diff --git a/bench/iota.scm b/bench/iota.scm index 2ae816579aceebffda6b51dc3c6fdfb8746703ed..aa9ee853a4cfc8a044cd038e7493577d7653259b 100644 --- a/bench/iota.scm +++ b/bench/iota.scm @@ -130,8 +130,8 @@ (timing "新版本:\t\t" (lambda () (repeat 200 (lambda () (iota-new 5000 10 3))))) (timing "c版本:\t\t" - (lambda () (repeat 200 (lambda () (iota 5000 10 3))))) -) + (lambda () (repeat 200 (lambda () (iota 5000 10 3)))))) + ;;; 运行测试 (verify) diff --git a/bench/rich-integer.scm b/bench/rich-integer.scm index bd778b5581fa331ac5dcb382dbb1b893d8c415a8..d69a9ded50d2b66606b1ee8ee4e611113da6026f 100644 --- a/bench/rich-integer.scm +++ b/bench/rich-integer.scm @@ -52,8 +52,8 @@ r)))) (define rint-lambda -(lambda args (define (@is-type-of obj) (and (case-class? obj) (obj :is-instance-of 'rich-integer))) (define (@max-value) 9223372036854775807) (define (@min-value) -9223372036854775808) (define (is-normal-function? msg) (and (symbol? msg) (char=? (string-ref (symbol->string msg) 0) #\:))) (define (static-dispatcher msg . args) (cond ((eq? msg :is-type-of) (apply @is-type-of args)) ((eq? msg :max-value) (apply @max-value args)) ((eq? msg :min-value) (apply @min-value args)) (else (value-error "No such static method " msg)))) (define* (make-case-class-rich-integer data) (unless (integer? data) (type-error (format #f "In funtion #<~a ~a>: argument *~a* must be *~a*! **Got ~a**" make-case-class-rich-integer '(data) 'data "integer" (object->string data)))) (define {gensym}-171 #f) (define (%this . xs) (if (null? xs) {gensym}-171 (apply {gensym}-171 xs))) (define (%is-instance-of x) (eq? x 'rich-integer)) (define (%equals that) (unless (case-class? that) (type-error (format #f "In funtion #<~a ~a>: argument *~a* must be *~a*! **Got ~a**" %equals '(that) 'that "case-class" (object->string that)))) (and (that :is-instance-of 'rich-integer) (equal? data (that 'data)))) (define (%apply . args) (cond ((null? args) (value-error rich-integer "Apply on zero args is not implemented")) ((equal? ((symbol->string (car args)) 0) #\:) (value-error rich-integer "No such method: " (car args))) (else (value-error rich-integer "No such field: " (car args))))) (define (%to-string) (let ((field-strings (list (string-append ":data" " " (object->string data))))) (let loop ((strings field-strings) (acc "")) (if (null? strings) (string-append "(" "rich-integer" " " acc ")") (loop (cdr strings) (if (zero? (string-length acc)) (car strings) (string-append acc " " (car strings)))))))) (define (%get) data) (define (%to n) (unless (integer? n) (type-error (format #f "In funtion #<~a ~a>: argument *~a* must be *~a*! **Got ~a**" %to '(n) 'n "integer" (object->string n)))) (if (< n data) (rich-list (list)) (rich-list (iota (+ (- n data) 1) data)))) (define (%until n) (unless (integer? n) (type-error (format #f "In funtion #<~a ~a>: argument *~a* must be *~a*! **Got ~a**" %until '(n) 'n "integer" (object->string n)))) (if (<= n data) (rich-list (list)) (rich-list (iota (+ (- n data)) data)))) (define (%to-rich-char) (rich-char data)) (define (%to-string) (number->string data)) (define (%sqrt) (if (< data 0) (value-error (format #f "sqrt of negative integer is undefined! ** Got ~a **" data)) (inexact->exact (floor (sqrt data))))) (define (instance-dispatcher) (lambda (msg . args) (cond ((eq? msg :sqrt) (apply %sqrt args)) ((eq? msg :is-instance-of) (apply %is-instance-of args)) ((eq? msg :equals) (apply %equals args)) ((eq? msg :to-string) (%to-string)) ((eq? msg :this) (apply %this args)) ((eq? msg :data) (rich-integer (car args))) ((is-normal-function? msg) (case msg ((:get) (apply %get args)) ((:to) (apply %to args)) ((:until) (apply %until args)) ((:to-rich-char) (apply %to-rich-char args)) ((:to-string) (apply %to-string args)) ((:sqrt) (apply %sqrt args)) (else (value-error rich-integer "No such method: " msg)))) ((eq? msg 'data) data) (else (apply %apply (cons msg args)))))) (set! {gensym}-171 (instance-dispatcher)) {gensym}-171) (if (null? args) (make-case-class-rich-integer) (let ((msg (car args))) (cond ((in? msg (list :max-value :min-value :is-type-of)) (apply static-dispatcher args)) ((and (zero? 1) (in? :apply (list :max-value :min-value))) (apply static-dispatcher (cons :apply args))) (else (apply make-case-class-rich-integer args)))))) -) + (lambda args (define (@is-type-of obj) (and (case-class? obj) (obj :is-instance-of 'rich-integer))) (define (@max-value) 9223372036854775807) (define (@min-value) -9223372036854775808) (define (is-normal-function? msg) (and (symbol? msg) (char=? (string-ref (symbol->string msg) 0) #\:))) (define (static-dispatcher msg . args) (cond ((eq? msg :is-type-of) (apply @is-type-of args)) ((eq? msg :max-value) (apply @max-value args)) ((eq? msg :min-value) (apply @min-value args)) (else (value-error "No such static method " msg)))) (define* (make-case-class-rich-integer data) (unless (integer? data) (type-error (format #f "In funtion #<~a ~a>: argument *~a* must be *~a*! **Got ~a**" make-case-class-rich-integer '(data) 'data "integer" (object->string data)))) (define {gensym}-171 #f) (define (%this . xs) (if (null? xs) {gensym}-171 (apply {gensym}-171 xs))) (define (%is-instance-of x) (eq? x 'rich-integer)) (define (%equals that) (unless (case-class? that) (type-error (format #f "In funtion #<~a ~a>: argument *~a* must be *~a*! **Got ~a**" %equals '(that) 'that "case-class" (object->string that)))) (and (that :is-instance-of 'rich-integer) (equal? data (that 'data)))) (define (%apply . args) (cond ((null? args) (value-error rich-integer "Apply on zero args is not implemented")) ((equal? ((symbol->string (car args)) 0) #\:) (value-error rich-integer "No such method: " (car args))) (else (value-error rich-integer "No such field: " (car args))))) (define (%to-string) (let ((field-strings (list (string-append ":data" " " (object->string data))))) (let loop ((strings field-strings) (acc "")) (if (null? strings) (string-append "(" "rich-integer" " " acc ")") (loop (cdr strings) (if (zero? (string-length acc)) (car strings) (string-append acc " " (car strings)))))))) (define (%get) data) (define (%to n) (unless (integer? n) (type-error (format #f "In funtion #<~a ~a>: argument *~a* must be *~a*! **Got ~a**" %to '(n) 'n "integer" (object->string n)))) (if (< n data) (rich-list (list)) (rich-list (iota (+ (- n data) 1) data)))) (define (%until n) (unless (integer? n) (type-error (format #f "In funtion #<~a ~a>: argument *~a* must be *~a*! **Got ~a**" %until '(n) 'n "integer" (object->string n)))) (if (<= n data) (rich-list (list)) (rich-list (iota (+ (- n data)) data)))) (define (%to-rich-char) (rich-char data)) (define (%to-string) (number->string data)) (define (%sqrt) (if (< data 0) (value-error (format #f "sqrt of negative integer is undefined! ** Got ~a **" data)) (inexact->exact (floor (sqrt data))))) (define (instance-dispatcher) (lambda (msg . args) (cond ((eq? msg :sqrt) (apply %sqrt args)) ((eq? msg :is-instance-of) (apply %is-instance-of args)) ((eq? msg :equals) (apply %equals args)) ((eq? msg :to-string) (%to-string)) ((eq? msg :this) (apply %this args)) ((eq? msg :data) (rich-integer (car args))) ((is-normal-function? msg) (case msg ((:get) (apply %get args)) ((:to) (apply %to args)) ((:until) (apply %until args)) ((:to-rich-char) (apply %to-rich-char args)) ((:to-string) (apply %to-string args)) ((:sqrt) (apply %sqrt args)) (else (value-error rich-integer "No such method: " msg)))) ((eq? msg 'data) data) (else (apply %apply (cons msg args)))))) (set! {gensym}-171 (instance-dispatcher)) {gensym}-171) (if (null? args) (make-case-class-rich-integer) (let ((msg (car args))) (cond ((in? msg (list :max-value :min-value :is-type-of)) (apply static-dispatcher args)) ((and (zero? 1) (in? :apply (list :max-value :min-value))) (apply static-dispatcher (cons :apply args))) (else (apply make-case-class-rich-integer args))))))) + (with-let (funclet rint) (define (%to-string) diff --git a/bench/test-speed.scm b/bench/test-speed.scm index 1c1823085e2288232f69f6d3e7b12219c73f63ae..0e5460a30c40c872c6dc8b44bffdc974c9c25eb4 100644 --- a/bench/test-speed.scm +++ b/bench/test-speed.scm @@ -28,12 +28,12 @@ ;; --- User's original functions (to be tested) --- (define (build-digits-str-2) (let ((digits-str - ($ ($ (reverse digits) - :map (lambda (x) (box (number->string x))) - :map (@ _ :pad-left 9 #\0) - :make-string) - :drop-while (@ _ :equals (rich-char #\0)) - :get))) + ($ ($ (reverse digits) + :map (lambda (x) (box (number->string x))) + :map (@ _ :pad-left 9 #\0) + :make-string) + :drop-while (@ _ :equals (rich-char #\0)) + :get))) (if (string-null? digits-str) "0" digits-str))) (define (build-digits-str) @@ -44,7 +44,7 @@ (cond ;; 最高位(向量的最后一位),无需前导零 ((= i (- len 1)) - (number->string (vector-ref digits i))) + (number->string (vector-ref digits i))) ;; 其他位,需要前导零填充到dlen长度 (else (let ((str (number->string (vector-ref digits i)))) @@ -164,8 +164,8 @@ "Large Number of Chunks (50 Chunks)" ; 测试用例描述 fifty-chunks-vector ; 包含50个块的向量 9 ; dlen (假设保持为9) - num-iterations ; 从 run-all-tests 传入的迭代次数 - )) + num-iterations)) ; 从 run-all-tests 传入的迭代次数 + (let ((1000-chunks-vector (make-vector 1000))) ;; 用一些示例数据填充这个向量 @@ -179,8 +179,8 @@ "Large Number of Chunks (1000 Chunks)" ; 测试用例描述 1000-chunks-vector ; 包含50个块的向量 9 ; dlen (假设保持为9) - num-iterations ; 从 run-all-tests 传入的迭代次数 - )) + num-iterations)) ; 从 run-all-tests 传入的迭代次数 + (execute-test-case "All Zero Chunks" diff --git a/demo/demo_argparse.scm b/demo/demo_argparse.scm index 82966a62c00ea28e78467eed40826390cad3c003..bf38631c7e3216f4b8b34565739b7be4de9924b3 100644 --- a/demo/demo_argparse.scm +++ b/demo/demo_argparse.scm @@ -2,6 +2,6 @@ (let1 parser (make-argument-parser) (parser 'add - '((name . "width") (type . number) (default . 40))) + '((name . "width") (type . number) (default . 40))) (parser 'parse) (display* (parser 'width) "\n")) diff --git a/demo/demo_bitree.scm b/demo/demo_bitree.scm index 77b454c4f072eccb0e31371a4a4a6a8e5a1faeb4..20ef1b2a6de6d629f452659e24456c7b07f8e99b 100644 --- a/demo/demo_bitree.scm +++ b/demo/demo_bitree.scm @@ -8,23 +8,23 @@ (left bitree?) (right bitree?)) -(define (%leaf?) - (and (null? left) (null? right))) + (define (%leaf?) + (and (null? left) (null? right))) -(typed-define (@leaf (x string?)) - (bitree x '() '())) + (typed-define (@leaf (x string?)) + (bitree x '() '())) -(define (%make-string) - (if (%leaf?) - ($ "(" :+ data :+ ")") - ($ (list data (if (null? left) "()" (left :to-string)) - (if (null? right) "()" (right :to-string))) + (define (%make-string) + (if (%leaf?) + ($ "(" :+ data :+ ")") + ($ (list data (if (null? left) "()" (left :to-string)) + (if (null? right) "()" (right :to-string))) :make-string "(" " " ")"))) -(define (%to-string) - (%make-string)) + (define (%to-string) + (%make-string))) -) ; end of define-case-class + ; end of define-case-class diff --git a/demo/demo_curlet.scm b/demo/demo_curlet.scm index 5134e7afb6725495eb6a742c05fdc66182553d53..1b1a74258179b4b1256da5e38166539e3edd8a3f 100644 --- a/demo/demo_curlet.scm +++ b/demo/demo_curlet.scm @@ -2,8 +2,8 @@ (define (print-curlet-length) (display "Length of curlet ") (display (length (rootlet))) - (newline) -) + (newline)) + (print-curlet-length) (import (liii oop)) diff --git a/demo/demo_error.scm b/demo/demo_error.scm index ce7a9fed6357deb909487197ea8902efae1ba897..412a1a505aedad8a679f13eb3a5134612177bb94 100644 --- a/demo/demo_error.scm +++ b/demo/demo_error.scm @@ -1 +1 @@ -(car (list )) +(car (list)) diff --git a/demo/demo_prime.scm b/demo/demo_prime.scm index 396cbe2561339d558c383a23c70ad3d248915b48..679fb07941dc6cefd3227eecdc2a782c569bc233 100644 --- a/demo/demo_prime.scm +++ b/demo/demo_prime.scm @@ -32,8 +32,8 @@ (let1 n 1073729 (timing "R7RS: " (lambda () ((range 1 100) :for-each (lambda (x) (prime1? n))))) (timing "Goldfish: " (lambda () ((range 1 100) :for-each (lambda (x) (prime2? n))))) - (display* (prime1? n) "\n") -) + (display* (prime1? n) "\n")) + ; (($ 1 :to 100) ; :filter prime? diff --git a/demo/design_pattern.scm b/demo/design_pattern.scm index 688b09727fc939439d27453387997da7ebb1ca80..d23ab7dfdf53c6c612bafce76c365c11d30e6d97 100644 --- a/demo/design_pattern.scm +++ b/demo/design_pattern.scm @@ -3,8 +3,8 @@ ; Singleton (define-object cat (define (@run) - "I'm a running cat") -) + "I'm a running cat")) + (check (cat :run) => "I'm a running cat") @@ -18,8 +18,8 @@ (define (@apply name) (let1 d (duck) (d :set-name! name) - d)) -) + d))) + (define-class dog ((name string? "doggy")) @@ -30,8 +30,8 @@ (define (@apply name) (let1 d (dog) (d :set-name! name) - d)) -) + d))) + (define-object animal (define (@create kind) @@ -40,8 +40,8 @@ (duck "Duck")) ((dog) (dog "Dog")) - (else (??? "No such kind")))) -) + (else (??? "No such kind"))))) + (check (animal :create 'duck) => (duck "Duck")) (check (animal :create 'dog) => (dog "Dog")) diff --git a/flake.nix b/flake.nix index 6da83e7f9adb257d88b3d0661abca88893fef46e..f109895c683827048ceffc83c23c6d9f33d4ecb1 100644 --- a/flake.nix +++ b/flake.nix @@ -121,6 +121,24 @@ keep-sorted = { includes = lib.mkForce [ "*.nix" ]; }; + parinfer = { + command = "${pkgs.bash}/bin/bash"; + options = [ + "-euc" + '' + for file in "$@"; do + tmpfile=$(mktemp) + if ${lib.getExe pkgs.parinfer-rust} --l scheme -m paren < "$file" > "$tmpfile"; then + mv "$tmpfile" "$file" + else + rm -f "$tmpfile" + fi + done + '' + "--" # bash swallows the second argument when using -c + ]; + includes = [ "*.scm" ]; + }; }; }; }; diff --git a/goldfish/liii/alist.scm b/goldfish/liii/alist.scm index e0284d1624bc3453a5d110c8b2b856bea85bd89d..d27f1b86d5108896adf1ec83b3f42547a495bd6b 100644 --- a/goldfish/liii/alist.scm +++ b/goldfish/liii/alist.scm @@ -45,8 +45,8 @@ (cons (cons n (car x)) (if (null? (cdr x)) '() - (loop (cdr x) (+ n 1)))))))) + (loop (cdr x) (+ n 1)))))))))) - ) ; end of begin - ) ; end of library + ; end of begin + ; end of library diff --git a/goldfish/liii/argparse.scm b/goldfish/liii/argparse.scm index 6337d748ba8439cf7cff60cf64a6238e16c5be32..6d1e0b2a9154d4ba8c568195b42c420b087e77bb 100644 --- a/goldfish/liii/argparse.scm +++ b/goldfish/liii/argparse.scm @@ -132,8 +132,8 @@ (else (if (and (null? args) (symbol? command)) (%get-argument args-ht (list (symbol->string command))) - (error "Unknown parser command" command))))))) + (error "Unknown parser command" command))))))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/array-buffer.scm b/goldfish/liii/array-buffer.scm index 1a64aff641fde8e604a642229f78186518e39e95..55ae133467824a9a8d1b31ea6763926df8518b09 100644 --- a/goldfish/liii/array-buffer.scm +++ b/goldfish/liii/array-buffer.scm @@ -118,10 +118,10 @@ (vector->list data 0 size)) (define (%to-rich-list) - (box (%to-list))) + (box (%to-list)))))) - ) ; end of array-buffer + ; end of array-buffer - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/base.scm b/goldfish/liii/base.scm index 9aa4521c57fa4659bbce747062c1e28c63fffa40..ade09707aa43e01d65277a3066fcb2edcf767573 100644 --- a/goldfish/liii/base.scm +++ b/goldfish/liii/base.scm @@ -59,8 +59,8 @@ ; Extra routines loose-car loose-cdr compose identity any? ; Extra structure - let1 typed-lambda - ) + let1 typed-lambda) + (begin (define* (u8-substring str (start 0) (end #t)) @@ -108,8 +108,8 @@ "~S is not ~S~%" ',(car arg) ',(cadr arg))) (values))) args) - ,@body)))) + ,@body)))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/base64.scm b/goldfish/liii/base64.scm index b6fd86823764ac9e46d35498f9909c9f0ba5f5cd..9cf9265afa06e763342b5c16aae5304763c2fcd5 100644 --- a/goldfish/liii/base64.scm +++ b/goldfish/liii/base64.scm @@ -19,8 +19,8 @@ (liii bitwise)) (export string-base64-encode bytevector-base64-encode base64-encode - string-base64-decode bytevector-base64-decode base64-decode - ) + string-base64-decode bytevector-base64-decode base64-decode) + (begin (define-constant BYTE2BASE64_BV (string->utf8 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")) @@ -129,8 +129,8 @@ ((bytevector? x) (bytevector-base64-decode x)) (else - (type-error "input must be string or bytevector")))) + (type-error "input must be string or bytevector")))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/bitwise.scm b/goldfish/liii/bitwise.scm index efcb3c5df0c56d17eaa79714b7d3b51913236813..9af0a274918c32868edfe935cc1b725fb88640ba 100644 --- a/goldfish/liii/bitwise.scm +++ b/goldfish/liii/bitwise.scm @@ -26,12 +26,12 @@ bit-field bit-field-any? bit-field-every? bit-field-clear bit-field-set ; S7 built-in lognot logand logior logxor - ash - ) + ash) + (begin - (define bitwise-or bitwise-ior) + (define bitwise-or bitwise-ior))) - ) ; end of begin - ) ; end of library + ; end of begin + ; end of library diff --git a/goldfish/liii/case.scm b/goldfish/liii/case.scm index 1ac938edafb630f6bd539516399065ae2ff45748..dd4f8fc942bf519bad1e43fa01d850c6b711b960 100644 --- a/goldfish/liii/case.scm +++ b/goldfish/liii/case.scm @@ -337,8 +337,8 @@ clauses))))))) ;; case* (#_macro (selector . clauses) - `(((#_funclet 'case*) 'case*-helper) ,selector ',clauses (#_curlet))))) + `(((#_funclet 'case*) 'case*-helper) ,selector ',clauses (#_curlet))))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/check.scm b/goldfish/liii/check.scm index 4b8d88dcc6b33126a0a86a3bd1ea640ce1ddef1c..4990136a1293f4006c82157a1bddefa3e09b10dd 100644 --- a/goldfish/liii/check.scm +++ b/goldfish/liii/check.scm @@ -48,8 +48,8 @@ (define* (check-float a b (epsilon 1e-10)) (or (= a b) - (< (abs (- a b)) epsilon))) + (< (abs (- a b)) epsilon))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/chez.scm b/goldfish/liii/chez.scm index f3274009bc7644451be12327fdc722a078f589df..8bad721df655068d4728e45bccfd389a787cc247 100644 --- a/goldfish/liii/chez.scm +++ b/goldfish/liii/chez.scm @@ -19,8 +19,8 @@ (begin (define (atom? x) - (not (pair? x))) + (not (pair? x))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/comparator.scm b/goldfish/liii/comparator.scm index 7c00a1fcd6388c13147cd0ef55555039ad20b4e2..b8632c5218a953a4cafbf57c515d482ae14ca8e9 100644 --- a/goldfish/liii/comparator.scm +++ b/goldfish/liii/comparator.scm @@ -26,10 +26,10 @@ comparator-type-test-predicate comparator-equality-predicate comparator-ordering-predicate comparator-hash-function comparator-test-type comparator-check-type comparator-hash - =? ? <=? >=? - ) - (begin + =? ? <=? >=?) + + (begin)) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/either.scm b/goldfish/liii/either.scm index 760736a7970d9cd98919a04e23b4babaeba4198a..52863a4f77bbdadfde3642941a8332fb7407c912 100644 --- a/goldfish/liii/either.scm +++ b/goldfish/liii/either.scm @@ -108,15 +108,15 @@ %exists '(pred) 'pred "procedure" (object->string pred)))) (if (%right?) (pred value) - #f)) + #f))) - ) + (define (left v) (either 'left v)) (define (right v) - (either 'right v)) + (either 'right v)))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/error.scm b/goldfish/liii/error.scm index 0c2b97048da4055380bb2bfafade1d9deb1d522a..af382623d3d04f0480a3d1afbb53be76304e2b57 100644 --- a/goldfish/liii/error.scm +++ b/goldfish/liii/error.scm @@ -52,8 +52,8 @@ (apply error (cons 'index-error args))) (define (??? . args) - (apply error (cons '??? args))) + (apply error (cons '??? args))))) - ) ; begin - ) ; define-library + ; begin + ; define-library diff --git a/goldfish/liii/hash-table.scm b/goldfish/liii/hash-table.scm index e5b6593623e9e177d382b5bc50797e087c04d2df..656406b85300f5a19d61efd8286413a7f56e9535 100644 --- a/goldfish/liii/hash-table.scm +++ b/goldfish/liii/hash-table.scm @@ -27,9 +27,9 @@ hash-table-size hash-table-keys hash-table-values hash-table-entries hash-table-find hash-table-count hash-table-for-each hash-table-map->list - hash-table->alist - ) - (begin - ) ; end of begin - ) ; end of library + hash-table->alist) + + (begin)) + ; end of begin + ; end of library diff --git a/goldfish/liii/lang.scm b/goldfish/liii/lang.scm index b1e80dae507d1d82be921478d235313bf5b93310..56b9d7b156e444384f83b9c5ad42c89ebd74d542 100644 --- a/goldfish/liii/lang.scm +++ b/goldfish/liii/lang.scm @@ -42,8 +42,8 @@ option none either left right rich-integer rich-float rich-char rich-string rich-vector rich-list array rich-hash-table - box $ - ) + box $) + (begin (define (class=? left right) @@ -153,9 +153,9 @@ arg1, arg2, ... : any (if (< data 0) (value-error (format #f "sqrt of negative integer is undefined! ** Got ~a **" data)) - (inexact->exact (floor (sqrt data))))) + (inexact->exact (floor (sqrt data)))))) - ) + (define-case-class rich-rational ((data rational?)) @@ -164,9 +164,9 @@ arg1, arg2, ... : any (define (%abs) (if (< data 0) (- 0 data) - data)) + data))) - ) + (define-case-class rich-float ((data float?)) @@ -184,15 +184,15 @@ arg1, arg2, ... : any (if (< data 0) (value-error (format #f "sqrt of negative float is undefined! ** Got ~a **" data)) - (sqrt data))) + (sqrt data)))) - ) + - (define array rich-vector) + (define array rich-vector))) - ) ; end of begin - ) ; end of library + ; end of begin + ; end of library diff --git a/goldfish/liii/lint.scm b/goldfish/liii/lint.scm index 5495c40d1a3bb9d59e25f546c43571d40f0eca4b..2cdec5100d3dbed881341c3f90b15dc009f8db51 100644 --- a/goldfish/liii/lint.scm +++ b/goldfish/liii/lint.scm @@ -27,7 +27,7 @@ (values (list->string (reverse result)) chars)) (else (loop (cdr chars) (cons (car chars) result)))))) -#| + #| lint-check-brackets 检查字符串中的括号是否平衡匹配,提供精确的符号上下文。 diff --git a/goldfish/liii/list.scm b/goldfish/liii/list.scm index 49ebbc4070b8901f52826b2c0b60c10aa4614b06..4fc979dfca3b4213a5c9117588bb65668feefec8 100644 --- a/goldfish/liii/list.scm +++ b/goldfish/liii/list.scm @@ -41,8 +41,8 @@ ; Liii List extensions flat-map list-null? list-not-null? not-null-list? - length=? length>? length>=? flatten - ) + length=? length>? length>=? flatten) + (import (srfi srfi-1) (srfi srfi-13) (liii error) @@ -143,9 +143,9 @@ (string-append "flatten: the second argument depth should be symbol " "`deepest' or a integer, which will be uesd as depth," - " but got a ~A") depth))) - ) ; end of (define* (flatten)) + " but got a ~A") depth)))))) + ; end of (define* (flatten)) - ) ; end of begin - ) ; end of library + ; end of begin + ; end of library diff --git a/goldfish/liii/logging.scm b/goldfish/liii/logging.scm index 7bd5aff95927a7bf070a1c45aa97c5fa52104551..5adeda46f0f60c4ca5da993d1e16cd8ee20c5534 100644 --- a/goldfish/liii/logging.scm +++ b/goldfish/liii/logging.scm @@ -135,10 +135,10 @@ (define (%critical . args) (when (%critical?) - (apply print-log "CRITICAL" args))) + (apply print-log "CRITICAL" args)))))) - ) + - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/oop.scm b/goldfish/liii/oop.scm index d29e560044ba8d17b8d286c5875824f401cb17ad..53860bf9486b8ba408cdac826e592d68f3bf3ae4 100644 --- a/goldfish/liii/oop.scm +++ b/goldfish/liii/oop.scm @@ -19,8 +19,8 @@ (export @ typed-define define-case-class define-object define-class case-class? chained-define display* object->string - chain-apply - ) + chain-apply) + (begin (define-macro (@ . paras) @@ -288,8 +288,8 @@ (else (apply %apply (cons msg args)))))) (set! ,this-symbol (instance-dispatcher)) - ,this-symbol - ) ; end of the internal typed define + ,this-symbol) + ; end of the internal typed define (if (null? args) (,f-make-case-class) @@ -299,11 +299,11 @@ ((and (zero? ,field-count) (member :apply (list ,@static-messages))) (apply static-dispatcher (cons :apply args))) (else - (apply ,f-make-case-class args))))) + (apply ,f-make-case-class args)))))))) - ) ; end of define - ) ; end of let - ) ; end of define-macro + ; end of define + ; end of let + ; end of define-macro (define-macro (define-object object-name . definitions) (let* ((static-methods (filter (lambda (def) @@ -350,8 +350,8 @@ (with-let (funclet ,object-name) ,@definitions ,@varlet-bindings - #t - )))) + #t)))) + (define-macro (define-class class-name private-fields . private-fields-and-methods) (let* ((field-defs '()) @@ -434,7 +434,7 @@ (define (object->string x) (if (case-class? x) (x :to-string) - (s7-object->string x))) + (s7-object->string x))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/option.scm b/goldfish/liii/option.scm index beae1fbc2bc2c6ab6aa824f76ffd7436b912671f..3f141266e99d7d626ad3e3b9dfb1a629a9c20d41 100644 --- a/goldfish/liii/option.scm +++ b/goldfish/liii/option.scm @@ -84,11 +84,11 @@ (chain-apply args (if (or (null? value) (not (pred value))) (option '()) - (option value)))) + (option value))))) - ) + - (define (none) (option '())) + (define (none) (option '())))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/os.scm b/goldfish/liii/os.scm index 00810460a289f948959b1073d68e3cf12864c61f..57b86361f7b6dced153b16c2f00e8739a2f35e58 100644 --- a/goldfish/liii/os.scm +++ b/goldfish/liii/os.scm @@ -130,8 +130,8 @@ (g_getlogin))) (define (getpid) - (g_getpid)) + (g_getpid)))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/path.scm b/goldfish/liii/path.scm index 348bc47aaeac5b19ec2c0b067967b3bda27da539..32154d9552b3459c01ed713eb7e6e71058e73e68 100644 --- a/goldfish/liii/path.scm +++ b/goldfish/liii/path.scm @@ -18,8 +18,8 @@ (export path-dir? path-file? path-exists? path-getsize path-read-text path-read-bytes path-write-text path-append-text path-touch - path - ) + path) + (import (liii base) (liii lang) (liii error) (liii vector) (liii string) (liii list) (liii os)) (begin @@ -332,10 +332,10 @@ (else (value-error "path@home: unknown type")))) (chained-define (@temp-dir) - (path (os-temp-dir))) + (path (os-temp-dir)))))) - ) + - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/range.scm b/goldfish/liii/range.scm index 68455068ffb9b729ba57c3ce2df55737a9e1ca1f..7e6285fd88120ec6e4c8f7148965d47d0d0c6ae2 100644 --- a/goldfish/liii/range.scm +++ b/goldfish/liii/range.scm @@ -79,12 +79,12 @@ #f (if (in-range? elem) ;判断是否在范围内 (zero? (modulo (- elem start) (abs step))) - #f))) + #f)))))) - ) ; define-case-cass - ) ; begin - ) ; define-library + ; define-case-cass + ; begin + ; define-library diff --git a/goldfish/liii/rich-char.scm b/goldfish/liii/rich-char.scm index 9a12eff539bbfe6690b6df89f42e56b0d8fc6f21..acbab13109cdd2f93e3782ece3509ae70c96a200 100644 --- a/goldfish/liii/rich-char.scm +++ b/goldfish/liii/rich-char.scm @@ -171,9 +171,9 @@ (rich-char x))) (define (%to-integer) - code-point) + code-point)))) - ) + - ) ; end of begin - ) ; end of define-library \ No newline at end of file + ; end of begin + ; end of define-library \ No newline at end of file diff --git a/goldfish/liii/rich-hash-table.scm b/goldfish/liii/rich-hash-table.scm index 4818da7741d3d16b6e330aee44ae3e1c7cce98e8..0ec89b2cf9bc7c7f902d1133924187e6dd872879 100644 --- a/goldfish/liii/rich-hash-table.scm +++ b/goldfish/liii/rich-hash-table.scm @@ -94,9 +94,9 @@ (lambda (k v) (when (f k v) (hash-table-set! r k v))) data) - (rich-hash-table r)))) + (rich-hash-table r))))))) - ) ; end of define-case-class + ; end of define-case-class - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/rich-list.scm b/goldfish/liii/rich-list.scm index e62583623b3e59ad7311d5b6f9c67bc2831480f5..7847f922e53bb3efc857b9b338aea03d5b1bddae 100644 --- a/goldfish/liii/rich-list.scm +++ b/goldfish/liii/rich-list.scm @@ -12,7 +12,7 @@ (define-case-class rich-list ((data list?)) -#| + #| rich-list@range 生成一个从起始值到结束值(不包含结束值)的数字序列。 @@ -79,7 +79,7 @@ step-and-args : list (let ((cnt (ceiling (/ (- end start) step-size)))) (rich-list (iota cnt start step-size)))))))) -#| + #| rich-list@empty 创建一个空的rich-list对象。 @@ -119,9 +119,9 @@ args : list (define (@empty . args) (chain-apply args - (rich-list (list )))) + (rich-list (list)))) -#| + #| rich-list@concat 连接两个rich-list为一个新的rich-list。 @@ -169,7 +169,7 @@ args : list (chain-apply args (rich-list (append (lst1 :collect) (lst2 :collect))))) -#| + #| rich-list@fill 创建一个指定长度、所有元素都为指定值的rich-list。 @@ -225,7 +225,7 @@ elem : any (else (rich-list (make-list n elem))))) -#| + #| rich-list%collect 将rich-list转换为标准的Scheme列表。 @@ -653,10 +653,10 @@ rich-list%collect (list->vector data)) (define (%to-rich-vector) - (rich-vector (list->vector data))) + (rich-vector (list->vector data)))))) - ) ; end of define-case-class rich-list + ; end of define-case-class rich-list - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/rich-string.scm b/goldfish/liii/rich-string.scm index 3236c7e2e66f6d03cb4686507880e59294a1472e..cf19059ac69feb392fc4680f138ed66e46c81cfc 100644 --- a/goldfish/liii/rich-string.scm +++ b/goldfish/liii/rich-string.scm @@ -340,9 +340,9 @@ (if (zero? sep-len) ((%to-rich-vector) :map (lambda (c) (c :make-string))) - (rich-vector (reverse-list->vector (split-helper 0 '())))))) + (rich-vector (reverse-list->vector (split-helper 0 '()))))))))) - ) + - ) - ) + + diff --git a/goldfish/liii/rich-vector.scm b/goldfish/liii/rich-vector.scm index 6fee342fb02e06b4120bf08151f048c51175800c..a2d3ab3de6b84708bca0d73707eca86cbfcd4bdf 100644 --- a/goldfish/liii/rich-vector.scm +++ b/goldfish/liii/rich-vector.scm @@ -438,9 +438,9 @@ (if (vector? v) (rich-vector (vector-append data v)) - (rich-vector (vector-append data (v :collect))))) + (rich-vector (vector-append data (v :collect)))))))) - ) ; end of define-case-class + ; end of define-case-class - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/set.scm b/goldfish/liii/set.scm index dac49e13b8e72a250f206fc3fa21505f692e2079..515dfdc7744456a77857b5a3332b92cf69208912 100644 --- a/goldfish/liii/set.scm +++ b/goldfish/liii/set.scm @@ -61,9 +61,9 @@ (chained-define (%clear!) (hash-table-clear! data) - (%this)) + (%this))))) - ) ; end of define-case-class - ) ; end of begin - ) ; end of define-library + ; end of define-case-class + ; end of begin + ; end of define-library diff --git a/goldfish/liii/stack.scm b/goldfish/liii/stack.scm index ad02b37fbeefe3b6d122eb3cc6820318ff688857..0272cc8c82f14736a81d792d722b7d36dcfec341 100644 --- a/goldfish/liii/stack.scm +++ b/goldfish/liii/stack.scm @@ -20,7 +20,7 @@ (begin (define-case-class stack ((data list?)) -#| + #| @empty 生成一个空栈对象。 @@ -51,9 +51,9 @@ - 时间复杂度:O(1) - 空间复杂度:O(1) |# - (define (@empty) (stack (list ))) + (define (@empty) (stack (list))) -#| + #| %length 获取栈中元素的数量。 @@ -85,7 +85,7 @@ |# (define (%length) (length data)) -#| + #| %size 获取栈中元素的数量。 @@ -117,7 +117,7 @@ |# (define (%size) (length data)) -#| + #| %top 获取栈顶元素。 @@ -157,7 +157,7 @@ (error 'out-of-range) (car data))) -#| + #| %pop 移除栈顶元素并返回新栈。 @@ -197,7 +197,7 @@ (error 'out-of-range "Cannot pop from an empty stack") (stack (cdr data)))) -#| + #| %pop! 移除栈顶元素并修改原栈。 @@ -242,7 +242,7 @@ (stack (set! data (cdr data)))) (%this)) -#| + #| %push 将元素压入栈顶并返回新栈。 @@ -281,7 +281,7 @@ element : any-type (chained-define (%push element) (stack (cons element data))) -#| + #| %push! 将元素压入栈顶并修改原栈。 @@ -321,7 +321,7 @@ element : any-type (stack (set! data (cons element data))) (%this)) -#| + #| %to-list 将栈转换为链表表示。 @@ -354,7 +354,7 @@ element : any-type |# (define (%to-list) data) -#| + #| %to-rich-list 将栈转换为rich-list表示。 @@ -385,8 +385,8 @@ element : any-type - 时间复杂度:O(n),其中n为栈内元素数量 - 空间复杂度:O(n),需要创建新的rich-list对象 |# - (define (%to-rich-list) (rich-list data)) - ) ; end of define-case-class - ) ; end of begin - ) ; end of define-library + (define (%to-rich-list) (rich-list data))))) + ; end of define-case-class + ; end of begin + ; end of define-library diff --git a/goldfish/liii/string.scm b/goldfish/liii/string.scm index 7a55470c73717e0a9ac65b670be0a306fa35eb11..da24826105533613114b804ffb4b78a05f0dccd4 100644 --- a/goldfish/liii/string.scm +++ b/goldfish/liii/string.scm @@ -34,8 +34,8 @@ string-tokenize ; Liii extras string-starts? string-ends? - string-remove-prefix string-remove-suffix - ) + string-remove-prefix string-remove-suffix) + (import (srfi srfi-13) (liii base) (liii error)) @@ -61,8 +61,8 @@ (typed-lambda ((str string?) (suffix string?)) (if (string-suffix? suffix str) (substring str 0 (- (string-length str) (string-length suffix))) - (string-copy str)))) + (string-copy str)))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/sys.scm b/goldfish/liii/sys.scm index 7e0de5d9784775e4118363ed2e0ac8ec738eb2ca..7395e38775a676f4fde2dcc8a15b634f6e4a28b3 100644 --- a/goldfish/liii/sys.scm +++ b/goldfish/liii/sys.scm @@ -18,7 +18,7 @@ (export argv executable) (import (scheme process-context)) (begin -#| + #| argv 返回一个程序命令行参数列表 @@ -52,7 +52,7 @@ argv 用于获取命令行参数返回一个存储命令行参数的列表。 (define (argv) (command-line)) -#| + #| executable 用来返回程序可执行文件的绝对路径 @@ -81,8 +81,8 @@ string |# - (define (executable) (g_executable)) + (define (executable) (g_executable)))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/trie.scm b/goldfish/liii/trie.scm index 373b983bb97f78eda1b766fbdfacad8d65f6ff5e..7787448dd03c719d0e15b4183972e34a96640ab8 100644 --- a/goldfish/liii/trie.scm +++ b/goldfish/liii/trie.scm @@ -91,7 +91,7 @@ (cons (car child) (trie->list (cdr child)))) (trie-children trie))) - (trie-value trie))) + (trie-value trie))))) - ) ; end of begin - ) ; end of library + ; end of begin + ; end of library diff --git a/goldfish/liii/uuid.scm b/goldfish/liii/uuid.scm index f8f1829e38ecc14cb29cee2cba92810d0dbd97ed..292d85d8ee3d23a8908d23c54b7c0416beba4e44 100644 --- a/goldfish/liii/uuid.scm +++ b/goldfish/liii/uuid.scm @@ -18,8 +18,8 @@ (export uuid4) (begin - (define (uuid4) (g_uuid4)) + (define (uuid4) (g_uuid4)))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/liii/vector.scm b/goldfish/liii/vector.scm index 296b2faedcba3354eab1292550615d22b574292d..c43264b267cadaf26bcab26ef5acfc8103845a5c 100644 --- a/goldfish/liii/vector.scm +++ b/goldfish/liii/vector.scm @@ -33,8 +33,8 @@ vector-swap! vector-reverse! vector-cumulate reverse-list->vector vector= ; Liii Extras - vector-filter - ) + vector-filter) + (begin (define (vector-filter pred vec) @@ -51,8 +51,8 @@ result-vec (begin (vector-set! result-vec i (car lst)) - (loop (- i 1) (cdr lst))))))) + (loop (- i 1) (cdr lst))))))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/scheme/base.scm b/goldfish/scheme/base.scm index 122050f219e5680fdb68b3d822855f59d0f9709c..b25f2a823c4826be46fbe414115f2939f8fda8ab 100644 --- a/goldfish/scheme/base.scm +++ b/goldfish/scheme/base.scm @@ -488,8 +488,8 @@ ; from S7 source repo: r7rs.scm (define* (string->vector s (start 0) end) (let ((stop (or end (length s)))) - (copy s (make-vector (- stop start)) start stop))) + (copy s (make-vector (- stop start)) start stop))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/scheme/boot.scm b/goldfish/scheme/boot.scm index 14f4a671d4e8b79610e893975f31082ab236e913..5d50ffa8540e71e5a041b754a52d51457e7bb84e 100644 --- a/goldfish/scheme/boot.scm +++ b/goldfish/scheme/boot.scm @@ -49,8 +49,8 @@ (when (not (defined? (symbol (object->string (car libs))))) ;(display "Loading ") (display lib-filename) (newline) (load lib-filename)) - (r7rs-import-library-filename (cdr libs))))) - ) + (r7rs-import-library-filename (cdr libs)))))) + (define-macro (import . libs) `(begin diff --git a/goldfish/scheme/case-lambda.scm b/goldfish/scheme/case-lambda.scm index af5fb5cf827822d54255068c6bf8e5c4959896f1..fd789b89402789cb298ed153d92c124e151cd305 100644 --- a/goldfish/scheme/case-lambda.scm +++ b/goldfish/scheme/case-lambda.scm @@ -16,8 +16,8 @@ `(else (apply (lambda ,(car choice) ,@(cdr choice)) args)) `((,(length (car choice))) (apply (lambda ,(car choice) ,@(cdr choice)) args)))) - choices)))) + choices)))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/scheme/char.scm b/goldfish/scheme/char.scm index cc75e85330a569edf0fb0e7f7ec09a898f64eadd..ad09e55ee58eafe5a92e6a99bfaff008e45753dd 100644 --- a/goldfish/scheme/char.scm +++ b/goldfish/scheme/char.scm @@ -16,14 +16,14 @@ (define-library (scheme char) (export - char-upcase char-downcase char-upper-case? char-lower-case? digit-value - ) + char-upcase char-downcase char-upper-case? char-lower-case? digit-value) + (begin (define (digit-value ch) (if (char-numeric? ch) (- (char->integer ch) (char->integer #\0)) - #f)) + #f)))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/scheme/file.scm b/goldfish/scheme/file.scm index 252c97bd4d3b1671bbbb602f689916d843f4ba21..a52893728195900e6248752c4659ebad81678333 100644 --- a/goldfish/scheme/file.scm +++ b/goldfish/scheme/file.scm @@ -20,8 +20,8 @@ (define open-binary-input-file open-input-file) - (define open-binary-output-file open-output-file) + (define open-binary-output-file open-output-file))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/scheme/inexact.scm b/goldfish/scheme/inexact.scm index ef8a6450e06565e668a6be69d8a88a02e258f26a..ef7d3ef9342675e492f6197f1f167e20b3007f77 100644 --- a/goldfish/scheme/inexact.scm +++ b/goldfish/scheme/inexact.scm @@ -30,8 +30,8 @@ (define (finite? x) (and (number? x) (not (infinite? x)) - (not (nan? x)))) + (not (nan? x)))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/scheme/process-context.scm b/goldfish/scheme/process-context.scm index 5e34f7534fe3465e006e818c238b0814810e764f..c9880c7a3413725c0cc941c02b988c034a7e7f65 100644 --- a/goldfish/scheme/process-context.scm +++ b/goldfish/scheme/process-context.scm @@ -22,7 +22,7 @@ (g_get-environment-variable key)) (define (command-line) - (g_command-line)) + (g_command-line)))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/scheme/time.scm b/goldfish/scheme/time.scm index 3630dfb9c35626f99d3a7baa6eaae27159472d07..d8613e78e9814293cf07fa38ea32c3a1326eeb76 100644 --- a/goldfish/scheme/time.scm +++ b/goldfish/scheme/time.scm @@ -23,7 +23,7 @@ (define (current-second) (g_current-second)) (define (current-jiffy) - (round (* (current-second) (jiffies-per-second)))) + (round (* (current-second) (jiffies-per-second)))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/srfi/srfi-1.scm b/goldfish/srfi/srfi-1.scm index 2766e20434d0b10e9f1290b63848b8c78e9cf96e..cd921daaf0afc354ea70823116663484c2f18ea5 100644 --- a/goldfish/srfi/srfi-1.scm +++ b/goldfish/srfi/srfi-1.scm @@ -337,8 +337,8 @@ (and (pair? x) (let ((x (cdr x)) (lag (cdr lag))) - (or (eq? x lag) (loop x lag)))))))) + (or (eq? x lag) (loop x lag)))))))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/srfi/srfi-113.scm b/goldfish/srfi/srfi-113.scm index 62b05ba7bff70c0df016b102e8cb6a2822e8003d..770db567a6b70bd11f540227755ccfd56c91acde 100644 --- a/goldfish/srfi/srfi-113.scm +++ b/goldfish/srfi/srfi-113.scm @@ -22,8 +22,8 @@ (define-library (srfi srfi-113) (import (scheme base)) (export set?) - (begin + (begin)) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/srfi/srfi-125.scm b/goldfish/srfi/srfi-125.scm index 401471174e32db1b607d5a0cf45941e2ffb59f22..794d7d9bc42c0c3a0f771b70248344b39aa94dab 100644 --- a/goldfish/srfi/srfi-125.scm +++ b/goldfish/srfi/srfi-125.scm @@ -28,8 +28,8 @@ hash-table-size hash-table-keys hash-table-values hash-table-entries hash-table-find hash-table-count hash-table-for-each hash-table-map->list - hash-table->alist - ) + hash-table->alist) + (begin (define (assert-hash-table-type ht f) @@ -154,8 +154,8 @@ (typed-lambda ((ht hash-table?)) (append-map (lambda (x) (list (car x) (cdr x))) - (map values ht)))) + (map values ht)))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/srfi/srfi-128.scm b/goldfish/srfi/srfi-128.scm index 1f3b46e118a11a7a7db34c7e7b49b92ae06ac6d5..e6fa21402d7c1941a2b8f6a6760b5e9f702a13eb 100644 --- a/goldfish/srfi/srfi-128.scm +++ b/goldfish/srfi/srfi-128.scm @@ -43,8 +43,8 @@ comparator-type-test-predicate comparator-equality-predicate comparator-ordering-predicate comparator-hash-function comparator-test-type comparator-check-type comparator-hash - =? ? <=? >=? - ) + =? ? <=? >=?) + (begin (define-record-type comparator @@ -369,8 +369,8 @@ (define (>=? comparator a b . objs) (let loop ((a a) (b b) (objs objs)) (and (binary>=? comparator a b) - (if (null? objs) #t (loop b (car objs) (cdr objs)))))) + (if (null? objs) #t (loop b (car objs) (cdr objs)))))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/srfi/srfi-13.scm b/goldfish/srfi/srfi-13.scm index cf62c93bb257bc9bf25f84291baed6de433edaae..df5e4f17a08797bc6577e93e9a0226d29ca09bac 100644 --- a/goldfish/srfi/srfi-13.scm +++ b/goldfish/srfi/srfi-13.scm @@ -383,8 +383,8 @@ (string-tokenize-sub (%string-from-range str (cdr char+start+end)) (car char+start+end))) - (else (error 'wrong-type-arg "string-tokenize")))) + (else (error 'wrong-type-arg "string-tokenize")))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/srfi/srfi-132.scm b/goldfish/srfi/srfi-132.scm index b43240da352f780b24bd2fb6b8c039da22abcc63..7d535cba7c77697b169d2216ac25889ef8c21eef 100644 --- a/goldfish/srfi/srfi-132.scm +++ b/goldfish/srfi/srfi-132.scm @@ -180,9 +180,9 @@ ((less-p v1 v2 start1 end1 start2 end2) (list->vector (list-merge less-p (subvector->list v1 start1 end1) (subvector->list v2 start2 end2)))))) - (define (vector-merge! . r) (???)) + (define (vector-merge! . r) (???)))) - ) ; end of begin - ) ; end of library + ; end of begin + ; end of library diff --git a/goldfish/srfi/srfi-133.scm b/goldfish/srfi/srfi-133.scm index 7252d94b0056ef5549e84656100d3cdd313dba94..918cc6aaacdb9199742600c4ae571463bca7f8c9 100644 --- a/goldfish/srfi/srfi-133.scm +++ b/goldfish/srfi/srfi-133.scm @@ -142,8 +142,8 @@ (let ((elem-i (vector-ref vec i)) (elem-j (vector-ref vec j))) (vector-set! vec i elem-j) - (vector-set! vec j elem-i) - )) + (vector-set! vec j elem-i))) + (define (vector-reverse! vec . args) (let* ((args-length (length args)) @@ -176,8 +176,8 @@ (if (null? l) v-rst (begin (vector-set! v-rst i (car l)) - (loop (cdr l) (- i 1)))))))) + (loop (cdr l) (- i 1)))))))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/srfi/srfi-151.scm b/goldfish/srfi/srfi-151.scm index 6d0e5764805c2e5477d9bfe5c054f333fd09f1a0..5b09ff39f520cdee20fddf3a47d301721f891d19 100644 --- a/goldfish/srfi/srfi-151.scm +++ b/goldfish/srfi/srfi-151.scm @@ -21,8 +21,8 @@ bit-count bitwise-orc1 bitwise-orc2 bitwise-andc1 bitwise-andc2 arithmetic-shift integer-length bitwise-if bit-set? copy-bit bit-swap any-bit-set? every-bit-set? first-set-bit - bit-field bit-field-any? bit-field-every? bit-field-clear bit-field-set - ) + bit-field bit-field-any? bit-field-every? bit-field-clear bit-field-set) + (begin (define bitwise-not lognot) @@ -161,8 +161,8 @@ (define (bit-field-set i start end) (bitwise-ior i (arithmetic-shift - (- (arithmetic-shift 1 (- end start)) 1) start))) + (- (arithmetic-shift 1 (- end start)) 1) start))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/srfi/srfi-2.scm b/goldfish/srfi/srfi-2.scm index b270e5ee4671af9e22fadfae5ffb0a5b053c8cc9..c2fd941bafdc7b7213282bc0d3ace83c72ca87c3 100644 --- a/goldfish/srfi/srfi-2.scm +++ b/goldfish/srfi/srfi-2.scm @@ -4,8 +4,8 @@ (begin (define-macro (and-let* vars . body) - `(let () (and ,@(map (lambda (v) `(define ,@v)) vars) (begin ,@body)))) + `(let () (and ,@(map (lambda (v) `(define ,@v)) vars) (begin ,@body)))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/srfi/srfi-216.scm b/goldfish/srfi/srfi-216.scm index 1148faebd0a7423a643d2c7d952898d2560e593c..acd6702825e2359d7181e0e7e5501a0e3a378cc4 100644 --- a/goldfish/srfi/srfi-216.scm +++ b/goldfish/srfi/srfi-216.scm @@ -26,8 +26,8 @@ (define nil '()) (define (runtime) - (round (* 1000 (current-second)))) + (round (* 1000 (current-second)))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/srfi/srfi-26.scm b/goldfish/srfi/srfi-26.scm index ace6cb45992e9c0e7987e1e54a668f349fe02eb0..4da829722b3feab125dbd870fefef004fa6e22cc 100644 --- a/goldfish/srfi/srfi-26.scm +++ b/goldfish/srfi/srfi-26.scm @@ -63,8 +63,8 @@ ((not (or (slot? (car paras)) (more-slot? (car paras)))) `(,(car xs) ,@(parse (cdr xs) (cdr paras)))) (else `(,(car paras) ,@(parse xs (cdr paras)))))))) - `(let ,lets (cut ,@(parse xs paras))))) + `(let ,lets (cut ,@(parse xs paras))))))) - ) ; end of begin - ) ; end of library + ; end of begin + ; end of library diff --git a/goldfish/srfi/srfi-39.scm b/goldfish/srfi/srfi-39.scm index 312e62409472d167fca8e756977edceb98929ed4..1444c8048f3d23fe722c0f32cd5c5703bcd21e58 100644 --- a/goldfish/srfi/srfi-39.scm +++ b/goldfish/srfi/srfi-39.scm @@ -29,7 +29,7 @@ `(with-let (funclet ,(car var)) (set! value (car old-values)) (set! old-values (cdr old-values)))) - vars)))) + vars)))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/srfi/srfi-78.scm b/goldfish/srfi/srfi-78.scm index 3ccafaf6cb7819cc09b0cffb202f69377e822565..29d8a1de40b522deea9ac691b3c895d2916b85cd 100644 --- a/goldfish/srfi/srfi-78.scm +++ b/goldfish/srfi/srfi-78.scm @@ -183,8 +183,8 @@ (display " correct, ") (display (length check:failed)) (display " failed.") - (newline)))) + (newline)))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/srfi/srfi-8.scm b/goldfish/srfi/srfi-8.scm index a3cbd237af51479a1e93a13e34736b01840dab07..0639d88fa6b6f3befb6d562f17aef642a4c54e86 100644 --- a/goldfish/srfi/srfi-8.scm +++ b/goldfish/srfi/srfi-8.scm @@ -21,8 +21,8 @@ (define-macro (receive formals expression . body) `(call-with-values (lambda () (values ,expression)) - (lambda ,formals ,@body))) + (lambda ,formals ,@body))))) - ) ; end of begin - ) ; end of define-library + ; end of begin + ; end of define-library diff --git a/goldfish/srfi/srfi-9.scm b/goldfish/srfi/srfi-9.scm index 1b35f79b79fa178a22adb66c9b073a23c395c830..7b670f6d79570b6db6f9b60eb8d37cceac174e15 100644 --- a/goldfish/srfi/srfi-9.scm +++ b/goldfish/srfi/srfi-9.scm @@ -1,7 +1,7 @@ (define-library (srfi srfi-9) (import (scheme base)) (export define-record-type) - (begin - ) ; end of begin - ) ; end of define-library + (begin)) + ; end of begin + ; end of define-library diff --git a/tests/goldfish/liii/base-test.scm b/tests/goldfish/liii/base-test.scm old mode 100755 new mode 100644 index b9e93689ca3304d9d87af50c5705529f29b23e41..8586c489dfc04c1be115409a123d47aba71b81fa --- a/tests/goldfish/liii/base-test.scm +++ b/tests/goldfish/liii/base-test.scm @@ -4742,7 +4742,7 @@ wrong-type-arg (check (make-vector 1 1) => (vector 1)) (check (make-vector 3 'a) => (vector 'a 'a 'a)) -(check (make-vector 0) => (vector )) +(check (make-vector 0) => (vector)) (check (vector-ref (make-vector 1) 0) => #) (check (vector 'a 'b 'c) => #(a b c)) @@ -5456,13 +5456,13 @@ wrong-type-arg (bytevector-u8-set! bv 0 10) (check bv => #u8(10 4 3 4 5)) (bytevector-u8-set! bv 4 255) - (check bv => #u8(10 4 3 4 255)) -) + (check bv => #u8(10 4 3 4 255))) + (let1 bv (bytevector 5) (bytevector-u8-set! bv 0 10) - (check bv => #u8(10)) -) + (check bv => #u8(10))) + ;; 错误处理测试 diff --git a/tests/goldfish/liii/bitwise-test.scm b/tests/goldfish/liii/bitwise-test.scm index 0e76268eee7b07b1d44f82dd4b97a0b26bdf5dd8..7e86d6f82f8bf93fe71bf5d386192075c011328e 100644 --- a/tests/goldfish/liii/bitwise-test.scm +++ b/tests/goldfish/liii/bitwise-test.scm @@ -169,13 +169,13 @@ (check (first-set-bit (expt 2 62)) => 62) (check (first-set-bit (expt -2 62)) => 62) -(check (bit-field #b1101101010 0 4) => #b1010 ) -(check (bit-field #b1101101010 3 9) => #b101101 ) -(check (bit-field #b1101101010 4 9) => #b10110 ) -(check (bit-field #b1101101010 4 10) => #b110110 ) -(check (bit-field 6 0 1) => 0 ) ; #110 => #0 -(check (bit-field 6 1 3) => 3 ) ; #110 => #11 -(check (bit-field 6 2 999) => 1 ) ; 超出整数长度的部分截断 +(check (bit-field #b1101101010 0 4) => #b1010) +(check (bit-field #b1101101010 3 9) => #b101101) +(check (bit-field #b1101101010 4 9) => #b10110) +(check (bit-field #b1101101010 4 10) => #b110110) +(check (bit-field 6 0 1) => 0) ; #110 => #0 +(check (bit-field 6 1 3) => 3) ; #110 => #11 +(check (bit-field 6 2 999) => 1) ; 超出整数长度的部分截断 (check-catch 'out-of-range (bit-field #x100000000000000000000000000000000 128 129)) ; start 超过64位整数范围 diff --git a/tests/goldfish/liii/comparator-test.scm b/tests/goldfish/liii/comparator-test.scm index e0ff80d58b5be57a5469b69e86503a0975cabf1a..b96a930b6b7d453d70f696c8704107a06432ec72 100644 --- a/tests/goldfish/liii/comparator-test.scm +++ b/tests/goldfish/liii/comparator-test.scm @@ -18,8 +18,8 @@ (check-true ( 42) - ) + (check (comparator-hash default-comp (list 1 2)) => 42)) + (check-report) diff --git a/tests/goldfish/liii/hash-table-test.scm b/tests/goldfish/liii/hash-table-test.scm index e00c833bf8dbedf00b745cbfacd13a7cedcf4e38..e3e33cfffdda132a3e92242bb0fc8e404922de8c 100644 --- a/tests/goldfish/liii/hash-table-test.scm +++ b/tests/goldfish/liii/hash-table-test.scm @@ -81,14 +81,14 @@ (check (hash-table-ref/default ht 'key (lambda () (begin (display "hello") (+ 1 2)))) - => 'value) - ) ; end of let1 + => 'value)) + ; end of let1 (let1 ht (make-hash-table) (hash-table-set! ht 'k1 'v1 'k2 'v2) (check (ht 'k1) => 'v1) - (check (ht 'k2) => 'v2) - ) + (check (ht 'k2) => 'v2)) + (let1 ht (make-hash-table) (hash-table-update! ht 'key 'value) @@ -99,8 +99,8 @@ (hash-table-update! ht 'key2 'value2) (hash-table-update! ht 'key3 'value3) (hash-table-update! ht 'key4 'value4) - (check (hash-table-delete! ht 'key1 'key2 'key3) => 3) - ) + (check (hash-table-delete! ht 'key1 'key2 'key3) => 3)) + (let1 ht (make-hash-table) (hash-table-update! ht 'key 'value) @@ -152,7 +152,7 @@ (let1 ht (make-hash-table) (check (call-with-values (lambda () (hash-table-entries ht)) (lambda (ks vs) (list ks vs))) - => (list (list ) (list ))) + => (list (list ) (list))) (hash-table-set! ht 'k1 'v1) (check (call-with-values (lambda () (hash-table-entries ht)) diff --git a/tests/goldfish/liii/lang-test.scm b/tests/goldfish/liii/lang-test.scm index 067dbe6aa02d7e2927af74104bfb358e57d73317..3692b3f735c316b9d4e520beb17606d9abdd937a 100644 --- a/tests/goldfish/liii/lang-test.scm +++ b/tests/goldfish/liii/lang-test.scm @@ -114,8 +114,8 @@ (define (%to-string) (string-append "I am " name " " (number->string age) " years old!")) (define (%greet x) - (string-append "Hi " x ", " (%to-string))) - ) + (string-append "Hi " x ", " (%to-string)))) + (let1 bob (jerson "Bob" 21) (check (bob :to-string) => "I am Bob 21 years old!") @@ -127,8 +127,8 @@ (define (%get-name) name) (define (%set-name! x) - (set! name x)) - ) + (set! name x))) + (let1 p (anonymous) (p :set-name! "Alice") @@ -154,8 +154,8 @@ ((boolean? x) (if x (r :set-true!) (r :set-false!))) (else (r :set-false!))) - r)) - ) + r))) + (check-true ((my-bool 'true) :true?)) (check-true ((my-bool 'false) :false?)) @@ -170,8 +170,8 @@ (test-case-class "static")) (define (%this-is-a-instance-method) - (test-case-class (string-append name "instance"))) - ) + (test-case-class (string-append name "instance")))) + (let1 hello (test-case-class "hello ") (check-catch 'value-error (hello :this-is-a-static-method)) @@ -222,21 +222,21 @@ (define-object string-utils (define (@concat x y) - (string-append x y)) - ) + (string-append x y))) + (check (string-utils :concat "a" "b") => "ab") (define-object object1 (define x 0) (define (@concat x y) - (string-append x y)) - ) + (string-append x y))) + (define-object object2 (define y 0) - (define (@return-object1) object1) - ) + (define (@return-object1) object1)) + (check ((object2 :return-object1) :concat "a" "b") => "ab") @@ -269,8 +269,8 @@ ;; 测试类型检查 (check-catch 'type-error (p1 :set-name! 123)) - (check-catch 'type-error (p1 :set-age! "invalid")) - ) + (check-catch 'type-error (p1 :set-age! "invalid"))) + (check-false (case-class? (lambda (x) x))) (check-false (case-class? +)) @@ -279,8 +279,8 @@ (let ((bob (person "Bob" 21))) (check-true (case-class? bob)) (check-false (case-class? +)) - (check-false (case-class? 42)) - ) + (check-false (case-class? 42))) + (check (class=? (list 1 2) (list 1 2)) => #t) (check (class=? (box 10) 10) => #t) @@ -350,11 +350,11 @@ (check (($ 1 :to 2) :collect) => (list 1 2)) (check (($ 1 :to 1) :collect) => (list 1)) -(check (($ 2 :to 1) :collect) => (list )) +(check (($ 2 :to 1) :collect) => (list)) (check (($ 1 :until 3) :collect) => (list 1 2)) (check (($ 1 :until 2) :collect) => (list 1)) -(check (($ 2 :until 2) :collect) => (list )) +(check (($ 2 :until 2) :collect) => (list)) (check ($ 65 :to-rich-char) => #\A) (check-catch 'value-error ($ #x110000 :to-rich-char)) @@ -912,8 +912,8 @@ (check (opt2 :get-or-else 0) => 0) (check (opt1 :get-or-else (lambda () 0)) => 42) - (check (opt2 :get-or-else (lambda () 0)) => 0) - ) + (check (opt2 :get-or-else (lambda () 0)) => 0)) + (check ((none) :get-or-else ($ 1)) => ($ 1)) @@ -921,8 +921,8 @@ (check (opt1 :or-else (option 0)) => (option 42)) (check (opt2 :or-else (option 0)) => (option 0)) (check (opt2 :or-else (option 0) :or-else (option 1)) => (option 0)) - (check-catch 'type-error (opt1 :or-else 0)) - ) + (check-catch 'type-error (opt1 :or-else 0))) + (check-true ((option "str") :equals (option "str"))) @@ -1098,8 +1098,8 @@ (check (lst :slice 1 4 :map (@ * _ 2) :collect) => '(4 6 8)) ;; 空切片 - (check (lst :slice 2 2 :collect) => '()) - ) + (check (lst :slice 2 2 :collect) => '())) + (check-true ($ (list) :empty?)) (check-false ($ '(1 2 3) :empty?)) @@ -1108,8 +1108,8 @@ (let1 lst ($ '(1 2 3 4 5)) (check (lst :forall (@ > _ 0)) => #t) - (check (lst :forall (@ > _ 3)) => #f) - ) + (check (lst :forall (@ > _ 3)) => #f)) + (check (rich-list :empty :forall (@ > _ 0)) => #t) @@ -1134,32 +1134,32 @@ (check (lst :take 0 :collect) => '()) (check (lst :take 3 :collect) => '(1 2 3)) (check (lst :take 5 :collect) => '(1 2 3 4 5)) - (check (lst :take 10 :collect) => '(1 2 3 4 5)) - ) + (check (lst :take 10 :collect) => '(1 2 3 4 5))) + (let ((lst (rich-list '(1 2 3 4 5)))) (check (lst :drop -1 :collect) => '(1 2 3 4 5)) (check (lst :drop 0 :collect) => '(1 2 3 4 5)) (check (lst :drop 3 :collect) => '(4 5)) (check (lst :drop 5 :collect) => '()) - (check (lst :drop 10 :collect) => '()) - ) + (check (lst :drop 10 :collect) => '())) + (let ((lst (rich-list '(1 2 3 4 5)))) (check (lst :take-right -1 :collect) => '()) (check (lst :take-right 0 :collect) => '()) (check (lst :take-right 3 :collect) => '(3 4 5)) (check (lst :take-right 5 :collect) => '(1 2 3 4 5)) - (check (lst :take-right 10 :collect) => '(1 2 3 4 5)) - ) + (check (lst :take-right 10 :collect) => '(1 2 3 4 5))) + (let ((lst (rich-list '(1 2 3 4 5)))) (check (lst :drop-right -1 :collect) => '(1 2 3 4 5)) (check (lst :drop-right 0 :collect) => '(1 2 3 4 5)) (check (lst :drop-right 3 :collect) => '(1 2)) (check (lst :drop-right 5 :collect) => '()) - (check (lst :drop-right 10 :collect) => '()) - ) + (check (lst :drop-right 10 :collect) => '())) + (check ((rich-list (list 1 2 3)) :count) => 3) (check ((rich-list (list 1 2 3)) :count (cut > <> 1)) => 2) @@ -1176,8 +1176,8 @@ (check (lst :fold '() (lambda (x acc) (cons x acc))) => '(5 4 3 2 1)) (check (lst :fold-right 0 +) => 15) - (check (lst :fold-right '() (lambda (x acc) (cons x acc))) => '(1 2 3 4 5)) - ) + (check (lst :fold-right '() (lambda (x acc) (cons x acc))) => '(1 2 3 4 5))) + (check ($ '(3 1 2 4 5) :sort-with (lambda (x y) (< x y))) @@ -1308,8 +1308,8 @@ (let ((xs ($ '(1 2 3 4 5)))) (check (xs :index-where even?) => 1) (check (xs :index-where (@ > _ 3)) => 3) - (check (xs :index-where (@ > _ 5)) => #f) - ) + (check (xs :index-where (@ > _ 5)) => #f)) + (check ($ '(1 2 3) :max-by identity) => 3) (check ($ '((1) (3) (2)) :max-by car) => '(3)) @@ -1341,8 +1341,8 @@ (check-catch 'wrong-number-of-args (l :make-string "[" ",")) (check-catch 'type-error (l :make-string 123 "," "]")) (check-catch 'type-error (l :make-string "[" 123 "]")) - (check-catch 'type-error (l :make-string "[" "," 123)) - ) + (check-catch 'type-error (l :make-string "[" "," 123))) + (check ($ (list "a" "b") :make-string) => "ab") (check ($ (list "a" "b") :make-string " ") => "a b") @@ -1365,7 +1365,7 @@ (check (array :range 1 6 2) => ($ (vector 1 3 5))) (check (array :range 5 1 -1) => ($ (vector 5 4 3 2))) -(check (array :range 5 1 1) => ($ (vector ))) +(check (array :range 5 1 1) => ($ (vector))) (check-catch 'value-error (array :range 1 5 0)) @@ -1485,48 +1485,48 @@ (check (vec :take 0 :collect) => #()) (check (vec :take 3 :collect) => #(1 2 3)) (check (vec :take 5 :collect) => #(1 2 3 4 5)) - (check (vec :take 10 :collect) => #(1 2 3 4 5)) - ) + (check (vec :take 10 :collect) => #(1 2 3 4 5))) + (let ((vec (array #(1 2 3 4 5)))) (check (vec :take-right -1 :collect) => #()) (check (vec :take-right 0 :collect) => #()) (check (vec :take-right 3 :collect) => #(3 4 5)) (check (vec :take-right 5 :collect) => #(1 2 3 4 5)) - (check (vec :take-right 10 :collect) => #(1 2 3 4 5)) - ) + (check (vec :take-right 10 :collect) => #(1 2 3 4 5))) + (let ((vec (array #(1 2 3 4 5)))) (check (vec :drop -1 :collect) => #(1 2 3 4 5)) (check (vec :drop 0 :collect) => #(1 2 3 4 5)) (check (vec :drop 3 :collect) => #(4 5)) (check (vec :drop 5 :collect) => #()) - (check (vec :drop 10 :collect) => #()) - ) + (check (vec :drop 10 :collect) => #())) + (let ((vec (array #(1 2 3 4 5)))) (check (vec :drop-right -1 :collect) => #(1 2 3 4 5)) (check (vec :drop-right 0 :collect) => #(1 2 3 4 5)) (check (vec :drop-right 3 :collect) => #(1 2)) (check (vec :drop-right 5 :collect) => #()) - (check (vec :drop-right 10 :collect) => #()) - ) + (check (vec :drop-right 10 :collect) => #())) + (let ((vec (array #(1 2 3 4 5))) (empty-vec ($ #()))) (check (vec :drop-while (@ < _ 3) :collect) => #(3 4 5)) (check (vec :drop-while (@ > _ 3) :collect) => #(1 2 3 4 5)) (check (vec :drop-while (@ < _ 3) :drop 1 :collect) => #(4 5)) (check (empty-vec :drop-while (@ < _ 3) :drop 1 :collect) => #()) - (check (vec :drop-while (@ < _ 100) :collect) => #()) - ) + (check (vec :drop-while (@ < _ 100) :collect) => #())) + (let ((vec (array #(1 2 3 4 5)))) (check (vec :fold 0 +) => 15) (check (vec :fold '() (lambda (x acc) (cons x acc))) => '(5 4 3 2 1)) (check (vec :fold-right 0 +) => 15) - (check (vec :fold-right '() (lambda (x acc) (cons x acc))) => '(1 2 3 4 5)) - ) + (check (vec :fold-right '() (lambda (x acc) (cons x acc))) => '(1 2 3 4 5))) + (check ($ #() :count) => 0) (check ($ #() :count (@ > _ 2)) => 0) @@ -1691,8 +1691,8 @@ (check-catch 'wrong-number-of-args (v :make-string "[" ",")) (check-catch 'type-error (v :make-string 123 "," "]")) (check-catch 'type-error (v :make-string "[" 123 "]")) - (check-catch 'type-error (v :make-string "[" "," 123)) - ) + (check-catch 'type-error (v :make-string "[" "," 123))) + (check ($ #("a" "b" "c") :make-string) => "abc") @@ -1757,24 +1757,24 @@ (check (ht :forall (lambda (k v) (symbol? k))) => #t) - (check (ht :forall (lambda (k v) (eq? k v))) => #f) - ) + (check (ht :forall (lambda (k v) (eq? k v))) => #f)) + (let1 ht-empty ($ (hash-table)) - (check (ht-empty :forall (lambda (k v) (string? v))) => #t) - ) + (check (ht-empty :forall (lambda (k v) (string? v))) => #t)) + (let1 ht-mixed ($ (hash-table 'id 10 'score 85 3.14 "pi")) (check (ht-mixed :forall (lambda (k v) (number? v))) => #f) - (check (ht-mixed :forall (lambda (k v) (and (integer? v) (even? v)))) => #f) - ) + (check (ht-mixed :forall (lambda (k v) (and (integer? v) (even? v)))) => #f)) + (let1 ht-fail ($ (hash-table 'valid 42 'invalid "string")) (check (ht-fail :forall (lambda (k v) (number? v))) => #f) (check (ht-fail :forall (lambda (k v) - (and (symbol? k) (number? v) (positive? v)))) => #f) - ) + (and (symbol? k) (number? v) (positive? v)))) => #f)) + ;; nested hash table test (let1 ht-nested ($ (hash-table @@ -1782,8 +1782,8 @@ 'b ($ (hash-table 'y 20)))) (check (ht-nested :forall (lambda (k sub-ht) - (sub-ht :forall (lambda (k v) (> v 9))))) => #t) - ) + (sub-ht :forall (lambda (k v) (> v 9))))) => #t)) + (let ((ht ($ (hash-table 'a 1 'b "2" 'c 3)))) (check (ht :exists (lambda (k v) (string? v))) => #t)) @@ -1811,8 +1811,8 @@ (sum 0)) (ht :for-each (lambda (k v) (set! sum (+ sum v)))) - (check sum => 100) - ) + (check sum => 100)) + ;; Empty hash table (let ((ht ($ (make-hash-table))) @@ -1821,8 +1821,8 @@ (ht :for-each (lambda (k v) (set! call-counter (+ call-counter 1)))) - (check call-counter => 0) - ) + (check call-counter => 0)) + ;; Nested hash tables (let* ((inner ($ (hash-table 'x 100 'y 200))) @@ -1837,8 +1837,8 @@ (set! total (+ total v)))) (set! total (+ total v))))) - (check total => 342) - ) + (check total => 342)) + (let1 ht ($ (hash-table 'a 1 'b 2 'c 3)) (let1 r (ht :filter (lambda (k v) (even? v)) :collect) diff --git a/tests/goldfish/liii/list-test.scm b/tests/goldfish/liii/list-test.scm index 59e0e6a469094eada8521823b25c0b9cb6617df7..c61770bda89d6a439d6210dbe3c2880437b1fc9f 100644 --- a/tests/goldfish/liii/list-test.scm +++ b/tests/goldfish/liii/list-test.scm @@ -362,7 +362,7 @@ proper list是指一个符合R7RS规范的传统列表结构,满足以下条 (check-false (proper-list? (circular-list 1 2 3))) ; 边界条件测试 -(check-true (proper-list? '(() ()) )) ; 嵌套列表 +(check-true (proper-list? '(() ()))) ; 嵌套列表 (check-true (proper-list? '(a))) ; 单元素列表 (check-false (proper-list? 1)) ; 非列表对象 (check-false (proper-list? 'hello)) ; 符号 @@ -1278,7 +1278,7 @@ wrong-type-arg 当任何参数不是列表类型时可能抛出 (check (reduce-right + 0 '()) => 0) (check (reduce-right cons () '(1 2 3 4)) - => '(1 2 3 . 4) ) + => '(1 2 3 . 4)) (check (reduce-right (lambda (x count) (if (symbol? x) (+ count 1) count)) @@ -1312,7 +1312,7 @@ wrong-type-arg 当任何参数不是列表类型时可能抛出 (let* ((proc (lambda (x) (list (list x) (list (* x 2))))) (input '(5)) - (expected '( (5) (10) ))) + (expected '( (5) (10)))) (check (append-map proc input) => expected)) #| @@ -1509,7 +1509,7 @@ wrong-type-arg 如果 clist 不是列表类型。 (check (delete #\a (list #\a #\b #\c) (lambda (x y) #f)) => (list #\a #\b #\c)) -(check (delete 1 (list )) => (list )) +(check (delete 1 (list )) => (list)) (check (catch 'wrong-type-arg @@ -1522,7 +1522,7 @@ wrong-type-arg 如果 clist 不是列表类型。 (check (delete-duplicates (list 1 2 3)) => (list 1 2 3)) (check (delete-duplicates (list 1 1 1)) => (list 1)) -(check (delete-duplicates (list )) => (list )) +(check (delete-duplicates (list )) => (list)) (check (delete-duplicates (list 1 1 2 3) (lambda (x y) #f)) => (list 1 1 2 3)) @@ -1562,8 +1562,8 @@ wrong-type-arg 如果 clist 不是列表类型。 (check-false (length=? 2 (list 1 2 3))) (check-false (length=? 4 (list 1 2 3))) -(check-true (length=? 0 (list ))) -(check-catch 'value-error (length=? -1 (list ))) +(check-true (length=? 0 (list))) +(check-catch 'value-error (length=? -1 (list))) (check-true (length>? '(1 2 3 4 5) 3)) (check-false (length>? '(1 2) 3)) diff --git a/tests/goldfish/liii/path-test.scm b/tests/goldfish/liii/path-test.scm index 30cac59a487cfd1b2a174195ad9430f586121408..769de323b715c9f231f81ecce95fc348767c777a 100644 --- a/tests/goldfish/liii/path-test.scm +++ b/tests/goldfish/liii/path-test.scm @@ -83,8 +83,8 @@ path : 文件路径(string类型) (check (path-dir? "/no_such_dir") => #f) (check (path-dir? "/not/a/real/path") => #f) ;; 相对路径测试 - (check-true (path-dir? (os-temp-dir))) - ) + (check-true (path-dir? (os-temp-dir)))) + (when (os-windows?) ;; 根目录测试 @@ -1868,15 +1868,15 @@ boolean (let ((original-size (string-length original-content))) ;; 更新时间戳 - (check-true (temp-file :touch)) + (check-true (temp-file :touch)) ;; 验证文件内容未改变 - (check (temp-file :read-text) => "initial content") - (check (string-length (temp-file :read-text)) => original-size) + (check (temp-file :read-text) => "initial content") + (check (string-length (temp-file :read-text)) => original-size) ;; 验证文件仍然存在 - (check-true (temp-file :exists?)) - (check-true (temp-file :file?)))) + (check-true (temp-file :exists?)) + (check-true (temp-file :file?)))) ;; 清理 (temp-file :unlink)) diff --git a/tests/goldfish/liii/range-test.scm b/tests/goldfish/liii/range-test.scm index 5f7b871a14cadb8aaada0b12e91f34ba6492606e..6b7092581a61a0b138c526b6731881a7e33ec1ec 100644 --- a/tests/goldfish/liii/range-test.scm +++ b/tests/goldfish/liii/range-test.scm @@ -41,20 +41,20 @@ (let1 r (range 0 10 1 #f) (check (r :filter even?) => ($ (list 0 2 4 6 8))) (check (r :filter (lambda (x) (> x 5))) => ($ (list 6 7 8 9))) - (check (r :filter (lambda (x) (< x 0))) => ($ (list )))) + (check (r :filter (lambda (x) (< x 0))) => ($ (list)))) (let1 r (range 5 1 -1 #t) (check (r :filter odd?) => ($ (list 5 3 1)))) (let1 r (range 5 1 1 #t) - (check (r :filter odd?) => ($ (list )))) + (check (r :filter odd?) => ($ (list)))) (let1 r (range -5 -1 1 #t) (check (r :filter odd?) => ($ (list -5 -3 -1)))) (let1 r (range 5 5 -1 #t) (check (r :filter odd?) => ($ (list 5))) - (check (r :filter even?) => ($ (list )))) + (check (r :filter even?) => ($ (list)))) (check-false ((range :inclusive 1 3) :contains 4)) (check-true ((range :inclusive 1 3) :contains 2)) diff --git a/tests/goldfish/scheme/list-test.scm b/tests/goldfish/scheme/list-test.scm index a0d8eb42679defbb4f2a3856d202724b539862e3..e70c743f104212209f979cb89c55cfb2254f2c15 100644 --- a/tests/goldfish/scheme/list-test.scm +++ b/tests/goldfish/scheme/list-test.scm @@ -100,7 +100,7 @@ boolean? (check-true (pair? '(()))) ; 空列表作为唯一元素 ;; 嵌套深度边界测试 -(check-true (pair? '((((a))))) ) ; 深度嵌套列表 +(check-true (pair? '((((a)))))) ; 深度嵌套列表 (check-true (pair? (cons 'a (cons 'b (cons 'c '()))))) ; 深层cons链 (check-true (pair? '(a b (c d (e))))) ; 中度嵌套绑定 @@ -219,7 +219,7 @@ wrong-type-arg (check (car '(3.14 2.71)) => 3.14) (check (car '(1/2 2/3)) => 1/2) (check (car '(1+2i 3+4i)) => 1+2i) -(check (car '(# ab #\newline)) => # ab) +(check (car '(# ab #\newline)) => # ab) ;; 嵌套结构和特殊边界值测试 (check (car '((a (b (c))))) => '(a (b (c)))) @@ -325,7 +325,7 @@ wrong-type-arg ;; 各种数据类型cdr边界测试 (check (cdr '(123 "text" symbol)) => '("text" symbol)) (check (cdr '(# -ewline # ab #\space)) => '(# ab #\space)) + ewline # ab #\space)) => '(# ab #\space)) (check (cdr '((a b) c d)) => '(c d)) (check (cdr '(#(1 2) #(3 4))) => '(#(3 4))) (check (cdr '(+ - * /)) => '(- * /)) @@ -569,7 +569,7 @@ wrong-number-of-args (check pair => '(first . new-tail)) ;; 将列表尾部替换为单个元素 - (set-cdr! (cdr (cdr lst)) '() ) + (set-cdr! (cdr (cdr lst)) '()) (check lst => '(a b c))) ;; 测试set-cdr!与cons结合构建动态结构 @@ -1747,18 +1747,18 @@ wrong-type-arg ;; 各种数据类型边界测试 (check (list-tail '(42 "text" #t 'symbol) 1) => '("text" #t 'symbol)) -(check (list-tail '(# # - # -) 0) => '(# # - # -)) -(check (list-tail '(# # - # -) 2) => '(# -)) -(check (list-tail '(# # - # -) 3) => '()) +(check (list-tail '(# # + #) + 0) => '(# # + #)) + +(check (list-tail '(# # + #) + 2) => '(#)) + +(check (list-tail '(# # + #) + 3) => '()) ;; 子列表包含嵌套结构测试 (check (list-tail '((a b) (c d) (e f)) 0) => '((a b) (c d) (e f))) @@ -2118,7 +2118,7 @@ out-of-range (check lst => '("" (x y z) "abc"))) ;; 数值和浮点数元素测试 -(let ((lst (list 1 2.5 3 4.0 ))) +(let ((lst (list 1 2.5 3 4.0))) (list-set! lst 2 99) (list-set! lst 3 100.0) (check lst => '(1 2.5 99 100.0))) diff --git a/tests/resources/200_14_block_comment_good.scm b/tests/resources/200_14_block_comment_good.scm index 94df0da379b7b7039c5421a970160939933f2ea6..1c66c018d8c8b5a498ce233e23798f83eaf27cd5 100644 --- a/tests/resources/200_14_block_comment_good.scm +++ b/tests/resources/200_14_block_comment_good.scm @@ -2,6 +2,6 @@ (define (test-block-comment-good) #| This is a multi-line block comment |# (display "Perfectly balanced") - (let ((x 42) #| unm(matched here |# x)) - ) ; properly closed + (let ((x 42) #| unm(matched here |# x))) + ; properly closed ;; good - the unmatched parentheses are inside comments, so file is balanced \ No newline at end of file diff --git a/tests/resources/200_14_hash_valid.scm b/tests/resources/200_14_hash_valid.scm index 618354809dfc5f86a80ef429102b3f4f3e80c90f..13b4b7d47b35ee592021d2969185ba752a8d18ea 100644 --- a/tests/resources/200_14_hash_valid.scm +++ b/tests/resources/200_14_hash_valid.scm @@ -1,10 +1,10 @@ ; Valid cases with #racket character literals (define result (list # - 1 # - 2)) + 1 # + 2)) (display #\() (display #\)) (define (test-char) #\( (let ((x 5)) (display #\) - x))) \ No newline at end of file + x))) \ No newline at end of file diff --git a/tests/resources/200_14_with_strings.scm b/tests/resources/200_14_with_strings.scm index e8e7e6e9516a91074873929ea250dd550feb1f8f..6359718bdd6c32929d6f5250bdfc4813ac38d983 100644 --- a/tests/resources/200_14_with_strings.scm +++ b/tests/resources/200_14_with_strings.scm @@ -1,14 +1,14 @@ ;; 包含字符串内容的测试,忽略括号 (define (greeting name) (display (string-append "Hello, " name "!") - (newline)) + (newline)) -(let ((str "This string has (parens) in it ()()()")) - (display str) - (newline)) + (let ((str "This string has (parens) in it ()()()")) + (display str) + (newline)) -(define (test) - (display "Unmatched parens in strings should be ignored: () (")) - (newline)) + (define (test) + (display "Unmatched parens in strings should be ignored: () (")) + (newline)) (define x "mixed (content (like) this)") \ No newline at end of file