From f7a994e0e0a9d06b7e656383d340de110775b35e Mon Sep 17 00:00:00 2001 From: Piers Cawley Date: Sat, 16 May 2020 17:42:23 +0100 Subject: [PATCH 1/7] Add an xtmtest-with-fixture test and exercise it Adds an xtmtest-with-fixture macro that sets up a fixture and then runs its body in the fixture's environment. There's a bunch of stuff introducing conveniently named macros within the body, which got added as I was debugging and getting the basic macro to work and it's a tad tricky to unpick this and present it as a series of patches adding small pieces of behaviour every time. Sorry. --- libs/core/test.xtm | 52 +++++++++++++++++++++++++++++++++++---------- tests/all-core.xtm | 2 +- tests/core/test.xtm | 23 ++++++++++++++++++++ 3 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 tests/core/test.xtm diff --git a/libs/core/test.xtm b/libs/core/test.xtm index 3ef7e1c48..87dd7a337 100644 --- a/libs/core/test.xtm +++ b/libs/core/test.xtm @@ -99,17 +99,22 @@ (eval ,form (interaction-environment)) (xtmtest-update-test-result func-sym 'correct 'compile-only #t #t)))) -(define-macro (xtmtest-result call expected-result) - `(let ((evaluation-environment (current-environment)) - (func-sym (quote ,(car call)))) - (print-with-colors 'cyan 'default #t (print "xtmtest ")) - (print-with-colors 'black 'cyan #t (print "" func-sym "")) - (println) - (catch (xtmtest-update-test-result func-sym ',call 'compile #f #f) - (let ((result (eval ',call evaluation-environment))) - (if (equal? ,expected-result result) - (xtmtest-update-test-result func-sym 'correct ',call ,expected-result result) - (xtmtest-update-test-result func-sym 'incorrect ',call ,expected-result result)))))) +(define (xtmtest-result-body call expected-result extra) + (let ((prefix (if (null? extra) "" (format "~a: " (car extra))))) + `(let ((evaluation-environment (current-environment)) + (test-name (format "~a ~a" ,prefix ',(if (pair? call) (car call) call)))) + (print-with-colors 'cyan 'default #t (print "xtmtest ")) + (print-with-colors 'black 'cyan #t (print "" test-name )) + (println) + (catch (xtmtest-update-test-result test-name ',call 'compile #f #f) + (let ((result (eval ',call evaluation-environment))) + (if (equal? ,expected-result result) + (xtmtest-update-test-result ',prefix 'correct ',call ,expected-result result) + (xtmtest-update-test-result ',prefix 'incorrect ',call ,expected-result result)))))) ) + +(define-macro (xtmtest-result call expected-result . extra) + (xtmtest-result-body call expected-result extra)) + (define xtmtest-print-results (lambda () @@ -179,3 +184,28 @@ 0))) ;; if not quitting, set the timeout back (sys:set-default-timeout timeout))))) + +;;; xmttest-with-fixture + +(define (xtmtest-with-fixture-body name fixture tests) + `(let ((fixture-environment ((lambda () (current-environment))))) + (let ((suite-name ',name)) + (print-with-colors 'cyan 'default #t (print "xtmtest ")) + (print-with-colors 'black 'cyan #t (print "" suite-name)) + (println) + (eval `(begin + (define-macro (is? call expected-result . args) + (xtmtest-result-body call + expected-result + (list (if (not (null? args)) + (format "~a.~a" ',suite-name (car args)) + (format "~a.is?" ',suite-name)))))) + fixture-environment) + (catch (xtmtest-update-test-result suite-name 'no-compile ',fixture #f #f) + (eval ',fixture fixture-environment) + (eval '(begin ,@tests) fixture-environment))))) + + +(define-macro (xtmtest-with-fixture name fixture . tests) + (xtmtest-with-fixture-body name fixture tests)) + diff --git a/tests/all-core.xtm b/tests/all-core.xtm index 65813c0d4..c5a2f5ed7 100644 --- a/tests/all-core.xtm +++ b/tests/all-core.xtm @@ -10,6 +10,6 @@ ;;; Code: -(xtmtest-run-tests (append '("tests/core/system.xtm" "tests/core/adt.xtm" "tests/core/math.xtm" "tests/core/std.xtm" "tests/core/xtlang.xtm" "tests/core/constraints.xtm" "tests/core/expr_problem.xtm" "tests/core/algebraic_data_types.xtm") +(xtmtest-run-tests (append '("tests/core/system.xtm" "tests/core/test.xtm" "tests/core/adt.xtm" "tests/core/math.xtm" "tests/core/std.xtm" "tests/core/xtlang.xtm" "tests/core/constraints.xtm" "tests/core/expr_problem.xtm" "tests/core/algebraic_data_types.xtm") (unix-or-Windows '("tests/core/generics.xtm") '())) #t #t) diff --git a/tests/core/test.xtm b/tests/core/test.xtm new file mode 100644 index 000000000..3f790c89b --- /dev/null +++ b/tests/core/test.xtm @@ -0,0 +1,23 @@ +;;; tests/test.txt -- test the test library + + +(xtmtest-with-fixture base + (begin + (define target 'outer) + (define-macro (target-macro) ''outer)) + + (xtmtest-with-fixture cleanliness + (define target 'inner) + + (is? (eq? target 'inner) #t) + (is? target 'inner)) + + (is? (eq? target 'outer) #t) + (xtmtest-with-fixture macrocheck + (define-macro (target-macro) ''inner) + (is? (target-macro) 'inner)) + + (is? (target-macro) 'outer)) + + + From ae931ed3283df0a5338bfdc3fff45ae71b6be121 Mon Sep 17 00:00:00 2001 From: Piers Cawley Date: Sat, 16 May 2020 18:03:13 +0100 Subject: [PATCH 2/7] Fail a sanity check I thought, I'll fix the double eval in xtmtest and xtmtest-compile by checking if the `form` argument is quoted, stripping the quote, and then doing `(eval ',form (interaction-environment))` in the body of the test. By my understanding of the way lisps work, this should not change behaviour in any way. Hah! Tests are now failing. What on _earth_ am I doing wrong? squash! Fail a sanity check --- libs/core/test.xtm | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/libs/core/test.xtm b/libs/core/test.xtm index 87dd7a337..3a0f98842 100644 --- a/libs/core/test.xtm +++ b/libs/core/test.xtm @@ -72,23 +72,27 @@ ;; some tests are supposed to fail compilation (type check catch for example) ;; by passing 'copmile-should-fail as expected-result the failure will be marked as success (define-macro (xtmtest form call . expected-result) - `(let ((func-sym (quote ,(car call))) - (exp-res ,(if (null? expected-result) - #f - (car expected-result)))) - (print-with-colors 'cyan 'default #t (print "xtmtest ")) - (print-with-colors 'black 'cyan #t (print "" func-sym "")) - (println) - (catch (if (and (symbol? exp-res) - (equal? exp-res 'compile-should-fail)) - (xtmtest-update-test-result func-sym 'correct ',call #f #f) - (xtmtest-update-test-result func-sym 'no-compile ',call #f #f)) - (eval ,form (interaction-environment)) - (catch (xtmtest-update-test-result func-sym 'compile ',call #f #f) - (let ((result (eval ,call (interaction-environment)))) - (if (or (not exp-res) (equal? exp-res result)) - (xtmtest-update-test-result func-sym 'correct ',call exp-res result) - (xtmtest-update-test-result func-sym 'incorrect ',call exp-res result))))))) + (let ((form (if (and (pair? form) + (eq? 'quote (car form))) + (cdr form) + form))) + `(let ((func-sym (quote ,(car call))) + (exp-res ,(if (null? expected-result) + #f + (car expected-result)))) + (print-with-colors 'cyan 'default #t (print "xtmtest ")) + (print-with-colors 'black 'cyan #t (print "" func-sym "")) + (println) + (catch (if (and (symbol? exp-res) + (equal? exp-res 'compile-should-fail)) + (xtmtest-update-test-result func-sym 'correct ',call #f #f) + (xtmtest-update-test-result func-sym 'no-compile ',call #f #f)) + (eval ',form (interaction-environment)) + (catch (xtmtest-update-test-result func-sym 'compile ',call #f #f) + (let ((result (eval ,call (interaction-environment)))) + (if (or (not exp-res) (equal? exp-res result)) + (xtmtest-update-test-result func-sym 'correct ',call exp-res result) + (xtmtest-update-test-result func-sym 'incorrect ',call exp-res result)))))))) (define-macro (xtmtest-compile form) `(let ((func-sym (quote ,(cadadr form)))) From 478fd6475c6b7c334f7de4f9a14e27155a000933 Mon Sep 17 00:00:00 2001 From: Piers Cawley Date: Sun, 17 May 2020 11:31:00 +0100 Subject: [PATCH 3/7] squash! Fail a sanity check --- libs/core/test.xtm | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libs/core/test.xtm b/libs/core/test.xtm index 3a0f98842..9ef5b2da1 100644 --- a/libs/core/test.xtm +++ b/libs/core/test.xtm @@ -74,7 +74,7 @@ (define-macro (xtmtest form call . expected-result) (let ((form (if (and (pair? form) (eq? 'quote (car form))) - (cdr form) + (eval form (interaction-environment)) form))) `(let ((func-sym (quote ,(car call))) (exp-res ,(if (null? expected-result) @@ -95,13 +95,18 @@ (xtmtest-update-test-result func-sym 'incorrect ',call exp-res result)))))))) (define-macro (xtmtest-compile form) - `(let ((func-sym (quote ,(cadadr form)))) - (print-with-colors 'cyan 'default #t (print "xtmtest ")) - (print-with-colors 'black 'cyan #t (print "" func-sym "")) - (println) - (catch (xtmtest-update-test-result func-sym 'no-compile 'compile-only #f #f) - (eval ,form (interaction-environment)) - (xtmtest-update-test-result func-sym 'correct 'compile-only #t #t)))) + ;; If we're quoted force unquote + (let ((form (if (and (pair? form) + (eq? 'quote (car form))) + (eval form (interaction-environment)) + form))) + `(let ((func-sym (quote ,(cadar form)))) + (print-with-colors 'cyan 'default #t (print "xtmtest ")) + (print-with-colors 'black 'cyan #t (print "" func-sym "")) + (println) + (catch (xtmtest-update-test-result func-sym 'no-compile 'compile-only #f #f) + (eval ',form (interaction-environment)) + (xtmtest-update-test-result func-sym 'correct 'compile-only #t #t))))) (define (xtmtest-result-body call expected-result extra) (let ((prefix (if (null? extra) "" (format "~a: " (car extra))))) From e8290a466e6a8aa7db69d2cdf0d7fb5071009b88 Mon Sep 17 00:00:00 2001 From: Piers Cawley Date: Sun, 17 May 2020 14:30:17 +0100 Subject: [PATCH 4/7] Passing my sanity check now! --- libs/core/test.xtm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/core/test.xtm b/libs/core/test.xtm index 9ef5b2da1..714896d46 100644 --- a/libs/core/test.xtm +++ b/libs/core/test.xtm @@ -100,7 +100,7 @@ (eq? 'quote (car form))) (eval form (interaction-environment)) form))) - `(let ((func-sym (quote ,(cadar form)))) + `(let ((func-sym (quote ,(cadr form)))) (print-with-colors 'cyan 'default #t (print "xtmtest ")) (print-with-colors 'black 'cyan #t (print "" func-sym "")) (println) From 0d97dddda918942fbe11262f31959e7dc763bc99 Mon Sep 17 00:00:00 2001 From: Piers Cawley Date: Sun, 17 May 2020 14:40:01 +0100 Subject: [PATCH 5/7] Remove last double evaluation from xtmtest We're still doing a double eval, but that's only until we fix the tests. --- libs/core/test.xtm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/core/test.xtm b/libs/core/test.xtm index 714896d46..4b32d5087 100644 --- a/libs/core/test.xtm +++ b/libs/core/test.xtm @@ -89,7 +89,7 @@ (xtmtest-update-test-result func-sym 'no-compile ',call #f #f)) (eval ',form (interaction-environment)) (catch (xtmtest-update-test-result func-sym 'compile ',call #f #f) - (let ((result (eval ,call (interaction-environment)))) + (let ((result (eval ',call (interaction-environment)))) (if (or (not exp-res) (equal? exp-res result)) (xtmtest-update-test-result func-sym 'correct ',call exp-res result) (xtmtest-update-test-result func-sym 'incorrect ',call exp-res result)))))))) From 25e31c4dcb53e4c67e8f8108a20b89b9afe7c9f8 Mon Sep 17 00:00:00 2001 From: Piers Cawley Date: Sun, 17 May 2020 14:52:47 +0100 Subject: [PATCH 6/7] Eliminate the unnecessary quoting of xtmtest-* forms Since we've removed the double eval from xtmtest and xtmtest-compile, we can now fix all the tests to stop quoting their 'form' arguments. 'tests/all-core.xtm' is still passing. --- tests/core/adt.xtm | 188 ++++++++-------- tests/core/algebraic_data_types.xtm | 18 +- tests/core/aot-compilation.xtm | 6 +- tests/core/builtins.xtm | 322 ++++++++++++++-------------- tests/core/constraints.xtm | 22 +- tests/core/expr_problem.xtm | 6 +- tests/core/generics.xtm | 14 +- tests/core/math.xtm | 60 +++--- tests/core/pcg-rng.xtm | 6 +- tests/core/std.xtm | 4 +- tests/core/xtlang.xtm | 176 +++++++-------- tests/external/fft.xtm | 4 +- tests/external/system.xtm | 16 +- 13 files changed, 421 insertions(+), 421 deletions(-) diff --git a/tests/core/adt.xtm b/tests/core/adt.xtm index ace1ba39e..2b8c3243e 100644 --- a/tests/core/adt.xtm +++ b/tests/core/adt.xtm @@ -21,7 +21,7 @@ ;; (xtmtest-compile - '(bind-func print:[void,Point*]* + (bind-func print:[void,Point*]* (lambda (p) (if (null? p) (begin (printout "<>") void) @@ -32,20 +32,20 @@ ;; make and return a Point (xtmtest-compile - '(bind-func test_generic_point_1 + (bind-func test_generic_point_1 "Test doc-string" (lambda () (let ((x (Point 1.0 2.0))) x)))) (xtmtest-compile - '(bind-func test_generic_point_2 + (bind-func test_generic_point_2 (lambda () (let ((x (Point 1 2))) x)))) ;; print the point -(xtmtest '(bind-func test_generic_point_3 +(xtmtest (bind-func test_generic_point_3 (lambda () (let ((x (test_generic_point_1)) (y (test_generic_point_2))) @@ -55,16 +55,16 @@ ;; Generic Size {width,height} -(xtmtest-compile '(bind-type Size )) +(xtmtest-compile (bind-type Size )) ;; points and size must be the same primitive type! -(xtmtest-compile '(bind-type Rectangle )) +(xtmtest-compile (bind-type Rectangle )) ;; this basically the same as Rectangle -(xtmtest-compile '(bind-type RectangleA )) +(xtmtest-compile (bind-type RectangleA )) ;; this allows *different* point and size primitives -(xtmtest-compile '(bind-type RectangleB )) +(xtmtest-compile (bind-type RectangleB )) ;; print routines for everything! -(xtmtest-compile '(bind-func print:[void,Size*]* +(xtmtest-compile (bind-func print:[void,Size*]* (lambda (p) (if (null? p) (begin (printout "<>") void) @@ -74,7 +74,7 @@ void))))) (xtmtest-compile - '(bind-func print:[void,Rectangle*]* + (bind-func print:[void,Rectangle*]* (lambda (p) (if (null? p) (begin (printout "<>") void) @@ -84,7 +84,7 @@ void))))) (xtmtest-compile - '(bind-func print:[void,RectangleA*]* + (bind-func print:[void,RectangleA*]* (lambda (p) (if (null? p) (begin (printout "<>") void) @@ -94,7 +94,7 @@ void))))) (xtmtest-compile - '(bind-func print:[void,RectangleB*]* + (bind-func print:[void,RectangleB*]* (lambda (p) (if (null? p) (begin (printout "<>") void) @@ -105,14 +105,14 @@ ;; make some rectangles (xtmtest-compile - '(bind-func test_rectangle_1 + (bind-func test_rectangle_1 (lambda () (let ((a (Rectangle (Point 1:i64 2:i64) (Size 3:i64 4:i64))) (b (RectangleA (Point 5:i64 6:i64) (Size 7:i64 8:i64))) (c (RectangleB (Point 9.0:double 10.0:double) (Size 11:i64 12:i64)))) c)))) -(xtmtest '(bind-func test_rectangle_2 +(xtmtest (bind-func test_rectangle_2 (lambda () (let ((a (Rectangle (Point 1 2) (Size 3 4))) (b (RectangleA (Point 5 6) (Size 7 8))) @@ -129,22 +129,22 @@ ;; (xtmtest-compile - '(bind-type Tree )) + (bind-type Tree )) (xtmtest-compile - '(bind-func Leaf:[Tree:*,!a]* + (bind-func Leaf:[Tree:*,!a]* "Make A Leaf" (lambda (x) (let ((t (Tree x null null))) t)))) (xtmtest-compile - '(bind-func tree_value:[!a,Tree*]* + (bind-func tree_value:[!a,Tree*]* (lambda (t) (tref t 0)))) (xtmtest-compile - '(bind-func print:[void,Tree*]* + (bind-func print:[void,Tree*]* (lambda (t) (let ((f (lambda (t) (if (null? t) void @@ -157,7 +157,7 @@ (println))))) -(xtmtest '(bind-func tree_test +(xtmtest (bind-func tree_test (lambda () (let ((t1 (Leaf 3)) (t2 (Leaf 4)) @@ -180,21 +180,21 @@ ;; (xtmtest-compile - '(bind-func polygen:[!a,!a]* + (bind-func polygen:[!a,!a]* (lambda (x) (* 1 x)))) (xtmtest-compile - '(bind-func polygen:[!a,!a,!a]* + (bind-func polygen:[!a,!a,!a]* (lambda (x y) (* 1 x y)))) (xtmtest-compile - '(bind-func polygen:[!a,!a,!a,!a]* + (bind-func polygen:[!a,!a,!a,!a]* (lambda (x y z) (* 1 x y z)))) -(xtmtest '(bind-func arity_test +(xtmtest (bind-func arity_test (lambda (x:i32 y:i32 z:i32) (let ((a (polygen x)) (b (polygen x y)) @@ -209,7 +209,7 @@ ;; list tests ;; -(xtmtest '(bind-func test_list_1 +(xtmtest (bind-func test_list_1 (lambda () (let ((l (list 1 2 3 4 5))) (println l) @@ -217,7 +217,7 @@ (test_list_1) 2) -(xtmtest '(bind-func test_list_2 +(xtmtest (bind-func test_list_2 (lambda () (let ((l (list 1 2 3 4 5)) (l2 (map (lambda (x) (* x x)) l))) @@ -225,7 +225,7 @@ (test_list_2)) -(xtmtest '(bind-func test_list_3 +(xtmtest (bind-func test_list_3 (lambda () (let ((l (list 1.0 2.0 3.0 4.0)) (f (lambda (x) (* x x))) @@ -234,7 +234,7 @@ (test_list_3)) -(xtmtest '(bind-func test_set_car +(xtmtest (bind-func test_set_car (lambda () (let ((lst (list 1 2 3))) (set_car (nth_tail lst 1) 5) @@ -243,7 +243,7 @@ (test_set_car) 1) -(xtmtest '(bind-func test_set_cdr +(xtmtest (bind-func test_set_cdr (lambda () (let ((lst1 (list 1 2 3)) (lst2 (list 4 5 6))) @@ -253,21 +253,21 @@ (test_set_cdr) 1) -(xtmtest '(bind-func test_list_4 +(xtmtest (bind-func test_list_4 (lambda () (let ((l1 (list 1 2 3 4)) (l2 (list 1.0 2.0 3.0 4.0))) (map (lambda (a b) (Pair a b)) l1 l2)))) (test_list_4)) -(xtmtest '(bind-func test_list_5 +(xtmtest (bind-func test_list_5 (lambda () (let ((l (test_list_4))) (for-each (lambda (x) (println x)) l)))) (test_list_5)) -(xtmtest '(bind-func test_list_foreach +(xtmtest (bind-func test_list_foreach (lambda () (let ((l (test_list_4))) (for-each (lambda (a b) @@ -283,7 +283,7 @@ (test_list_foreach)) (xtmtest - '(bind-func test_list_flatten + (bind-func test_list_flatten (lambda () (let ((l1 (list 1 2 3)) (l2 (list 4 5 6)) @@ -294,7 +294,7 @@ ;; spec'd funcs (xtmtest - '(bind-func test_map_pair + (bind-func test_map_pair (lambda (l1 l2) (map Pair:$[i64,double]* l1 l2))) (test_map_pair)) @@ -304,7 +304,7 @@ ;; lists of lists (xtmtest - '(bind-func test_list_6 + (bind-func test_list_6 (lambda () (let ((l1 (list 1 2 3)) (l2 (list l1 l1 l1))) @@ -312,7 +312,7 @@ (test_list_6)) (xtmtest - '(bind-func test_list_7 + (bind-func test_list_7 (lambda () (let ((l1 (list 1 2 3)) (l2 (list l1 l1)) @@ -339,7 +339,7 @@ ;; test some list functions ;; -(xtmtest '(bind-func test_append_insert_length +(xtmtest (bind-func test_append_insert_length (lambda () (let ((v1 (list 1 2 3 4)) (v2 (list 5 6 7 8)) @@ -351,7 +351,7 @@ (test_append_insert_length) 9) -(xtmtest '(bind-func test_list_membership +(xtmtest (bind-func test_list_membership (lambda (x) (let ((lst (list 1 2 3)) (result (member x lst))) @@ -365,14 +365,14 @@ (xtmtest-result (test_list_membership 4) 0) (xtmtest - '(bind-func test_eveni64 + (bind-func test_eveni64 (lambda (x) (if (= (bitwise-and x 1) 0) #t #f))) (test_eveni64 4) 1) (xtmtest-result (test_eveni64 45) 0) -(xtmtest '(bind-func test_list_any_1 +(xtmtest (bind-func test_list_any_1 (lambda () (let ((l1 (list 1 2 3 4)) (l2 (list 1 3))) @@ -381,7 +381,7 @@ (test_list_any_1) 1) -(xtmtest '(bind-func test_list_any_2 +(xtmtest (bind-func test_list_any_2 (lambda (x:i64) (let ((l1 (range 3)) (l2 (list x x x)) @@ -392,7 +392,7 @@ (xtmtest-result (test_list_any_2 -1) 0) -(xtmtest '(bind-func test_list_every_22 +(xtmtest (bind-func test_list_every_22 (lambda (x:i64) (let ((l1 (range 3)) (l2 (list x x x))) @@ -403,7 +403,7 @@ (xtmtest-result (test_list_every_22 1) 0) -(xtmtest '(bind-func test_list_swap +(xtmtest (bind-func test_list_swap (lambda () (let ((lst (list 1 2 3 4 5))) (swap lst 1 3) @@ -412,7 +412,7 @@ (test_list_swap) 1) -(xtmtest '(bind-func test_list_reverse_1 +(xtmtest (bind-func test_list_reverse_1 (lambda () (let ((lst (list 1 2 3 4 5 6)) (len (length lst))) @@ -424,7 +424,7 @@ (test_list_reverse_1) 1) ;; test filter and map arity 2 -(xtmtest '(bind-func test_list_filter +(xtmtest (bind-func test_list_filter (lambda () (let ((l1 (list (Point 1.0 2.0) (Point 3.0 4.0))) (l2 (list (Size 1.0 1.0) (Size 2.0 2.0))) @@ -440,7 +440,7 @@ (test_list_filter)) -(xtmtest '(bind-func test_list_range_1 +(xtmtest (bind-func test_list_range_1 (lambda () (let ((res1 (range 3 8)) (res2 (range 1 10 3))) @@ -451,7 +451,7 @@ (test_list_range_1) 1) -(xtmtest '(bind-func test_list_range_2 +(xtmtest (bind-func test_list_range_2 (lambda () (let ((list1 (range 3. 14. 2.5)) (list2 (range 16.)) @@ -466,7 +466,7 @@ ;; foldl/foldr -(xtmtest '(bind-func test_foldl_1 +(xtmtest (bind-func test_foldl_1 (lambda () (let ((plus (lambda (a b) (+ a b))) (lst (list 1 2 3 4))) @@ -474,7 +474,7 @@ (test_foldl_1) 10) -(xtmtest '(bind-func test_foldl_2 +(xtmtest (bind-func test_foldl_2 (lambda () (let ((lst (range 10. 30.))) (foldl (lambda (a b) @@ -486,7 +486,7 @@ (test_foldl_2) 57) -(xtmtest '(bind-func test_foldr_1 +(xtmtest (bind-func test_foldr_1 (lambda () (let ((lst (range 10.)) (fn (lambda (lower:double upper) (random lower upper))) @@ -495,7 +495,7 @@ (test_foldr_1)) -(xtmtest '(bind-func test_foldr_2 +(xtmtest (bind-func test_foldr_2 (lambda () (let ((lst (range 10)) (fn (lambda (a:i64 b) (cons a b))) @@ -519,7 +519,7 @@ (Pair (String "Ben") 30)))) dict))) -(xtmtest '(bind-func test_assoc_2 +(xtmtest (bind-func test_assoc_2 (lambda () (let ((dict (test_assoc_1))) (println dict) @@ -534,7 +534,7 @@ ;; ;; BTree -(xtmtest '(bind-func btree_test_1 +(xtmtest (bind-func btree_test_1 (lambda () (let ((t1 (BTree_leaf 3)) (t2 (BTree_leaf 4)) @@ -552,7 +552,7 @@ ;; (xtmtest-compile - '(bind-type Maybe )) + (bind-type Maybe )) ;; Maybe's data constructor IS unit/return ;; @@ -560,7 +560,7 @@ ;; arg, so it has type [Maybe*,!a]* ;; so we can override on arity as below (xtmtest-compile - '(bind-func Maybe:[Maybe:*,!a]* + (bind-func Maybe:[Maybe:*,!a]* (lambda (x) (let ((m (alloc))) (tset! m 0 #t) @@ -568,7 +568,7 @@ m)))) (xtmtest-compile - '(bind-func bind:[Maybe:*,Maybe:*,[Maybe:*,!a]*]* + (bind-func bind:[Maybe:*,Maybe:*,[Maybe:*,!a]*]* (lambda (m f) (if (tref m 0) (f (tref m 1)) ;; true Maybe @@ -592,7 +592,7 @@ ;; maybe multiply (xtmtest-compile - '(bind-func maybe_mul:[Maybe*,Maybe*,Maybe*]* + (bind-func maybe_mul:[Maybe*,Maybe*,Maybe*]* (lambda (a b) (bind a (lambda (x) @@ -619,7 +619,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" ;; which makes maybe_mul considerably more readable (xtmtest-compile - '(bind-func maybe_mul:[Maybe*,Maybe*,Maybe*]* + (bind-func maybe_mul:[Maybe*,Maybe*,Maybe*]* (lambda (a b) (mlet ((x a) (y b)) @@ -631,14 +631,14 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (Maybe #t z))))))) (xtmtest-compile - '(bind-func maybe_print_i64 + (bind-func maybe_print_i64 (lambda (x:i64) (let ((w (printf "%lld\n" x))) (if (>= w 0) (Maybe #t x) (Maybe #f x)))))) -(xtmtest '(bind-func maybe_test +(xtmtest (bind-func maybe_test (lambda (w:i64) (let ((x (Maybe w)) (y (Maybe 5)) @@ -666,12 +666,12 @@ but we'll use a let style form mlet for monadic-let---bad name :(" ;; type expansion ;; -(xtmtest-compile '(bind-type TypeA )) -(xtmtest-compile '(bind-type TypeB )) -(xtmtest-compile '(bind-type TypeC )) -(xtmtest-compile '(bind-type TypeD )) +(xtmtest-compile (bind-type TypeA )) +(xtmtest-compile (bind-type TypeB )) +(xtmtest-compile (bind-type TypeC )) +(xtmtest-compile (bind-type TypeD )) -(xtmtest '(bind-func test_exp2 +(xtmtest (bind-func test_exp2 (lambda () (let ((a:TypeA{i64}* (alloc)) (b:TypeB{i64}* (alloc)) @@ -682,12 +682,12 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (test_exp2)) (xtmtest-compile - '(bind-func gen_exp:[!a,[!a,!b]*,!b]* + (bind-func gen_exp:[!a,[!a,!b]*,!b]* (lambda (f x) (f x)))) (xtmtest-compile - '(bind-func test_gen_e + (bind-func test_gen_e (lambda () (let ((f (lambda (x) (i64tod x)))) (gen_exp:$[double,i64]* f 2))))) @@ -698,7 +698,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" ;; lst))) (xtmtest-compile - '(bind-func gen_exp:[!a,!a,!a,!a]* + (bind-func gen_exp:[!a,!a,!a,!a]* (lambda (x y z) (* x y z)))) @@ -713,22 +713,22 @@ but we'll use a let style form mlet for monadic-let---bad name :(" ;; generic overloading ;; (xtmtest-compile - '(bind-func gen_sqr:[!a,!a]* + (bind-func gen_sqr:[!a,!a]* (lambda (x) (* x x)))) (xtmtest-compile - '(bind-func gen_sqr:[Pair*,Pair*]* + (bind-func gen_sqr:[Pair*,Pair*]* (lambda (x) (Pair (* (first x) (first x)) (* (second x) (second x)))))) (xtmtest-compile - '(bind-func gen_sqr:[List*,List*]* + (bind-func gen_sqr:[List*,List*]* (lambda (lst) (map (lambda (x) (gen_sqr x)) lst)))) -(xtmtest '(bind-func gen_sqr_test +(xtmtest (bind-func gen_sqr_test (lambda () (println (gen_sqr 2) (gen_sqr 3.0) @@ -738,7 +738,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (gen_sqr_test)) -(xtmtest '(bind-func test_point_1 +(xtmtest (bind-func test_point_1 (lambda () (let ((pt (Point 9 4))) (+ (first pt) @@ -746,7 +746,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (test_point_1) 13) -(xtmtest '(bind-func test_point_2 +(xtmtest (bind-func test_point_2 (lambda () (let ((pt1 (Point 9 4)) (pt2 (Point .3 .6))) @@ -758,7 +758,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (test_point_2) 13.9) ;; this currently hangs during compilation -;; (xtmtest '(bind-func test_list_ptr +;; (xtmtest (bind-func test_list_ptr ;; (lambda () ;; (let ((lst_ptr:List** (alloc 2))) ;; (pset! lst_ptr 0 (list 1 2 3)) @@ -767,7 +767,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" ;; (test_list_ptr) 5) -(xtmtest '(bind-func test_list_ptr_2 +(xtmtest (bind-func test_list_ptr_2 (lambda () (letz ((lst_ptr:List{i64}** (alloc 2))) (pset! lst_ptr 0 (list 1 2 3)) @@ -776,7 +776,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (test_list_ptr_2) 5) -(xtmtest '(bind-func test_copy_list +(xtmtest (bind-func test_copy_list (lambda () (letz ((l1 (list 1 2 3)) (l2 (copy l1))) @@ -784,7 +784,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (test_copy_list) 1) -(xtmtest '(bind-func test_nth_tail +(xtmtest (bind-func test_nth_tail (lambda () (let ((lst (list 1 2 3))) (nth_tail lst -3) @@ -792,7 +792,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (test_nth_tail) 0) -;; (xtmtest '(bind-func test_nth_tailr +;; (xtmtest (bind-func test_nth_tailr ;; (lambda () ;; (let ((lst (list 1 2 3))) ;; (nth_tailr lst -3) @@ -800,7 +800,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" ;; (test_nth_tailr) 0) -;; (xtmtest '(bind-func test_nth_tail_both +;; (xtmtest (bind-func test_nth_tail_both ;; (lambda () ;; (let ((lst (list 1 2 3))) ;; (equal (nth_tail lst 1) @@ -808,7 +808,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" ;; (test_nth_tail_both) 1) -(xtmtest '(bind-func test_list_take +(xtmtest (bind-func test_list_take (lambda () (let ((lst (list 1 2 3))) (equal (take lst 2) @@ -816,14 +816,14 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (test_list_take) 1) -(xtmtest '(bind-func test_list_take_2 +(xtmtest (bind-func test_list_take_2 (lambda () (let ((lst (list 1 2 3))) (length (take lst 1000))))) (test_list_take_2) 3) -(xtmtest '(bind-func test_list_drop +(xtmtest (bind-func test_list_drop (lambda () (let ((lst (list 1 2 3))) (equal (drop lst 1) @@ -831,7 +831,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (test_list_drop) 1) -(xtmtest '(bind-func test_list_drop_2 +(xtmtest (bind-func test_list_drop_2 (lambda () (let ((lst (list 1 2 3))) (length (drop lst 1000))))) @@ -840,7 +840,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" ;; dict -(xtmtest '(bind-func test_dict_get_1 +(xtmtest (bind-func test_dict_get_1 (lambda () (let ((d (list (Pair (String "one") 1) (Pair (String "two") 2)))) @@ -848,7 +848,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (test_dict_get_1) 1) -(xtmtest '(bind-func test_dict_get_2 +(xtmtest (bind-func test_dict_get_2 (lambda () (let ((d (list (Pair (String "one") 1) (Pair (String "two") 2)))) @@ -856,7 +856,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (test_dict_get_2) 0) -(xtmtest '(bind-func test_dict_set_1 +(xtmtest (bind-func test_dict_set_1 (lambda () (let ((d (list (Pair (String "one") 1) (Pair (String "two") 2))) @@ -866,7 +866,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (test_dict_set_1) 1) -(xtmtest '(bind-func test_dict_set_2 +(xtmtest (bind-func test_dict_set_2 (lambda () (let ((d (list (Pair (String "one") 1) (Pair (String "two") 2)))) @@ -883,7 +883,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" ;; (test-xtfunc (test_dict_set_3) 1)) -(xtmtest '(bind-func test_dict_update_1 +(xtmtest (bind-func test_dict_update_1 (lambda () (let ((d (list (Pair (String "one") 1) (Pair (String "two") 2))) @@ -895,7 +895,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (test_dict_update_1) 1) -(xtmtest '(bind-func test_dict_update_2 +(xtmtest (bind-func test_dict_update_2 (lambda () (let ((d (list (Pair (String "one") 1) (Pair (String "two") 2)))) @@ -907,21 +907,21 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (test_dict_update_2) 1) (xtmtest - '(bind-func test_list_duplicates + (bind-func test_list_duplicates (lambda () (let ((lst (list 1 2 3 3 4 6 6))) (equal (duplicates lst) (list 3 6))))) (test_list_duplicates) 1) (xtmtest - '(bind-func test_list_unique + (bind-func test_list_unique (lambda () (let ((lst (list 1 2 3 3 4 6 6))) (equal (unique lst) (list 1 2 3 4 6))))) (test_list_unique) 1) (xtmtest - '(bind-func test_list_intersection + (bind-func test_list_intersection (lambda () (let ((l1 (list 1 2 3)) (l2 (list 1 4 2))) @@ -929,7 +929,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" (test_list_intersection) 1) (xtmtest - '(bind-func test_list_union + (bind-func test_list_union (lambda () (let ((l1 (list 1 2 3)) (l2 (list 1 4 2))) @@ -947,7 +947,7 @@ but we'll use a let style form mlet for monadic-let---bad name :(" ;; (test_list_push_1) 42) (xtmtest - '(bind-func test_list_pop_1 + (bind-func test_list_pop_1 (lambda () (let ((l1 (list 42 1 2 3))) ;; probably should do a sorted compare here diff --git a/tests/core/algebraic_data_types.xtm b/tests/core/algebraic_data_types.xtm index 201093009..7781a3c72 100644 --- a/tests/core/algebraic_data_types.xtm +++ b/tests/core/algebraic_data_types.xtm @@ -14,7 +14,7 @@ (ADRect ADPoint{!a}* !a !a)) (xtmtest - '(bind-func algdt_test1 + (bind-func algdt_test1 (lambda () (let ((p1 (ADPoint2D 11 12)) (circle (ADCircle p1 5:i64)) @@ -38,14 +38,14 @@ (ADRight !b)) (xtmtest-compile - '(bind-func algdt_test2:[ADEither{i64,String*}*,i1]* + (bind-func algdt_test2:[ADEither{i64,String*}*,i1]* (lambda (choice) (if choice (ADLeft 100) (ADRight '100'))))) (xtmtest - '(bind-func algdt_test3 + (bind-func algdt_test3 (lambda () (let ((res (algdt_test2 #f))) (ADRight$ res (x) (println x) (println "wrong")) @@ -176,7 +176,7 @@ ;; list test 1 (xtmtest - '(bind-func algdt_test4 + (bind-func algdt_test4 (lambda () (let ((l1 (ADCons 1 (ADCons 2 (ADNil))))) (println 'l1 '= l1)))) @@ -185,7 +185,7 @@ ;; list test 2 (xtmtest - '(bind-func algdt_test5 + (bind-func algdt_test5 (lambda () (let ((l1 (ADCons 1 (ADCons 2 (ADNil)))) (l2 (fmap (lambda (x) (* x x)) l1))) @@ -194,7 +194,7 @@ ;; list test 3 (xtmtest - '(bind-func algdt_test6 + (bind-func algdt_test6 (lambda () (let ((l1 (ADCons 1 (ADCons 2 (ADNil)))) (l3 (fmap (lambda (x) (ADCons x (ADCons x (ADNil)))) l1))) @@ -227,14 +227,14 @@ (Str "()")))) (xtmtest-compile - '(bind-func algdt_test8 + (bind-func algdt_test8 (lambda () (dolet ((x (adrange 1 2)) (y (adrange 1 4))) (unit (ADPair x y)))))) (xtmtest - '(bind-func algdt_test8b + (bind-func algdt_test8b (lambda () (println (algdt_test8)))) (algdt_test8b)) @@ -322,7 +322,7 @@ (xtmtest - '(bind-func algdt_test9 + (bind-func algdt_test9 (lambda () (println (div_test (ADSome 125) (ADSome 25)) (div_test 50 10) diff --git a/tests/core/aot-compilation.xtm b/tests/core/aot-compilation.xtm index 99927a258..7d08a40e8 100644 --- a/tests/core/aot-compilation.xtm +++ b/tests/core/aot-compilation.xtm @@ -77,7 +77,7 @@ ;; bind-val (xtmtest - '(bind-func return_string_gv_with_docstring + (bind-func return_string_gv_with_docstring (lambda () string_gv_with_docstring)) (string=? (cptr->string (return_string_gv_with_docstring)) "sgv") @@ -90,7 +90,7 @@ ;; i8*, the string literal is the value (not the docstring) (xtmtest - '(bind-func return_string_gv_no_docstring + (bind-func return_string_gv_no_docstring (lambda () string_gv_no_docstring)) (string=? (cptr->string (return_string_gv_no_docstring)) "sgv") @@ -101,7 +101,7 @@ #t) (xtmtest - '(bind-func return_string_gv_no_initval + (bind-func return_string_gv_no_initval (lambda () string_gv_no_initval)) (string=? (cptr->string (return_string_gv_no_initval)) "") diff --git a/tests/core/builtins.xtm b/tests/core/builtins.xtm index 75b5bbb92..8c7210a12 100644 --- a/tests/core/builtins.xtm +++ b/tests/core/builtins.xtm @@ -12,367 +12,367 @@ ;;; Code: -(xtmtest '(bind-func test_fabsf +(xtmtest (bind-func test_fabsf (lambda () (fabsf -6.0))) (test_fabsf) 6.0) -(xtmtest '(bind-func test_fabsd +(xtmtest (bind-func test_fabsd (lambda () (fabsd -6.0))) (test_fabsd) 6.0) -(xtmtest '(bind-func test_fabs +(xtmtest (bind-func test_fabs (lambda () (fabs -6.0))) (test_fabs) 6.0) -(xtmtest '(bind-func test_sqrtd +(xtmtest (bind-func test_sqrtd (lambda () (sqrtd 9.))) (test_sqrtd) 3.) -(xtmtest '(bind-func test_sqrtf +(xtmtest (bind-func test_sqrtf (lambda () (sqrtf 9.))) (test_sqrtf) 3.) -(xtmtest '(bind-func test_sqrt +(xtmtest (bind-func test_sqrt (lambda () (sqrt 9.))) (test_sqrt) 3.) -(xtmtest '(bind-func test_log10d +(xtmtest (bind-func test_log10d (lambda () (log10d 100.))) (test_log10d) 2.) -(xtmtest '(bind-func test_log10f +(xtmtest (bind-func test_log10f (lambda () (log10f 100.))) (test_log10f) 2.) -(xtmtest '(bind-func test_log10 +(xtmtest (bind-func test_log10 (lambda () (log10 100.))) (test_log10) 2.) -(xtmtest '(bind-func test_log2d +(xtmtest (bind-func test_log2d (lambda () (log2d 8.))) (test_log2d) 3.) -(xtmtest '(bind-func test_log2f +(xtmtest (bind-func test_log2f (lambda () (log2f 8.))) (test_log2f) 3.) -(xtmtest '(bind-func test_log2 +(xtmtest (bind-func test_log2 (lambda () (log2 8.))) (test_log2) 3.) -(xtmtest '(bind-func test_logd +(xtmtest (bind-func test_logd (lambda () (logd 7.))) (test_logd)) -(xtmtest '(bind-func test_logf +(xtmtest (bind-func test_logf (lambda () (logf 7.))) (test_logf)) -(xtmtest '(bind-func test_log +(xtmtest (bind-func test_log (lambda () (log 7.))) (test_log)) -(xtmtest '(bind-func test_powd +(xtmtest (bind-func test_powd (lambda () (powd 2. 2.))) (test_powd) 4.) -(xtmtest '(bind-func test_powf +(xtmtest (bind-func test_powf (lambda () (powf 2. 2.))) (test_powf) 4.) -(xtmtest '(bind-func test_pow +(xtmtest (bind-func test_pow (lambda () (pow 2. 2.))) (test_pow) 4.) -(xtmtest '(bind-func test_fmodd +(xtmtest (bind-func test_fmodd (lambda () (fmodd 10. 3.))) (test_fmodd) 1.) -(xtmtest '(bind-func test_fmodf +(xtmtest (bind-func test_fmodf (lambda () (fmodf 10. 3.))) (test_fmodf) 1.) -(xtmtest '(bind-func test_fmod +(xtmtest (bind-func test_fmod (lambda () (fmod 10. 3.))) (test_fmod) 1.) -(xtmtest '(bind-func test_expd +(xtmtest (bind-func test_expd (lambda () (expd 2.))) (test_expd)) -(xtmtest '(bind-func test_expf +(xtmtest (bind-func test_expf (lambda () (expf 2.))) (test_expf)) -(xtmtest '(bind-func test_exp +(xtmtest (bind-func test_exp (lambda () (exp 2.))) (test_exp)) -(xtmtest '(bind-func test_floord +(xtmtest (bind-func test_floord (lambda () (floord 4.5))) (test_floord) 4.) -(xtmtest '(bind-func test_floorf +(xtmtest (bind-func test_floorf (lambda () (floorf 4.5))) (test_floorf) 4.) -(xtmtest '(bind-func test_floor +(xtmtest (bind-func test_floor (lambda () (floor 4.5))) (test_floor) 4.) -(xtmtest '(bind-func test_ceild +(xtmtest (bind-func test_ceild (lambda () (ceild 3.7))) (test_ceild) 4.) -(xtmtest '(bind-func test_ceilf +(xtmtest (bind-func test_ceilf (lambda () (ceilf 3.7))) (test_ceilf) 4.) -(xtmtest '(bind-func test_ceil +(xtmtest (bind-func test_ceil (lambda () (ceil 3.7))) (test_ceil) 4.) -(xtmtest '(bind-func test_atan2d +(xtmtest (bind-func test_atan2d (lambda () (atan2d 3.0 .2))) (test_atan2d)) -(xtmtest '(bind-func test_atan2f +(xtmtest (bind-func test_atan2f (lambda () (atan2f 3.0 .2))) (test_atan2f)) -(xtmtest '(bind-func test_atan2 +(xtmtest (bind-func test_atan2 (lambda () (atan2 3.0 .2))) (test_atan2)) -(xtmtest '(bind-func test_atand +(xtmtest (bind-func test_atand (lambda () (atand 3.))) (test_atand)) -(xtmtest '(bind-func test_atanf +(xtmtest (bind-func test_atanf (lambda () (atanf 3.))) (test_atanf)) -(xtmtest '(bind-func test_atan +(xtmtest (bind-func test_atan (lambda () (atan 3.))) (test_atan)) -(xtmtest '(bind-func test_asind +(xtmtest (bind-func test_asind (lambda () (asind 0.))) (test_asind) 0.) -(xtmtest '(bind-func test_asinf +(xtmtest (bind-func test_asinf (lambda () (asinf 0.))) (test_asinf) 0.) -(xtmtest '(bind-func test_asin +(xtmtest (bind-func test_asin (lambda () (asin 0.))) (test_asin) 0.) -(xtmtest '(bind-func test_acosd +(xtmtest (bind-func test_acosd (lambda () (acosd 0.))) (test_acosd)) -(xtmtest '(bind-func test_acosf +(xtmtest (bind-func test_acosf (lambda () (acosf 0.))) (test_acosf)) -(xtmtest '(bind-func test_acos +(xtmtest (bind-func test_acos (lambda () (acos 0.))) (test_acos)) -(xtmtest '(bind-func test_sinhd +(xtmtest (bind-func test_sinhd (lambda () (sinhd 0.))) (test_sinhd) 0.) -(xtmtest '(bind-func test_sinhf +(xtmtest (bind-func test_sinhf (lambda () (sinhf 0.))) (test_sinhf) 0.) -(xtmtest '(bind-func test_sinh +(xtmtest (bind-func test_sinh (lambda () (sinh 0.))) (test_sinh) 0.) -(xtmtest '(bind-func test_tanhd +(xtmtest (bind-func test_tanhd (lambda () (tanhd 0.))) (test_tanhd) 0.) -(xtmtest '(bind-func test_tanhf +(xtmtest (bind-func test_tanhf (lambda () (tanhf 0.))) (test_tanhf) 0.) -(xtmtest '(bind-func test_tanh +(xtmtest (bind-func test_tanh (lambda () (tanh 0.))) (test_tanh) 0.) -(xtmtest '(bind-func test_coshd +(xtmtest (bind-func test_coshd (lambda () (coshd 0.))) (test_coshd) 1.) -(xtmtest '(bind-func test_coshf +(xtmtest (bind-func test_coshf (lambda () (coshf 0.))) (test_coshf) 1.) -(xtmtest '(bind-func test_cosh +(xtmtest (bind-func test_cosh (lambda () (cosh 0.))) (test_cosh) 1.) -(xtmtest '(bind-func test_sind +(xtmtest (bind-func test_sind (lambda () (sind 0.))) (test_sind) 0.) -(xtmtest '(bind-func test_sinf +(xtmtest (bind-func test_sinf (lambda () (sinf 0.))) (test_sinf) 0.) -(xtmtest '(bind-func test_sin +(xtmtest (bind-func test_sin (lambda () (sin 0.))) (test_sin) 0.) -(xtmtest '(bind-func test_tand +(xtmtest (bind-func test_tand (lambda () (tand 0.))) (test_tand) 0.) -(xtmtest '(bind-func test_tanf +(xtmtest (bind-func test_tanf (lambda () (tanf 0.))) (test_tanf) 0.) -(xtmtest '(bind-func test_tan +(xtmtest (bind-func test_tan (lambda () (tan 0.))) (test_tan) 0.) -(xtmtest '(bind-func test_cosd +(xtmtest (bind-func test_cosd (lambda () (cosd 0.))) (test_cosd) 1.) -(xtmtest '(bind-func test_cosf +(xtmtest (bind-func test_cosf (lambda () (cosf 0.))) (test_cosf) 1.) -(xtmtest '(bind-func test_cos +(xtmtest (bind-func test_cos (lambda () (cos 0.))) (test_cos) 1.) -(xtmtest '(bind-func test_mutex +(xtmtest (bind-func test_mutex (lambda () (let ((mutex (mutex_create))) (mutex_lock mutex) @@ -382,575 +382,575 @@ (mutex_destroy mutex)))) (test_mutex)) -;; (xtmtest '(bind-func test_thread_sleep +;; (xtmtest (bind-func test_thread_sleep ;; (lambda () ;; (thread_sleep)))) ;; (test-xtfunc test_thread_sleep) -;; (xtmtest '(bind-func test_thread_self +;; (xtmtest (bind-func test_thread_self ;; (lambda () ;; (thread_self)))) ;; (test-xtfunc test_thread_self) -;; (xtmtest '(bind-func test_thread_kill +;; (xtmtest (bind-func test_thread_kill ;; (lambda () ;; (thread_kill)))) ;; (test-xtfunc test_thread_kill) -;; (xtmtest '(bind-func test_thread_join +;; (xtmtest (bind-func test_thread_join ;; (lambda () ;; (thread_join)))) ;; (test-xtfunc test_thread_join) -;; (xtmtest '(bind-func test_thread_fork +;; (xtmtest (bind-func test_thread_fork ;; (lambda () ;; (thread_fork)))) ;; (test-xtfunc test_thread_fork) -;; (xtmtest '(bind-func test_list_ref +;; (xtmtest (bind-func test_list_ref ;; (lambda () ;; (list_ref)))) ;; (test-xtfunc test_list_ref) -;; (xtmtest '(bind-func test_free16 +;; (xtmtest (bind-func test_free16 ;; (lambda () ;; (free16)))) ;; (test-xtfunc test_free16) -;; (xtmtest '(bind-func test_malloc16 +;; (xtmtest (bind-func test_malloc16 ;; (lambda () ;; (malloc16)))) ;; (test-xtfunc test_malloc16) -(xtmtest '(bind-func test_is_cptr_or_str +(xtmtest (bind-func test_is_cptr_or_str (lambda () (is_cptr_or_str "string"))) (test_is_cptr_or_str) 0) -(xtmtest '(bind-func test_is_cptr +(xtmtest (bind-func test_is_cptr (lambda () (let ((p:i8* (salloc))) (is_cptr p)))) (test_is_cptr) 0) -;; (xtmtest '(bind-func test_mk_cptr +;; (xtmtest (bind-func test_mk_cptr ;; (lambda () ;; (mk_cptr)))) ;; (test-xtfunc test_mk_cptr) -;; (xtmtest '(bind-func test_cptr_value +;; (xtmtest (bind-func test_cptr_value ;; (lambda () ;; (cptr_value)))) ;; (test-xtfunc test_cptr_value) -(xtmtest '(bind-func test_is_string +(xtmtest (bind-func test_is_string (lambda () (is_string "soifns"))) (test_is_string) 0) -;; (xtmtest '(bind-func test_mk_string +;; (xtmtest (bind-func test_mk_string ;; (lambda () ;; (mk_string)))) ;; (test-xtfunc test_mk_string) -;; (xtmtest '(bind-func test_string_value +;; (xtmtest (bind-func test_string_value ;; (lambda () ;; (string_value)))) ;; (test-xtfunc test_string_value) -;; (xtmtest '(bind-func test_is_integer +;; (xtmtest (bind-func test_is_integer ;; (lambda () ;; (is_integer)))) ;; (test-xtfunc test_is_integer) -;; (xtmtest '(bind-func test_mk_i1 +;; (xtmtest (bind-func test_mk_i1 ;; (lambda () ;; (mk_i1)))) ;; (test-xtfunc test_mk_i1) -;; (xtmtest '(bind-func test_i1value +;; (xtmtest (bind-func test_i1value ;; (lambda () ;; (i1value)))) ;; (test-xtfunc test_i1value) -;; (xtmtest '(bind-func test_mk_i8 +;; (xtmtest (bind-func test_mk_i8 ;; (lambda () ;; (mk_i8)))) ;; (test-xtfunc test_mk_i8) -;; (xtmtest '(bind-func test_i8value +;; (xtmtest (bind-func test_i8value ;; (lambda () ;; (i8value)))) ;; (test-xtfunc test_i8value) -;; (xtmtest '(bind-func test_mk_i16 +;; (xtmtest (bind-func test_mk_i16 ;; (lambda () ;; (mk_i16)))) ;; (test-xtfunc test_mk_i16) -;; (xtmtest '(bind-func test_i16value +;; (xtmtest (bind-func test_i16value ;; (lambda () ;; (i16value)))) ;; (test-xtfunc test_i16value) -;; (xtmtest '(bind-func test_mk_i32 +;; (xtmtest (bind-func test_mk_i32 ;; (lambda () ;; (mk_i32)))) ;; (test-xtfunc test_mk_i32) -;; (xtmtest '(bind-func test_i32value +;; (xtmtest (bind-func test_i32value ;; (lambda () ;; (i32value)))) ;; (test-xtfunc test_i32value) -;; (xtmtest '(bind-func test_mk_i64 +;; (xtmtest (bind-func test_mk_i64 ;; (lambda () ;; (mk_i64)))) ;; (test-xtfunc test_mk_i64) -;; (xtmtest '(bind-func test_i64value +;; (xtmtest (bind-func test_i64value ;; (lambda () ;; (i64value)))) ;; (test-xtfunc test_i64value) -;; (xtmtest '(bind-func test_is_real +;; (xtmtest (bind-func test_is_real ;; (lambda () ;; (is_real)))) ;; (test-xtfunc test_is_real) -;; (xtmtest '(bind-func test_mk_float +;; (xtmtest (bind-func test_mk_float ;; (lambda () ;; (mk_float)))) ;; (test-xtfunc test_mk_float) -;; (xtmtest '(bind-func test_r32value +;; (xtmtest (bind-func test_r32value ;; (lambda () ;; (r32value)))) ;; (test-xtfunc test_r32value) -;; (xtmtest '(bind-func test_mk_double +;; (xtmtest (bind-func test_mk_double ;; (lambda () ;; (mk_double)))) ;; (test-xtfunc test_mk_double) -;; (xtmtest '(bind-func test_r64value +;; (xtmtest (bind-func test_r64value ;; (lambda () ;; (r64value)))) ;; (test-xtfunc test_r64value) -;; (xtmtest '(bind-func test_cname_decode +;; (xtmtest (bind-func test_cname_decode ;; (lambda () ;; (cname_decode)))) ;; (test-xtfunc test_cname_decode) -;; (xtmtest '(bind-func test_cname_encode +;; (xtmtest (bind-func test_cname_encode ;; (lambda () ;; (cname_encode)))) ;; (test-xtfunc test_cname_encode) -;; (xtmtest '(bind-func test_base64_decode +;; (xtmtest (bind-func test_base64_decode ;; (lambda () ;; (base64_decode)))) ;; (test-xtfunc test_base64_decode) -;; (xtmtest '(bind-func test_base64_encode +;; (xtmtest (bind-func test_base64_encode ;; (lambda () ;; (base64_encode)))) ;; (test-xtfunc test_base64_encode) -;; (xtmtest '(bind-func test_rreplace +;; (xtmtest (bind-func test_rreplace ;; (lambda () ;; (rreplace)))) ;; (test-xtfunc test_rreplace) -;; (xtmtest '(bind-func test_rmatch +;; (xtmtest (bind-func test_rmatch ;; (lambda () ;; (rmatch)))) ;; (test-xtfunc test_rmatch) -;; (xtmtest '(bind-func test_rsplit +;; (xtmtest (bind-func test_rsplit ;; (lambda () ;; (rsplit)))) ;; (test-xtfunc test_rsplit) -(xtmtest '(bind-func test_imp_rand2_f +(xtmtest (bind-func test_imp_rand2_f (lambda () (< (imp_rand2_f 0. 10.) 10.))) (test_imp_rand2_f) 1) -(xtmtest '(bind-func test_imp_rand1_f +(xtmtest (bind-func test_imp_rand1_f (lambda () (< (imp_rand1_f 10.) 10.))) (test_imp_rand1_f) 1) -(xtmtest '(bind-func test_imp_rand2_d +(xtmtest (bind-func test_imp_rand2_d (lambda () (< (imp_rand2_d 0. 10.) 10.))) (test_imp_rand2_d) 1) -(xtmtest '(bind-func test_imp_rand1_d +(xtmtest (bind-func test_imp_rand1_d (lambda () (< (imp_rand1_d 10.) 10.))) (test_imp_rand1_d) 1) -(xtmtest '(bind-func test_imp_rand2_i32 +(xtmtest (bind-func test_imp_rand2_i32 (lambda () (< (imp_rand2_i32 0 10) 10))) (test_imp_rand2_i32) 1) -(xtmtest '(bind-func test_imp_rand1_i32 +(xtmtest (bind-func test_imp_rand1_i32 (lambda () (< (imp_rand1_i32 10) 10))) (test_imp_rand1_i32) 1) -(xtmtest '(bind-func test_imp_rand2_i64 +(xtmtest (bind-func test_imp_rand2_i64 (lambda () (< (imp_rand2_i64 0 10) 10))) (test_imp_rand2_i64) 1) -(xtmtest '(bind-func test_imp_rand1_i64 +(xtmtest (bind-func test_imp_rand1_i64 (lambda () (< (imp_rand1_i64 10) 10))) (test_imp_rand1_i64) 1) -(xtmtest '(bind-func test_imp_randf +(xtmtest (bind-func test_imp_randf (lambda () (and (> (imp_randf) .0) (< (imp_randf) 1.0)))) (test_imp_randf) 1) -(xtmtest '(bind-func test_imp_randd +(xtmtest (bind-func test_imp_randd (lambda () (and (> (imp_randd) 0.) (< (imp_randd) 1.)))) (test_imp_randd) 1) -(xtmtest '(bind-func test_unswap32f +(xtmtest (bind-func test_unswap32f (lambda () (unswap32f 10))) (test_unswap32f)) -(xtmtest '(bind-func test_unswap32i +(xtmtest (bind-func test_unswap32i (lambda () (unswap32i 10))) (test_unswap32i)) -(xtmtest '(bind-func test_unswap64f +(xtmtest (bind-func test_unswap64f (lambda () (unswap64f 10))) (test_unswap64f)) -(xtmtest '(bind-func test_unswap64i +(xtmtest (bind-func test_unswap64i (lambda () (unswap64i 10))) (test_unswap64i)) -(xtmtest '(bind-func test_swap32f +(xtmtest (bind-func test_swap32f (lambda () (swap32f 10.))) (test_swap32f)) -(xtmtest '(bind-func test_swap32i +(xtmtest (bind-func test_swap32i (lambda () (swap32i 10))) (test_swap32i)) -(xtmtest '(bind-func test_swap64f +(xtmtest (bind-func test_swap64f (lambda () (swap64f 10.))) (test_swap64f)) -(xtmtest '(bind-func test_swap64i +(xtmtest (bind-func test_swap64i (lambda () (swap64i 10))) (test_swap64i)) -(xtmtest '(bind-func test_string_hash +(xtmtest (bind-func test_string_hash (lambda () (string_hash "test"))) (test_string_hash)) -(xtmtest '(bind-func test_extitoa +(xtmtest (bind-func test_extitoa (lambda () (extitoa 40))) (test_extitoa)) -(xtmtest '(bind-func test_llvm_memset +(xtmtest (bind-func test_llvm_memset (lambda () (llvm_memset null 10 0))) (test_llvm_memset)) -(xtmtest '(bind-func test_llvm_zone_ptr_size +(xtmtest (bind-func test_llvm_zone_ptr_size (lambda () (llvm_zone_ptr_size null))) (test_llvm_zone_ptr_size) 0) -(xtmtest '(bind-func test_llvm_zone_ptr_set_size +(xtmtest (bind-func test_llvm_zone_ptr_set_size (lambda () (llvm_zone_ptr_set_size null 0))) (test_llvm_zone_ptr_set_size)) -;; (xtmtest '(bind-func test_llvm_zone_mark_size +;; (xtmtest (bind-func test_llvm_zone_mark_size ;; (lambda () ;; (llvm_zone_mark_size null)))) ;; (test-xtfunc (test_llvm_zone_mark_size)) -;; (xtmtest '(bind-func test_llvm_zone_mark +;; (xtmtest (bind-func test_llvm_zone_mark ;; (lambda () ;; (llvm_zone_mark)))) ;; (test-xtfunc test_llvm_zone_mark) -;; (xtmtest '(bind-func test_llvm_zone_copy_ptr +;; (xtmtest (bind-func test_llvm_zone_copy_ptr ;; (lambda () ;; (llvm_zone_copy_ptr)))) ;; (test-xtfunc test_llvm_zone_copy_ptr) -;; (xtmtest '(bind-func test_llvm_zone_reset +;; (xtmtest (bind-func test_llvm_zone_reset ;; (lambda () ;; (llvm_zone_reset)))) ;; (test-xtfunc test_llvm_zone_reset) -(xtmtest '(bind-func test_llvm_now +(xtmtest (bind-func test_llvm_now (lambda () (= (llvm_now) (now)))) (test_llvm_now)) -(xtmtest '(bind-func test_ascii_text_color +(xtmtest (bind-func test_ascii_text_color (lambda () (ascii_text_color 0 7 0))) (test_ascii_text_color)) -(xtmtest '(bind-func test_llvm_print_f64 +(xtmtest (bind-func test_llvm_print_f64 (lambda () (llvm_print_f64 130.))) (test_llvm_print_f64)) -(xtmtest '(bind-func test_llvm_print_f32 +(xtmtest (bind-func test_llvm_print_f32 (lambda () (llvm_print_f32 1.3))) (test_llvm_print_f32)) -(xtmtest '(bind-func test_llvm_print_i64 +(xtmtest (bind-func test_llvm_print_i64 (lambda () (llvm_print_i64 190))) (test_llvm_print_i64)) -(xtmtest '(bind-func test_llvm_print_i32 +(xtmtest (bind-func test_llvm_print_i32 (lambda () (llvm_print_i32 2342))) (test_llvm_print_i32)) -(xtmtest '(bind-func test_llvm_print_pointer +(xtmtest (bind-func test_llvm_print_pointer (lambda () (let ((p:i8* (salloc))) (llvm_print_pointer p)))) (test_llvm_print_pointer)) -(xtmtest '(bind-func test_new_address_table +(xtmtest (bind-func test_new_address_table (lambda () (new_address_table))) (test_new_address_table)) -;; (xtmtest '(bind-func test_add_address_table +;; (xtmtest (bind-func test_add_address_table ;; (lambda () ;; (add_address_table)))) ;; (test-xtfunc test_add_address_table) -(xtmtest '(bind-func test_get_address_offset +(xtmtest (bind-func test_get_address_offset (lambda () (get_address_offset "name" null))) (test_get_address_offset)) -(xtmtest '(bind-func test_check_address_exists +(xtmtest (bind-func test_check_address_exists (lambda () (check_address_exists "name" null))) (test_check_address_exists)) -(xtmtest '(bind-func test_check_address_type +(xtmtest (bind-func test_check_address_type (lambda () (check_address_type "name" null "type"))) (test_check_address_type)) -(xtmtest '(bind-func test_get_address_table +(xtmtest (bind-func test_get_address_table (lambda () (get_address_table "name" null))) (test_get_address_table)) -;; (xtmtest '(bind-func test_llvm_zone_malloc +;; (xtmtest (bind-func test_llvm_zone_malloc ;; (lambda () ;; (llvm_zone_malloc null 0)))) ;; (test-xtfunc (test_llvm_zone_malloc)) -;; (xtmtest '(bind-func test_llvm_stack_alloc +;; (xtmtest (bind-func test_llvm_stack_alloc ;; (lambda () ;; (llvm_stack_alloc)))) ;; (test-xtfunc test_llvm_stack_alloc) -;; (xtmtest '(bind-func test_llvm_push_zone_stack +;; (xtmtest (bind-func test_llvm_push_zone_stack ;; (lambda () ;; (llvm_push_zone_stack)))) ;; (test-xtfunc test_llvm_push_zone_stack) -;; (xtmtest '(bind-func test_llvm_pop_zone_stack +;; (xtmtest (bind-func test_llvm_pop_zone_stack ;; (lambda () ;; (llvm_pop_zone_stack)))) ;; (test-xtfunc test_llvm_pop_zone_stack) -;; (xtmtest '(bind-func test_llvm_peek_zone_stack +;; (xtmtest (bind-func test_llvm_peek_zone_stack ;; (lambda () ;; (llvm_peek_zone_stack)))) ;; (test-xtfunc test_llvm_peek_zone_stack) -;; (xtmtest '(bind-func test_llvm_scheme_process_ucontext +;; (xtmtest (bind-func test_llvm_scheme_process_ucontext ;; (lambda () ;; (llvm_scheme_process_ucontext)))) ;; (test-xtfunc test_llvm_scheme_process_ucontext) -;; (xtmtest '(bind-func test_llvm_make_ucontext +;; (xtmtest (bind-func test_llvm_make_ucontext ;; (lambda () ;; (llvm_make_ucontext)))) ;; (test-xtfunc test_llvm_make_ucontext) -;; (xtmtest '(bind-func test_llvm_get_function_ptr +;; (xtmtest (bind-func test_llvm_get_function_ptr ;; (lambda () ;; (llvm_get_function_ptr)))) ;; (test-xtfunc test_llvm_get_function_ptr) -;; (xtmtest '(bind-func test_llvm_schedule_callback +;; (xtmtest (bind-func test_llvm_schedule_callback ;; (lambda () ;; (llvm_schedule_callback)))) ;; (test-xtfunc test_llvm_schedule_callback) -;; (xtmtest '(bind-func test_llvm_send_udp +;; (xtmtest (bind-func test_llvm_send_udp ;; (lambda () ;; (llvm_send_udp)))) ;; (test-xtfunc test_llvm_send_udp) -;; (xtmtest '(bind-func test_llvm_runtime_error +;; (xtmtest (bind-func test_llvm_runtime_error ;; (lambda () ;; (llvm_runtime_error)))) ;; (test-xtfunc test_llvm_runtime_error) -;; (xtmtest '(bind-func test_llvm_zone_print +;; (xtmtest (bind-func test_llvm_zone_print ;; (lambda () ;; (llvm_zone_print)))) ;; (test-xtfunc test_llvm_zone_print) -;; (xtmtest '(bind-func test_llvm_zone_destroy +;; (xtmtest (bind-func test_llvm_zone_destroy ;; (lambda () ;; (llvm_zone_destroy)))) ;; (test-xtfunc test_llvm_zone_destroy) -;; (xtmtest '(bind-func test_llvm_zone_create +;; (xtmtest (bind-func test_llvm_zone_create ;; (lambda () ;; (llvm_zone_create)))) ;; (test-xtfunc test_llvm_zone_create) -;; (xtmtest '(bind-func test_llvm_fscanf +;; (xtmtest (bind-func test_llvm_fscanf ;; (lambda () ;; (llvm_fscanf)))) ;; (test-xtfunc test_llvm_fscanf) -;; (xtmtest '(bind-func test_llvm_sscanf +;; (xtmtest (bind-func test_llvm_sscanf ;; (lambda () ;; (llvm_sscanf)))) ;; (test-xtfunc test_llvm_sscanf) -(xtmtest '(bind-func test_llvm_sprintf +(xtmtest (bind-func test_llvm_sprintf (lambda () (let ((str:i8* (salloc 256))) (llvm_sprintf str "%lld %s %g\n" 4 "test" 54.) @@ -959,31 +959,31 @@ (test_llvm_sprintf)) -;; (xtmtest '(bind-func test_llvm_fprintf +;; (xtmtest (bind-func test_llvm_fprintf ;; (lambda () ;; (llvm_fprintf)))) ;; (test-xtfunc test_llvm_fprintf) -(xtmtest '(bind-func test_llvm_printf +(xtmtest (bind-func test_llvm_printf (lambda () (llvm_printf "%lld %s %g\n" 4 "test" 54.))) (test_llvm_printf)) -(xtmtest '(bind-func test_next_prime +(xtmtest (bind-func test_next_prime (lambda () (next_prime 10))) (test_next_prime) 11) -;; (xtmtest '(bind-func test_llvm_destroy_zone_after_delay +;; (xtmtest (bind-func test_llvm_destroy_zone_after_delay ;; (lambda () ;; (llvm_destroy_zone_after_delay)))) ;; (test-xtfunc test_llvm_destroy_zone_after_delay) -;; (xtmtest '(bind-func test_free_after_delay +;; (xtmtest (bind-func test_free_after_delay ;; (lambda () ;; (free_after_delay)))) diff --git a/tests/core/constraints.xtm b/tests/core/constraints.xtm index 98e750ee9..1d23a9195 100644 --- a/tests/core/constraints.xtm +++ b/tests/core/constraints.xtm @@ -22,7 +22,7 @@ x)) (xtmtest - '(bind-func constraint1 + (bind-func constraint1 (lambda () (let ((a (test_1 2:i64)) (b (test_1 9.0:double)) @@ -42,14 +42,14 @@ (println "The following two tests should both fail constraints tests!") (xtmtest - '(bind-func constraint2 + (bind-func constraint2 (lambda () (test_1 (tuple 1.0:f 2.0:f 3.0:f)))) (constraint2) 'compile-should-fail) (xtmtest - '(bind-func constraint3 + (bind-func constraint3 (lambda () (test_1 (array 1.0:f 2.0:f 3.0:f)))) (constraint3) @@ -77,7 +77,7 @@ (sqr (sqr x)))) (xtmtest - '(bind-func constraint4 + (bind-func constraint4 (lambda () (sqr2 2:i32) (sqr2 2:i64))) @@ -87,7 +87,7 @@ (println "Constraint5 should fail!") (xtmtest - '(bind-func constraint5 + (bind-func constraint5 (lambda () (sqr2 2:float))) (constraint5) @@ -98,7 +98,7 @@ (println "After adding sqr:[float,float]* Constraint6 passes!") (xtmtest - '(bind-func constraint6 + (bind-func constraint6 (lambda () (sqr2 2:float))) (constraint6) @@ -120,7 +120,7 @@ (xtmtest - '(bind-func constraint7 + (bind-func constraint7 (lambda () (printer (tuple 1.0:double 2.0:f 3:i32)))) (constraint7)) @@ -134,13 +134,13 @@ (println "You must be a String or a Symbol! " x))) (xtmtest - '(bind-func constraint8 + (bind-func constraint8 (lambda () (print-str-sym (String "HI")))) (constraint8)) (xtmtest - '(bind-func constraint9 + (bind-func constraint9 (lambda () (print-str-sym (Symbol "HI")))) (constraint9)) @@ -148,7 +148,7 @@ (println "This should fail! not a string* or a symbol*!") (xtmtest - '(bind-func constraint10 + (bind-func constraint10 (lambda () (print-str-sym (tuple_ref 1.0:f)))) (constraint10) @@ -204,7 +204,7 @@ r))) (xtmtest - '(bind-func constraint11 + (bind-func constraint11 (lambda () (println (zip_array_test (array_ref 1:i64 2 3 4) (array_ref 0:i64 0 0 0))) (println (zip_array_test (array 1.0:f 2.0 3.0 4.0) (array 0.0:f 0.0 0.0 0.0))) diff --git a/tests/core/expr_problem.xtm b/tests/core/expr_problem.xtm index fcc548ba5..29575269f 100644 --- a/tests/core/expr_problem.xtm +++ b/tests/core/expr_problem.xtm @@ -17,7 +17,7 @@ ;; First Test (xtmtest - '(bind-func expr_problem + (bind-func expr_problem (lambda () (let ((e1 (Add (Lit 1) (Lit 2))) (e2 (Add (Lit 4.0) (Add (Lit 2.0) (Lit 3.0))))) @@ -37,7 +37,7 @@ (eval (tref x 1))))) (xtmtest - '(bind-func expr_problem_new_type + (bind-func expr_problem_new_type (lambda () (let ((e1 (Add (Lit 1) (Lit 2))) (e2 (Sub (Lit 10) e1))) @@ -68,7 +68,7 @@ (xtmtest - '(bind-func expr_problem_new_op + (bind-func expr_problem_new_op (lambda () (let ((e1 (Add (Lit 1) (Lit 2))) (e2 (Sub (Lit 10) e1))) diff --git a/tests/core/generics.xtm b/tests/core/generics.xtm index 0509b2045..e82f52e76 100644 --- a/tests/core/generics.xtm +++ b/tests/core/generics.xtm @@ -60,7 +60,7 @@ (bind-val NUM_f64 NUM{double}*) (xtmtest - '(bind-func init_num_f64_dict + (bind-func init_num_f64_dict (lambda () (set! NUM_f64 (NUM_h num_f64_plus num_f64_minus num_f64_mul num_f64_div)))) (init_num_f64_dict)) @@ -86,7 +86,7 @@ (bind-val NUM_i64 NUM{i64}*) (xtmtest - '(bind-func init_num_i64_dict + (bind-func init_num_i64_dict (lambda () (set! NUM_i64 (NUM_h num_i64_plus num_i64_minus num_i64_mul num_i64_div)))) (init_num_i64_dict)) @@ -112,7 +112,7 @@ (bind-val NUM_i32 NUM{i32}*) (xtmtest - '(bind-func init_num_i32_dict + (bind-func init_num_i32_dict (lambda () (set! NUM_i32 (NUM_h num_i32_plus num_i32_minus num_i32_mul num_i32_div)))) (init_num_i32_dict)) @@ -138,7 +138,7 @@ (bind-val NUM_f32 NUM{float}*) (xtmtest - '(bind-func init_num_f32_dict + (bind-func init_num_f32_dict (lambda () (set! NUM_f32 (NUM_h num_f32_plus num_f32_minus num_f32_mul num_f32_div)))) (init_num_f32_dict)) @@ -149,7 +149,7 @@ ;; now test the two instances ;;;; -(xtmtest '(bind-func type_class_test +(xtmtest (bind-func type_class_test (lambda () (println (plus NUM_f32 3.0:f 2.0:f) (minus NUM_f32 3.0:f 2.0:f) @@ -238,7 +238,7 @@ (success)))) (xtmtest - '(bind-func make_shapes + (bind-func make_shapes (lambda () (let ((s1 (Circle 1.0 2.0 3.0)) (s2 (Rectangle 1.0 2.0 3.0 4.0)) @@ -266,7 +266,7 @@ ;; (let ((r (ShapeRectangle x y w h))) ;; (Shape 2 (cast null) r)))) -;; (xtmtest '(bind-func make_shapes +;; (xtmtest (bind-func make_shapes ;; (lambda () ;; (let ((s1 (Circle 1.0 2.0 3.0)) ;; (s2 (Rectangle 1.0 2.0 3.0 4.0))) diff --git a/tests/core/math.xtm b/tests/core/math.xtm index 7bf156f3b..958e0c72e 100644 --- a/tests/core/math.xtm +++ b/tests/core/math.xtm @@ -13,62 +13,62 @@ (sys:load "libs/core/math.xtm") (sys:load "libs/core/rational.xtm") -(xtmtest '(bind-func test_gcd +(xtmtest (bind-func test_gcd (lambda () (Rational_greatest_common_divisor 4 12))) (test_gcd) 4) -(xtmtest '(bind-func test_rat_reduce +(xtmtest (bind-func test_rat_reduce (lambda () (println "3/6 =" (Rational_reduce 3/6)) (println "-2/12 =" (Rational_reduce -2/12)))) (test_rat_reduce)) -(xtmtest '(bind-func test_overload_rational_addition +(xtmtest (bind-func test_overload_rational_addition (lambda () (println (+ 1/3 2/3)))) (test_overload_rational_addition)) -(xtmtest '(bind-func test_overload_rational_subtraction +(xtmtest (bind-func test_overload_rational_subtraction (lambda () (println (- 1/3 2/3)))) (test_overload_rational_subtraction)) -(xtmtest '(bind-func test_overload_rational_multiplication +(xtmtest (bind-func test_overload_rational_multiplication (lambda () (println (* 1/3 2/3)))) (test_overload_rational_multiplication)) -(xtmtest '(bind-func test_overload_rational_division +(xtmtest (bind-func test_overload_rational_division (lambda () (println (/ 1/3 2/3)))) (test_overload_rational_division)) -(xtmtest '(bind-func test_rational_equal +(xtmtest (bind-func test_rational_equal (lambda () (= 3/4 6/8))) (test_rational_equal) 1) -(xtmtest '(bind-func test_rational_notequal +(xtmtest (bind-func test_rational_notequal (lambda () (<> 3/4 6/8))) (test_rational_notequal) 0) -(xtmtest '(bind-func test_rational_lessthan +(xtmtest (bind-func test_rational_lessthan (lambda () (< 1/2 3/4))) (test_rational_lessthan) 1) -(xtmtest '(bind-func test_rational_greaterthan +(xtmtest (bind-func test_rational_greaterthan (lambda () (> 1/2 3/4))) @@ -76,7 +76,7 @@ ;; some more complicated tests -(xtmtest '(bind-func test_operator_overloading_1 +(xtmtest (bind-func test_operator_overloading_1 (lambda () (= (* 4/3 1/2) (/ 12/3 12/2)))) @@ -85,27 +85,27 @@ ;; Complexd number tests -(xtmtest '(bind-func test_complex_addition +(xtmtest (bind-func test_complex_addition (lambda () (println (+ (Cpxd 2. 0.4) (Cpxd 5.4 6.))))) (test_complex_addition)) -(xtmtest '(bind-func test_complex_multiplication_1 +(xtmtest (bind-func test_complex_multiplication_1 (lambda () (println (* 1+1i 0+1i)))) (test_complex_multiplication_1)) -(xtmtest '(bind-func test_complex_multiplication_2 +(xtmtest (bind-func test_complex_multiplication_2 (lambda () (println (* 1+1i 1.0)))) (test_complex_multiplication_2)) (xtmtest - '(bind-func test_clampi32 + (bind-func test_clampi32 (lambda () (and (= (clamp 5:i32 0:i32 3:i32) 3) (= (clamp -4:i32 0:i32 3:i32) 0) @@ -113,7 +113,7 @@ (test_clampi32) 1) (xtmtest - '(bind-func test_clampi64 + (bind-func test_clampi64 (lambda () (and (= (clamp 5 0 3) 3) (= (clamp -4 0 3) 0) @@ -121,7 +121,7 @@ (test_clampi64) 1) (xtmtest - '(bind-func test_clampf + (bind-func test_clampf (lambda () (and (= (clamp 5. 0.4 3.3) 3.3) (= (clamp -4. 0.4 3.3) 0.4) @@ -129,7 +129,7 @@ (test_clampf) 1) (xtmtest - '(bind-func test_clampd + (bind-func test_clampd (lambda () (and (= (clamp 5. 0.4 3.3) 3.3) (= (clamp -4. 0.4 3.3) 0.4) @@ -137,7 +137,7 @@ (test_clampd) 1) (xtmtest - '(bind-func test_vcopy_unpack + (bind-func test_vcopy_unpack (lambda () (let ((src:float* (salloc 4)) (dest:float* (salloc 8))) @@ -151,7 +151,7 @@ 1) (xtmtest - '(bind-func test_vcopy_pack + (bind-func test_vcopy_pack (lambda () (let ((src:float* (salloc 8)) (dest:float* (salloc 4))) @@ -162,7 +162,7 @@ 10.) (xtmtest - '(bind-func test_vcopy_pack1 + (bind-func test_vcopy_pack1 (lambda () (let ((src:double* (salloc 8)) (dest:double* (salloc 4))) @@ -173,7 +173,7 @@ 10.) (xtmtest - '(bind-func test_histogram_float + (bind-func test_histogram_float (lambda () (let ((buf:float* (salloc 8)) (hist:HistBin* (salloc 4))) @@ -187,7 +187,7 @@ 1) (xtmtest - '(bind-func test_rowmaj_idx_2D + (bind-func test_rowmaj_idx_2D (lambda () (letz ((m:i64* (zalloc 6))) (pfill! m 0 1 2 3 4 5) @@ -200,7 +200,7 @@ (test_rowmaj_idx_2D) 1) (xtmtest - '(bind-func test_colmaj_idx_2D + (bind-func test_colmaj_idx_2D (lambda () (letz ((m:i64* (zalloc 6))) (pfill! m 0 3 1 4 2 5) @@ -214,7 +214,7 @@ ;; diff e^x (xtmtest - '(bind-func test-diff1 + (bind-func test-diff1 (lambda () (let ((a (ndiff (lambda (x) (exp x)) 5.0)) (b ((lambda (x:double) (exp x)) 5.0))) @@ -224,7 +224,7 @@ ;; diff sin x (xtmtest - '(bind-func test-diff2 + (bind-func test-diff2 (lambda () (let ((a (ndiff (lambda (x) (sin x)) 5.0)) (b ((lambda (x:double) (cos x)) 5.0))) @@ -234,7 +234,7 @@ ;; diff x^2 (xtmtest - '(bind-func test-diff3 + (bind-func test-diff3 (lambda () (let ((a (ndiff (lambda (x) (* x x)) 5.0)) (b ((lambda (x:double) (* 2.0 x)) 5.0))) @@ -244,7 +244,7 @@ ;; diff ln x (xtmtest - '(bind-func test-diff4 + (bind-func test-diff4 (lambda () (let ((a (ndiff (lambda (x) (log x)) 5.0)) (b ((lambda (x:double) (/ 1.0 x)) 5.0))) @@ -255,7 +255,7 @@ ;; integrate x^2 [4,5] (xtmtest - '(bind-func test-intgrate1 + (bind-func test-intgrate1 (lambda () (let ((a (nintegrate (lambda (x) (* x x)) 4.0 5.0)) (b (- ((lambda (x:double) (* (/ 1.0 3.0) (* x x x))) 5.0) @@ -266,7 +266,7 @@ ;; integrate (xtmtest - '(bind-func test-integrate2 + (bind-func test-integrate2 (lambda () (let ((a (nintegrate (lambda (x) (sin x)) 0.0 2.0)) (b (- ((lambda (x:double) (* -1.0 (cos x))) 2.0) diff --git a/tests/core/pcg-rng.xtm b/tests/core/pcg-rng.xtm index 389bd91b2..50a19795a 100644 --- a/tests/core/pcg-rng.xtm +++ b/tests/core/pcg-rng.xtm @@ -3,7 +3,7 @@ ;; uses a known rng state (xtmtest - '(bind-func test_rng_state + (bind-func test_rng_state "Test state" (lambda () (xt_pcg32_srandom #x853c49e6748fea9b #xda3e39cb94b95bd) @@ -11,7 +11,7 @@ (test_rng_state) -5255529594131777703) (xtmtest - '(bind-func test_rng_step_state + (bind-func test_rng_step_state "Test state step" (lambda () (xt_pcg32_srandom #x853c49e6748fea9b #xda3e39cb94b95bd) @@ -20,7 +20,7 @@ (test_rng_step_state) 8043768432876637472) (xtmtest - '(bind-func test_rng_output + (bind-func test_rng_output "Test state step" (lambda () (xt_pcg32_srandom #x853c49e6748fea9b #xda3e39cb94b95bd) diff --git a/tests/core/std.xtm b/tests/core/std.xtm index 01336ff33..179591791 100644 --- a/tests/core/std.xtm +++ b/tests/core/std.xtm @@ -10,13 +10,13 @@ ;;; Code: -(xtmtest '(bind-func test_String_cat_1 +(xtmtest (bind-func test_String_cat_1 (lambda () (println (cat (String "string1 ") (String "string2"))))) (test_String_cat_1)) -(xtmtest '(bind-func test_cat2 +(xtmtest (bind-func test_cat2 (lambda () (println (cat (String "string1 ") (String "string2 ") diff --git a/tests/core/xtlang.xtm b/tests/core/xtlang.xtm index 5ffaa0e20..60fc231ed 100644 --- a/tests/core/xtlang.xtm +++ b/tests/core/xtlang.xtm @@ -13,66 +13,66 @@ ;; bit twiddling -(xtmtest '(bind-func test_bit_twiddle_1 +(xtmtest (bind-func test_bit_twiddle_1 (lambda () (bitwise-and 65535 255 15 1))) (test_bit_twiddle_1) 1) -(xtmtest '(bind-func test_bit_twiddle_2 +(xtmtest (bind-func test_bit_twiddle_2 (lambda () (bitwise-not -1))) (test_bit_twiddle_2) 0) -(xtmtest '(bind-func test_bit_twiddle_3 +(xtmtest (bind-func test_bit_twiddle_3 (lambda () (bitwise-not 0))) (test_bit_twiddle_3) -1) -(xtmtest '(bind-func test_bit_twiddle_4 +(xtmtest (bind-func test_bit_twiddle_4 (lambda () (bitwise-shift-right 65535 8) (bitwise-shift-right 65535 4 4))) (test_bit_twiddle_4) 255) -(xtmtest '(bind-func test_bit_twiddle_5 +(xtmtest (bind-func test_bit_twiddle_5 (lambda () (bitwise-shift-left (bitwise-shift-right 65535 8) 4 4))) (test_bit_twiddle_5) 65280) -(xtmtest '(bind-func test_bit_twiddle_6 +(xtmtest (bind-func test_bit_twiddle_6 (lambda () (bitwise-and (bitwise-or (bitwise-eor 21844 65534) (bitwise-eor 43690 65534)) 1))) (test_bit_twiddle_6) 0) ;; integer literals default to 64 bit integers -(xtmtest '(bind-func int-literal-test +(xtmtest (bind-func int-literal-test (lambda (a) (* a 5))) (int-literal-test 6) 30) ;; float literals default to doubles -(xtmtest '(bind-func float-literal-test +(xtmtest (bind-func float-literal-test (lambda (a) (* a 5.0))) (float-literal-test 6.0) 30.0) ;; you are free to recompile an existing closure -(xtmtest '(bind-func int-literal-test +(xtmtest (bind-func int-literal-test (lambda (a) (/ a 5))) (int-literal-test 30)) ;; array literals tests -(xtmtest '(bind-func i64-array-lit-test +(xtmtest (bind-func i64-array-lit-test (lambda () (let ((a 5) (b 6)) @@ -81,21 +81,21 @@ (i64-array-lit-test)) -(xtmtest '(bind-func float-array-lit-test +(xtmtest (bind-func float-array-lit-test (lambda () (array 1.0:f 2.0 3.0 4.0 5.0) void)) (float-array-lit-test)) -(xtmtest '(bind-func float-ref-array-lit-test +(xtmtest (bind-func float-ref-array-lit-test (lambda () (let ((a (array 1.0:f 2.0 3.0))) (aref a 2)))) (float-ref-array-lit-test) 3.0) -(xtmtest '(bind-func tuple-lit-test +(xtmtest (bind-func tuple-lit-test (lambda () (let ((a 5:i64) (b 5.0:double)) @@ -104,7 +104,7 @@ (tuple-lit-test)) -(xtmtest '(bind-func tuple-ref-lit-test +(xtmtest (bind-func tuple-ref-lit-test (lambda () (let ((a 5:i64) (b 5.0:double) @@ -113,7 +113,7 @@ (tuple-ref-lit-test) 5.0) -(xtmtest '(bind-func closure-test1 +(xtmtest (bind-func closure-test1 (let ((power 0)) (lambda (x) (set! power (+ power 1)) ;; set! for closure mutation as per scheme @@ -121,14 +121,14 @@ (closure-test1 2)) -(xtmtest '(bind-func closure-returns-closure-test +(xtmtest (bind-func closure-returns-closure-test (lambda () (lambda (x) (* x 3)))) (closure-returns-closure-test)) -(xtmtest '(bind-func incrementer-test1 +(xtmtest (bind-func incrementer-test1 (lambda (i:i64) (lambda (incr) (set! i (+ i incr)) @@ -139,7 +139,7 @@ (define myf (incrementer-test1 0)) ;; so we need to type f properly -(xtmtest '(bind-func incrementer-test2 +(xtmtest (bind-func incrementer-test2 (lambda (f:[i64,i64]* x) (f x))) (incrementer-test2 myf 1) 1) @@ -155,7 +155,7 @@ ;; otherwise you just call my-inc-maker directly ;; this avoids the wrapper completely -(xtmtest '(bind-func incrementer-test3 +(xtmtest (bind-func incrementer-test3 (let ((f (incrementer-test1 0))) (lambda () (f 1)))) @@ -171,7 +171,7 @@ ;; function definitions. ;; do a little 16bit test -(xtmtest '(bind-func bitsize-sixteen +(xtmtest (bind-func bitsize-sixteen (lambda (a:i16) (dtoi16 (* (i16tod a) 5.0)))) @@ -179,7 +179,7 @@ ;; while loop test -(xtmtest '(bind-func test_while_loop_1 +(xtmtest (bind-func test_while_loop_1 (lambda () (let ((count 0)) (while (< count 5) @@ -194,7 +194,7 @@ ;; Closures can be recursive ;; -(xtmtest '(bind-func recursive-closure-test +(xtmtest (bind-func recursive-closure-test (lambda (a) (if (< a 1) (printf "done\n") @@ -210,7 +210,7 @@ ;; CANNOT RUN THIS TEST ON WINDOWS (i.e. no salloc)! (if (not (equal? (sys:platform) "Windows")) - (xtmtest '(bind-func tail_opt_test + (xtmtest (bind-func tail_opt_test (lambda (n:i64) (let ((a:float* (salloc 8000))) (if (= n 0) @@ -227,7 +227,7 @@ ;; ;; this for type inference check only -(xtmtest '(bind-func dotimes_inf_test +(xtmtest (bind-func dotimes_inf_test (lambda (len) (let ((buf:i8* (salloc len))) (doloop (i len) @@ -241,7 +241,7 @@ ;; some anon lambda tests ;; -(xtmtest '(bind-func infer_lambdas_test +(xtmtest (bind-func infer_lambdas_test (lambda () (let ((a 5) (b (lambda (x) (* x x))) @@ -258,7 +258,7 @@ ;; ;; make and return a simple tuple -(xtmtest '(bind-func tuple-test1 +(xtmtest (bind-func tuple-test1 (lambda () (let ((t:* (alloc))) t))) @@ -274,7 +274,7 @@ ;; note that my-test-7's return type is inferred ;; by the tuple-reference index ;; (i.e. i64 being tuple index 0) -(xtmtest '(bind-func tuple-test2 +(xtmtest (bind-func tuple-test2 (lambda () (let ((a:* (alloc)) ; returns pointer to type (b 37) @@ -300,7 +300,7 @@ ;; _ (underscore) means don't attempt ;; to match against this position in ;; the tuple (i.e. skip) -(xtmtest '(bind-func tuple-bind-test +(xtmtest (bind-func tuple-bind-test (lambda () (let ((t1:*,double>* (alloc)) (t2:* (alloc)) @@ -316,7 +316,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; some array code with *casting* ;; this function returns void -(xtmtest '(bind-func array-test1 +(xtmtest (bind-func array-test1 (lambda () (let ((v1:|5,float|* (alloc)) (v2:|5,float|* (alloc)) @@ -375,7 +375,7 @@ (let ((ff (aref v 0))) ; aref alias for array-ref (ff 5)))) -(xtmtest '(bind-func array-test4 +(xtmtest (bind-func array-test4 (lambda () (let ((v:|5,[i64,i64]*|* (alloc)) ;; make an array of closures! (vv:|5,i64|* (alloc))) @@ -389,7 +389,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; some conditionals -(xtmtest '(bind-func cond-test1 +(xtmtest (bind-func cond-test1 (lambda (x:i64 y) (if (> x y) x @@ -398,7 +398,7 @@ (cond-test1 12 13)) ;; returns boolean true -(xtmtest '(bind-func cond-test2 +(xtmtest (bind-func cond-test2 (lambda (x:i64) (cond ((= x 1) (printf "A\n")) ((= x 2) (printf "B\n")) @@ -445,7 +445,7 @@ res))))) ;; make a convenience wrapper -(xtmtest '(bind-func env-wrap +(xtmtest (bind-func env-wrap (let* ((points 3) (data:double* (zone-alloc (* points 2)))) (pointer-set! data 0 0.0) ;; point data @@ -489,7 +489,7 @@ ;; let's create a closure that capture's 'a' -(xtmtest '(bind-func dot-access-test1 +(xtmtest (bind-func dot-access-test1 (let ((a:i32 6)) (lambda () (printf "a:%d\n" a) @@ -502,7 +502,7 @@ ;; then we directly set the closures 'a' binding ;; then call again ;; -(xtmtest '(bind-func dot-access-test2 +(xtmtest (bind-func dot-access-test2 (lambda (x:i32) (dot-access-test1) (dot-access-test1.a:i32 x) @@ -512,14 +512,14 @@ ;; of course this works just as well for ;; non-global closures -(xtmtest '(bind-func dot-access-test3 +(xtmtest (bind-func dot-access-test3 (lambda (a:i32) (let ((f (lambda () (* 3 a)))) f))) (dot-access-test3 1)) -(xtmtest '(bind-func dot-access-test4 +(xtmtest (bind-func dot-access-test4 (lambda () (let ((f (dot-access-test3 5))) (f.a:i32 7) @@ -529,7 +529,7 @@ 21) ;; and you can get and set closures also! -(xtmtest '(bind-func dot-access-test5 +(xtmtest (bind-func dot-access-test5 (lambda () (let ((f (lambda (x:i64) x))) (lambda (z) @@ -537,7 +537,7 @@ (dot-access-test5)) -(xtmtest '(bind-func dot-access-test6 +(xtmtest (bind-func dot-access-test6 (lambda () (let ((t1 (dot-access-test5)) (t2 (dot-access-test5))) @@ -574,7 +574,7 @@ ;; end of the function call. You can ;; stack allocate (stack-alloc) ;; any valid type (i64 for example) -(xtmtest '(bind-func salloc-test +(xtmtest (bind-func salloc-test (lambda () (let ((point:vec3* (stack-alloc))) (tset! point 0 0.0) @@ -587,7 +587,7 @@ ;; all named types have 2 default constructors ;; name (zone alloation) + name_h (heap allocation) ;; and a default print poly -(xtmtest '(bind-func data-constructor-test +(xtmtest (bind-func data-constructor-test (lambda () (let ((v1 (vec3 1.0 2.0 3.0)) (v2 (vec3_h 4.0 5.0 6.0))) @@ -609,7 +609,7 @@ ;; This allows you to do things like create an array ;; with an offset -(xtmtest '(bind-func aref-ptr-test +(xtmtest (bind-func aref-ptr-test (lambda () (let ((arr:|32,i64|* (alloc)) (arroff (aref-ptr arr 16)) @@ -636,7 +636,7 @@ (bind-type tuple-with-array ) -(xtmtest '(bind-func array-test5 +(xtmtest (bind-func array-test5 (lambda () (let ((tup:tuple-with-array* (stack-alloc)) (t2:|32,i64|* (stack-alloc))) @@ -663,7 +663,7 @@ ;; increment g_var_a by inc ;; and return new value of g_var_a -(xtmtest '(bind-func global_var_test1 +(xtmtest (bind-func global_var_test1 (lambda (incr) (set! g_var_a (+ g_var_a incr)) g_var_a)) @@ -674,7 +674,7 @@ (bind-val g_var_b double 5.5) (bind-val g_var_c i1 0) -(xtmtest '(bind-func global_var_test1b +(xtmtest (bind-func global_var_test1b (lambda () (* g_var_b (if g_var_c 1.0 4.0)))) @@ -684,7 +684,7 @@ (bind-val g_cstring i8* "Jiblet.") -(xtmtest '(bind-func test_g_cstring +(xtmtest (bind-func test_g_cstring (lambda () (let ((i 0)) (dotimes (i 7) @@ -693,7 +693,7 @@ (test_g_cstring)) -(xtmtest '(bind-func test_g_cstring1 +(xtmtest (bind-func test_g_cstring1 (lambda () (let ((test_cstring "Niblot.") (i 0) @@ -718,7 +718,7 @@ (bind-val g_tuple1 ) (bind-val g_tuple2 ) -(xtmtest '(bind-func test_g_tuple +(xtmtest (bind-func test_g_tuple (lambda () (tfill! g_tuple1 1 4) (tfill! g_tuple2 4.0 1.0) @@ -734,7 +734,7 @@ ;; if we just loop over and print the values in each array -(xtmtest '(bind-func test_g_array11 +(xtmtest (bind-func test_g_array11 (lambda () (let ((i 0)) (dotimes (i 10) @@ -745,7 +745,7 @@ ;; but if we loop over and set some values into the arrays -(xtmtest '(bind-func test_g_array2 +(xtmtest (bind-func test_g_array2 (lambda () (let ((i 0)) (dotimes (i 10) @@ -762,7 +762,7 @@ (bind-val g_array3 |100000000,i64|) -(xtmtest '(bind-func test_g_array3 +(xtmtest (bind-func test_g_array3 (lambda () (let ((i 0)) (dotimes (i 100000000) @@ -777,7 +777,7 @@ (bind-val g_ptr0 double* 10) -(xtmtest '(bind-func test_g_ptr0 +(xtmtest (bind-func test_g_ptr0 (lambda () (let ((total 0.0) (i 0)) @@ -791,7 +791,7 @@ (bind-val g_ptr1 |4,i32|* 2) (bind-val g_ptr2 * 4) -(xtmtest '(bind-func test_g_ptr1 +(xtmtest (bind-func test_g_ptr1 (lambda () (afill! g_ptr1 11 66 35 81) (tset! g_ptr2 1 35.0) @@ -804,7 +804,7 @@ ;; ;; Callbacks -(xtmtest '(bind-func callback-test +(xtmtest (bind-func callback-test (lambda (time:i64 count:i64) (printf "time: %lld:%lld\n" time count) (callback (+ time 1000) callback-test (+ time 22050) (+ count 1)))) @@ -816,7 +816,7 @@ ;; of course we need to keep the type ;; signature the same [void,i64,i64]* ;; -(xtmtest '(bind-func callback-test +(xtmtest (bind-func callback-test (lambda (time:i64 count:i64) void)) @@ -826,7 +826,7 @@ (lambda (x:i64) (println "callback test2 helper: " x))) -(xtmtest '(bind-func callback-test2 +(xtmtest (bind-func callback-test2 (lambda (time:i64 count:i64) (printf "time: %lld:%lld\n" time count) (callback (+ time 20000) callback-test2-helper 555) @@ -834,7 +834,7 @@ (callback-test2 (now) 0)) -(xtmtest '(bind-func callback-test2 +(xtmtest (bind-func callback-test2 (lambda (time:i64 count:i64) void)) @@ -845,7 +845,7 @@ ;; ;; some memzone tests -(xtmtest '(bind-func memzone-test1 +(xtmtest (bind-func memzone-test1 (lambda () (let ((b:|5,double|* (zalloc))) (aset! b 0 @@ -859,7 +859,7 @@ (memzone-test1) 3.5) -(xtmtest '(bind-func memzone-test2 +(xtmtest (bind-func memzone-test2 (lambda () (memzone 1024 (let ((k:|15,double|* (zalloc)) @@ -874,7 +874,7 @@ (memzone-test2)) -(xtmtest '(bind-func memzone-test3 +(xtmtest (bind-func memzone-test3 (lambda () (let ((v (memzone-test2)) (i 0)) @@ -882,7 +882,7 @@ (memzone-test3)) ;; should print all 0.0's -(xtmtest '(bind-func memzone-test4 +(xtmtest (bind-func memzone-test4 (lambda () (memzone 1024 (* 44100 10) (let ((a:|5,double|* (alloc))) @@ -901,7 +901,7 @@ ;; same amount or whatever new amount you have allocated for closure ;; compilation) ;; -(xtmtest '(bind-func closure-zalloc-test 1000000 +(xtmtest (bind-func closure-zalloc-test 1000000 (let ((k:|100000,double|* (zalloc))) (lambda () (aset! k 0 1.0) @@ -949,7 +949,7 @@ ;; (bind-poly testprint poly-test5) ;; (bind-poly testprint poly-test6) -(xtmtest '(bind-func poly-test7 +(xtmtest (bind-func poly-test7 (lambda () (testprint "extempore's") (testprint "extempore's" "polymorphism") @@ -972,13 +972,13 @@ ;; specialize on [i64,double]* ;; -(xtmtest '(bind-func poly-test10:[i64,double]* +(xtmtest (bind-func poly-test10:[i64,double]* (lambda (a) (+ 1 (sqrd a)))) (poly-test10 5.0)) ;; specialize on [double,doube]* -(xtmtest '(bind-func poly-test11:[double,double]* +(xtmtest (bind-func poly-test11:[double,double]* (lambda (a) (+ 1.0 (sqrd a)))) @@ -995,7 +995,7 @@ (zone_cleanup (println "Clean up before leaving zone!")) tmp2))) -(xtmtest '(bind-func cleanup-test +(xtmtest (bind-func cleanup-test (lambda () (letz ((tmp:i8* (alloc 8)) (t2 (MyLittleCleanupTest))) @@ -1034,7 +1034,7 @@ (vfill! v2 2.0 2.5 2.25 2.125) (* v1 v2)))) -(xtmtest '(bind-func vector-test3 +(xtmtest (bind-func vector-test3 (lambda () (let ((a (vector-test2))) (printf "%f:%f:%f:%f\n" @@ -1091,7 +1091,7 @@ (+ (* p (- (* y f2) y)) y))))) -(xtmtest '(bind-func vector-test4 +(xtmtest (bind-func vector-test4 (lambda () (let ((a:/4,float/* (alloc))) (vfill! a 0.1 0.2 0.3 0.4) @@ -1141,7 +1141,7 @@ ;; (bind-poly print print_v4f64) (xtmtest - '(bind-func vector-test5:[/4,float/]* + (bind-func vector-test5:[/4,float/]* (lambda () (* (vector 1.0 2.0 3.0 4.0) (vector 2.0 2.0 2.0 2.0)))) @@ -1149,7 +1149,7 @@ (call-as-xtlang (println (vector-test5)))) (xtmtest - '(bind-func vector-test6:[/4,float/]* + (bind-func vector-test6:[/4,float/]* (lambda () (* (vector 1.0 2.0 3.0 4.0) 2.0))) @@ -1157,28 +1157,28 @@ (call-as-xtlang (println (vector-test6)))) (xtmtest - '(bind-func vector-test7:[/4,double/]* + (bind-func vector-test7:[/4,double/]* (lambda () (cos (vector 0.0 1.0 2.0 3.0)))) (call-as-xtlang (println (vector-test7)))) (xtmtest - '(bind-func vector-test8:[/4,double/]* + (bind-func vector-test8:[/4,double/]* (lambda () (cos 2.0))) (call-as-xtlang (println (vector-test8)))) (xtmtest - '(bind-func vector-test9:[/4,double/]* + (bind-func vector-test9:[/4,double/]* (lambda () (* (cos 2.0) (log (vector 1.0 2.0 3.0 4.0))))) (call-as-xtlang (println (vector-test9)))) (xtmtest - '(bind-func vector-test10:[/4,double/]* + (bind-func vector-test10:[/4,double/]* (lambda () (pow (vector 1.0 2.0 3.0 4.0) (vector 1.0 2.0 3.0 4.0)))) @@ -1186,7 +1186,7 @@ (call-as-xtlang (println (vector-test10)))) (xtmtest - '(bind-func vector-test11:[/4,double/]* + (bind-func vector-test11:[/4,double/]* (lambda () (pow (vector 1.0 2.0 3.0 4.0) 2.0))) @@ -1208,7 +1208,7 @@ (bind-val GlobalInc [i64,i64]* (testinc 2)) -(xtmtest '(bind-func ginc +(xtmtest (bind-func ginc (lambda () (GlobalInc 5))) (ginc) 7) @@ -1217,20 +1217,20 @@ ;; new xtlang macros (xtmtest - '(bind-func test_inc_macro + (bind-func test_inc_macro (lambda () (let ((x 3)) (inc x 10)))) (test_inc_macro) 13) -(xtmtest '(bind-func test_thread_first1 +(xtmtest (bind-func test_thread_first1 (lambda () (-> "this string is 33 characters long" (strlen) ))) (test_thread_first1) 33) -(xtmtest '(bind-func test_thread_first2 +(xtmtest (bind-func test_thread_first2 (lambda () (-> 1 (+ 2) @@ -1241,7 +1241,7 @@ (sys:load "libs/core/adt.xtm") -(xtmtest '(bind-func test_thread_last1 +(xtmtest (bind-func test_thread_last1 (lambda () (->> (list 1 2 3) (map (lambda (x) (+ x 1))) @@ -1250,7 +1250,7 @@ ))) (test_thread_last1) 2) -(xtmtest '(bind-func test_thread_last2 +(xtmtest (bind-func test_thread_last2 (lambda () (->> 1 (+ 2) @@ -1265,7 +1265,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (xtmtest - '(bind-func lvl1 + (bind-func lvl1 (let ((lvl2 (let ((lvl3 (let ((x 5)) @@ -1283,7 +1283,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (xtmtest - '(bind-func a1_test + (bind-func a1_test (lambda () (let ((a1:|4,float|* (array_ref 5.0:f 6.0 7.0 8.0))) a1))) @@ -1291,7 +1291,7 @@ (xtmX (begin (a1_test) 1))) (xtmtest - '(bind-func a2_test + (bind-func a2_test (lambda () (let ((a1:|4,float| (array 5.0:f 6.0 7.0 8.0))) a1))) @@ -1299,7 +1299,7 @@ (xtmX (begin (a2_test) 1))) (xtmtest - '(bind-func v1_test + (bind-func v1_test (lambda () (let ((a1:/4,float/* (vector_ref 5.0:f 6.0 7.0 8.0))) a1))) @@ -1307,7 +1307,7 @@ (xtmX (begin (v1_test) 1))) (xtmtest - '(bind-func v2_test + (bind-func v2_test (lambda () (let ((a1:/4,float/ (vector 5.0:f 6.0 7.0 8.0))) a1))) @@ -1315,7 +1315,7 @@ (xtmX (begin (v2_test) 1))) (xtmtest - '(bind-func t1_test + (bind-func t1_test (lambda () (let ((a1:* (tuple_ref 5.0:f 'fred 1:i64))) a1))) @@ -1323,7 +1323,7 @@ (xtmX (begin (t1_test) 1))) (xtmtest - '(bind-func t2_test + (bind-func t2_test (lambda () (let ((a1: (tuple 5.0:f 'fred 1:i64))) a1))) diff --git a/tests/external/fft.xtm b/tests/external/fft.xtm index cb25ef449..2d75f41c9 100644 --- a/tests/external/fft.xtm +++ b/tests/external/fft.xtm @@ -11,7 +11,7 @@ (sys:load "libs/external/fft.xtm") -(xtmtest '(bind-func test_fft +(xtmtest (bind-func test_fft (lambda (fft_length printq) (let ((signal:kiss_fft_scalar* (alloc fft_length)) (in:kiss_fft_cpx* (alloc fft_length)) @@ -50,7 +50,7 @@ ;; test real-only ffts -(xtmtest '(bind-func test_fftr +(xtmtest (bind-func test_fftr (lambda (fft_length printq) (let ((signal:kiss_fft_scalar* (zalloc fft_length)) (in:kiss_fft_scalar* (zalloc fft_length)) diff --git a/tests/external/system.xtm b/tests/external/system.xtm index d1fd87815..cf96dd787 100644 --- a/tests/external/system.xtm +++ b/tests/external/system.xtm @@ -13,7 +13,7 @@ (sys:load "libs/external/system.xtm") (xtmtest - '(bind-func test_sys_dir_make + (bind-func test_sys_dir_make (lambda () (sys_dir_make (cat (sys_temp_dir_get) (Str "aprtestdir")) @@ -27,32 +27,32 @@ (test_sys_dir_make) 0) (xtmtest - '(bind-func test_sys_file_rename + (bind-func test_sys_file_rename (lambda () (sys_file_rename (cat (sys_temp_dir_get) (Str "aprtestdir")) (cat (sys_temp_dir_get) (Str "aprtestdir-2"))))) (test_sys_file_rename) 0) (xtmtest - '(bind-func test_sys_dir_remove + (bind-func test_sys_dir_remove (lambda () (sys_dir_remove (cat (sys_temp_dir_get) (Str "aprtestdir-2"))))) (test_sys_dir_remove) 0) (xtmtest - '(bind-func test_sys_env_get + (bind-func test_sys_env_get (lambda () (println (sys_env_get (Str "HOME"))))) (test_sys_env_get)) (xtmtest - '(bind-func test_sys_ls + (bind-func test_sys_ls (lambda () (> (length (sys_ls (sys_env_get (Str "HOME")))) 0))) (test_sys_ls) 1) (xtmtest - '(bind-func test_sys_filepath_root + (bind-func test_sys_filepath_root (lambda () (letz ((res (sys_filepath_root (Str "/path/to/foo.xtm")))) (and (String_equal (car res) (Str "/")) @@ -60,7 +60,7 @@ (test_sys_filepath_root) 1) (xtmtest - '(bind-func test_sys_file_write + (bind-func test_sys_file_write (lambda () (letz ((pool (apr_pool_create)) (file:apr_file_t** (zalloc)) @@ -77,7 +77,7 @@ (test_sys_file_write) 0) (xtmtest - '(bind-func test_sys_file_read + (bind-func test_sys_file_read (lambda () (letz ((pool (apr_pool_create)) (file:apr_file_t** (zalloc)) From a3e232567b692abf8e4aa62731b20f799a07af28 Mon Sep 17 00:00:00 2001 From: Piers Cawley Date: Sun, 17 May 2020 14:55:08 +0100 Subject: [PATCH 7/7] Remove the optional unquote code from xtmtest-* Since we've fixed the tests so they don't quote the 'form' argument, we can remove the belt and braces code that unquoted such forms before expanding the test macros as well. --- libs/core/test.xtm | 57 +++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/libs/core/test.xtm b/libs/core/test.xtm index 4b32d5087..40fd358a7 100644 --- a/libs/core/test.xtm +++ b/libs/core/test.xtm @@ -72,41 +72,32 @@ ;; some tests are supposed to fail compilation (type check catch for example) ;; by passing 'copmile-should-fail as expected-result the failure will be marked as success (define-macro (xtmtest form call . expected-result) - (let ((form (if (and (pair? form) - (eq? 'quote (car form))) - (eval form (interaction-environment)) - form))) - `(let ((func-sym (quote ,(car call))) - (exp-res ,(if (null? expected-result) - #f - (car expected-result)))) - (print-with-colors 'cyan 'default #t (print "xtmtest ")) - (print-with-colors 'black 'cyan #t (print "" func-sym "")) - (println) - (catch (if (and (symbol? exp-res) - (equal? exp-res 'compile-should-fail)) - (xtmtest-update-test-result func-sym 'correct ',call #f #f) - (xtmtest-update-test-result func-sym 'no-compile ',call #f #f)) - (eval ',form (interaction-environment)) - (catch (xtmtest-update-test-result func-sym 'compile ',call #f #f) - (let ((result (eval ',call (interaction-environment)))) - (if (or (not exp-res) (equal? exp-res result)) - (xtmtest-update-test-result func-sym 'correct ',call exp-res result) - (xtmtest-update-test-result func-sym 'incorrect ',call exp-res result)))))))) + `(let ((func-sym (quote ,(car call))) + (exp-res ,(if (null? expected-result) + #f + (car expected-result)))) + (print-with-colors 'cyan 'default #t (print "xtmtest ")) + (print-with-colors 'black 'cyan #t (print "" func-sym "")) + (println) + (catch (if (and (symbol? exp-res) + (equal? exp-res 'compile-should-fail)) + (xtmtest-update-test-result func-sym 'correct ',call #f #f) + (xtmtest-update-test-result func-sym 'no-compile ',call #f #f)) + (eval ',form (interaction-environment)) + (catch (xtmtest-update-test-result func-sym 'compile ',call #f #f) + (let ((result (eval ',call (interaction-environment)))) + (if (or (not exp-res) (equal? exp-res result)) + (xtmtest-update-test-result func-sym 'correct ',call exp-res result) + (xtmtest-update-test-result func-sym 'incorrect ',call exp-res result))))))) (define-macro (xtmtest-compile form) - ;; If we're quoted force unquote - (let ((form (if (and (pair? form) - (eq? 'quote (car form))) - (eval form (interaction-environment)) - form))) - `(let ((func-sym (quote ,(cadr form)))) - (print-with-colors 'cyan 'default #t (print "xtmtest ")) - (print-with-colors 'black 'cyan #t (print "" func-sym "")) - (println) - (catch (xtmtest-update-test-result func-sym 'no-compile 'compile-only #f #f) - (eval ',form (interaction-environment)) - (xtmtest-update-test-result func-sym 'correct 'compile-only #t #t))))) + `(let ((func-sym (quote ,(cadr form)))) + (print-with-colors 'cyan 'default #t (print "xtmtest ")) + (print-with-colors 'black 'cyan #t (print "" func-sym "")) + (println) + (catch (xtmtest-update-test-result func-sym 'no-compile 'compile-only #f #f) + (eval ',form (interaction-environment)) + (xtmtest-update-test-result func-sym 'correct 'compile-only #t #t)))) (define (xtmtest-result-body call expected-result extra) (let ((prefix (if (null? extra) "" (format "~a: " (car extra)))))