(import srfi-105 test) (test-begin "srfi-105") (test-group "srfi-105 document examples" (test '(<= n 5) (expand '{n <= 5})) (test '(+ x 1) (expand '{x + 1})) (test '(+ a b c) (expand '{a + b + c})) (test '(,op x y z) (expand '{x ,op y ,op z})) (test '(eqv? x `a) (expand '{x eqv? `a})) (test '(eq? 'a b) (expand '{'a eq? b})) (test '(+ n-1 n-2) (expand '{n-1 + n-2})) (test '(* a (+ b c)) (expand '{a * {b + c}})) (test '(+ a (- b c)) (expand '{a + {b - c}})) (test '(- (+ a b) c) (expand '{{a + b} - c})) ;; ;; This one's close enough ;; (test (expand '{{a > 0} and {b >= 1}}) '(and (> a 0) (>= b 1))) (test '() (expand '{})) (test '5 (expand '{5})) (test '(- x) (expand '{- x})) (test '(>= (length x) 6) (expand '{length(x) >= 6})) (test '(+ (f x) (g y) (h z)) (expand '{f(x) + g(y) + h(z)})) (test '(+ (f a b) (g h)) (expand '{(f a b) + (g h)})) (test '(+ (f a b) (g h)) (expand '{f(a b) + g(h)})) (test '(+ a (f b) x) (expand '{a + f(b) + x})) (test '(/ (- a) b) (expand '{(- a) / b})) (test '(/ (- a) b) (expand '{-(a) / b})) (test '(cos q) (expand '{cos(q)})) (test '(e) (expand '{e{}})) (test '(e) (expand '{e{ }})) (test '(pi) (expand '{pi()})) (test '(f x) (expand {'f(x)})) ;; ;; No support for this in chicken ;; (test (expand '{#1=f(#1#)}) '#1=(f #1#)) (test '(f (g (h x))) (expand '{ (f (g h(x))) })) (test '#(1 2 (f a) 4) (expand '{#(1 2 f(a) 4)})) (test '(f (h x)) (expand '{(f #;g(x) h(x))})) (test '(map - ns) (expand '{(map - ns)})) (test '(map - ns) (expand '{map(- ns)})) (test '(* n (factorial (- n 1))) (expand '{n * factorial{n - 1}})) (test '(* 2 (sin (- x))) (expand '{2 * sin{- x}})) (test '($nfx$ 3 + 4 +) (expand '{3 + 4 +})) (test '($nfx$ 3 + 4 + 5 +) (expand '{3 + 4 + 5 +})) ;; ;; Not supported in chicken scheme ;; (test (expand '{a . z}) '($nfx$ a . z)) (test (expand '{a + b - c}) '($nfx$ a + b - c)) ;; ;; Not supported in chicken scheme ;; (test (expand '{read(. options)}) '(read . options)) (test '((a x) y) (expand '{a(x)(y)})) (test '($bracket-apply$ x a) (expand '{x[a]})) (test '($bracket-apply$ y a b) (expand '{y[a b]})) (test '((f (- n 1)) x) (expand '{f{n - 1}(x)})) (test '((f (- n 1)) (- y 1)) (expand '{f{n - 1}{y - 1}})) (test '($bracket-apply$ (f (- x)) y) (expand '{f{- x}[y]}))) (test-end "srfi-105")