From 71bfa9094a4a25f762d681bb07f79f92a95dbb87 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Sun, 6 Sep 2026 17:40:51 -0400 Subject: pit: Fix evaluator bug --- pit/test/array.lisp | 2 -- pit/test/array.pit | 2 ++ pit/test/broken.lisp | 5 ----- pit/test/broken.pit | 5 +++++ pit/test/fold.lisp | 12 ------------ pit/test/fold.pit | 12 ++++++++++++ pit/test/nonbroken.lisp | 2 -- pit/test/nonbroken.pit | 2 ++ pit/test/struct.lisp | 11 ----------- pit/test/struct.pit | 11 +++++++++++ pit/test/test.lisp | 22 ---------------------- pit/test/test.pit | 22 ++++++++++++++++++++++ pit/test/test10.pit | 5 +++++ pit/test/test11.pit | 4 ++++ pit/test/test2.lisp | 1 - pit/test/test2.pit | 1 + pit/test/test3.lisp | 7 ------- pit/test/test3.pit | 7 +++++++ pit/test/test5.pit | 3 ++- pit/test/thebug.lisp | 9 --------- pit/test/thebug.pit | 9 +++++++++ pit/test/thebug2.lisp | 13 ------------- pit/test/thebug2.pit | 13 +++++++++++++ pit/test/y.lisp | 5 ----- pit/test/y.pit | 5 +++++ 25 files changed, 100 insertions(+), 90 deletions(-) delete mode 100644 pit/test/array.lisp create mode 100644 pit/test/array.pit delete mode 100644 pit/test/broken.lisp create mode 100644 pit/test/broken.pit delete mode 100644 pit/test/fold.lisp create mode 100644 pit/test/fold.pit delete mode 100644 pit/test/nonbroken.lisp create mode 100644 pit/test/nonbroken.pit delete mode 100644 pit/test/struct.lisp create mode 100644 pit/test/struct.pit delete mode 100644 pit/test/test.lisp create mode 100644 pit/test/test.pit create mode 100644 pit/test/test10.pit create mode 100644 pit/test/test11.pit delete mode 100644 pit/test/test2.lisp create mode 100644 pit/test/test2.pit delete mode 100644 pit/test/test3.lisp create mode 100644 pit/test/test3.pit delete mode 100644 pit/test/thebug.lisp create mode 100644 pit/test/thebug.pit delete mode 100644 pit/test/thebug2.lisp create mode 100644 pit/test/thebug2.pit delete mode 100644 pit/test/y.lisp create mode 100644 pit/test/y.pit (limited to 'pit/test') diff --git a/pit/test/array.lisp b/pit/test/array.lisp deleted file mode 100644 index 976f70d..0000000 --- a/pit/test/array.lisp +++ /dev/null @@ -1,2 +0,0 @@ -(print! (array/repeat 'foo 1000)) -(array/repeat 'foo 10000) diff --git a/pit/test/array.pit b/pit/test/array.pit new file mode 100644 index 0000000..976f70d --- /dev/null +++ b/pit/test/array.pit @@ -0,0 +1,2 @@ +(print! (array/repeat 'foo 1000)) +(array/repeat 'foo 10000) diff --git a/pit/test/broken.lisp b/pit/test/broken.lisp deleted file mode 100644 index 09f4afc..0000000 --- a/pit/test/broken.lisp +++ /dev/null @@ -1,5 +0,0 @@ -;; (let ((foo (+ 1 1))) -;; (print! foo)) -((lambda (foo) - (print! foo)) - (+ 1 1)) diff --git a/pit/test/broken.pit b/pit/test/broken.pit new file mode 100644 index 0000000..09f4afc --- /dev/null +++ b/pit/test/broken.pit @@ -0,0 +1,5 @@ +;; (let ((foo (+ 1 1))) +;; (print! foo)) +((lambda (foo) + (print! foo)) + (+ 1 1)) diff --git a/pit/test/fold.lisp b/pit/test/fold.lisp deleted file mode 100644 index 89031d0..0000000 --- a/pit/test/fold.lisp +++ /dev/null @@ -1,12 +0,0 @@ -(defun! foo (x) - (+ x 1)) -(print! (foo 1)) -(print! (funcall 'foo 1)) -(print! (list/map 'foo '(1 2 3))) -(print! (list/foldl '+ 0 '(1 2 3))) -(print! (list/take 2 '(1 2 3))) -(print! (list/take 0 '(1 2 3))) -(print! (list/take 100 '(1 2 3))) -(print! (list/drop 2 '(1 2 3))) -(print! (list/drop 10 '(1 2 3))) -(print! (list/filter 'integer? '(1 foo 2 bar baz 3 quux))) diff --git a/pit/test/fold.pit b/pit/test/fold.pit new file mode 100644 index 0000000..89031d0 --- /dev/null +++ b/pit/test/fold.pit @@ -0,0 +1,12 @@ +(defun! foo (x) + (+ x 1)) +(print! (foo 1)) +(print! (funcall 'foo 1)) +(print! (list/map 'foo '(1 2 3))) +(print! (list/foldl '+ 0 '(1 2 3))) +(print! (list/take 2 '(1 2 3))) +(print! (list/take 0 '(1 2 3))) +(print! (list/take 100 '(1 2 3))) +(print! (list/drop 2 '(1 2 3))) +(print! (list/drop 10 '(1 2 3))) +(print! (list/filter 'integer? '(1 foo 2 bar baz 3 quux))) diff --git a/pit/test/nonbroken.lisp b/pit/test/nonbroken.lisp deleted file mode 100644 index 350f64f..0000000 --- a/pit/test/nonbroken.lisp +++ /dev/null @@ -1,2 +0,0 @@ -(+ 1 - (fwefwfwfwe 1 1)) diff --git a/pit/test/nonbroken.pit b/pit/test/nonbroken.pit new file mode 100644 index 0000000..350f64f --- /dev/null +++ b/pit/test/nonbroken.pit @@ -0,0 +1,2 @@ +(+ 1 + (fwefwfwfwe 1 1)) diff --git a/pit/test/struct.lisp b/pit/test/struct.lisp deleted file mode 100644 index 9e35654..0000000 --- a/pit/test/struct.lisp +++ /dev/null @@ -1,11 +0,0 @@ -(defstruct! foo - x - y - z) - -(setq! x (foo/new :y 10 :x 5 :z 111)) -(print! x) -(print! (foo/get-y x)) -(foo/set-y! x 42) -(print! (foo/get-y x)) -(print! (foo/get-z x)) diff --git a/pit/test/struct.pit b/pit/test/struct.pit new file mode 100644 index 0000000..9e35654 --- /dev/null +++ b/pit/test/struct.pit @@ -0,0 +1,11 @@ +(defstruct! foo + x + y + z) + +(setq! x (foo/new :y 10 :x 5 :z 111)) +(print! x) +(print! (foo/get-y x)) +(foo/set-y! x 42) +(print! (foo/get-y x)) +(print! (foo/get-z x)) diff --git a/pit/test/test.lisp b/pit/test/test.lisp deleted file mode 100644 index ef13abb..0000000 --- a/pit/test/test.lisp +++ /dev/null @@ -1,22 +0,0 @@ -(print! (list/map (lambda (x) (+ x 1)) (list 1 2 3 4 5))) -(print! (eval! '(cons 1 2))) -(defun! say-hi () - (princ! "hello computer")) -(say-hi) -(setq! counter 42) -(let ((counter 0)) - (print! counter) - (fset! 'count (lambda () (setq! counter (+ counter 1)))) - (fset! 'query (lambda () counter))) -(print! (count)) (print! (query)) -(print! (count)) (print! (query)) -(defun! bar (x & xs) - (print! x) - (print! xs)) -(bar 1 2 3 4 5) -(defun! baz (& kwargs) - (print! kwargs) - (let ((foo (plist/get :foo kwargs)) - (bar (plist/get :bar kwargs))) - bar)) -(print! (baz :foo 10 :bar 5 :baz 3)) diff --git a/pit/test/test.pit b/pit/test/test.pit new file mode 100644 index 0000000..ef13abb --- /dev/null +++ b/pit/test/test.pit @@ -0,0 +1,22 @@ +(print! (list/map (lambda (x) (+ x 1)) (list 1 2 3 4 5))) +(print! (eval! '(cons 1 2))) +(defun! say-hi () + (princ! "hello computer")) +(say-hi) +(setq! counter 42) +(let ((counter 0)) + (print! counter) + (fset! 'count (lambda () (setq! counter (+ counter 1)))) + (fset! 'query (lambda () counter))) +(print! (count)) (print! (query)) +(print! (count)) (print! (query)) +(defun! bar (x & xs) + (print! x) + (print! xs)) +(bar 1 2 3 4 5) +(defun! baz (& kwargs) + (print! kwargs) + (let ((foo (plist/get :foo kwargs)) + (bar (plist/get :bar kwargs))) + bar)) +(print! (baz :foo 10 :bar 5 :baz 3)) diff --git a/pit/test/test10.pit b/pit/test/test10.pit new file mode 100644 index 0000000..0eea605 --- /dev/null +++ b/pit/test/test10.pit @@ -0,0 +1,5 @@ +(list/find + (lambda (y) + (and (eq? (list/len y) 3) + (list/all? (lambda (x) (equal? x 2)) y))) + '((1 2 3) (2 2 2 2) (2 3 4) (2 2 2))) \ No newline at end of file diff --git a/pit/test/test11.pit b/pit/test/test11.pit new file mode 100644 index 0000000..83d4816 --- /dev/null +++ b/pit/test/test11.pit @@ -0,0 +1,4 @@ +(print! 'here) +(list/foldl '+ 0 '(1 2 3)) +(print! 'there) +(print! (list/foldl '+ 0 '(1 2 3))) \ No newline at end of file diff --git a/pit/test/test2.lisp b/pit/test/test2.lisp deleted file mode 100644 index 79a9791..0000000 --- a/pit/test/test2.lisp +++ /dev/null @@ -1 +0,0 @@ -(print "hello from test2") diff --git a/pit/test/test2.pit b/pit/test/test2.pit new file mode 100644 index 0000000..79a9791 --- /dev/null +++ b/pit/test/test2.pit @@ -0,0 +1 @@ +(print "hello from test2") diff --git a/pit/test/test3.lisp b/pit/test/test3.lisp deleted file mode 100644 index 2febb75..0000000 --- a/pit/test/test3.lisp +++ /dev/null @@ -1,7 +0,0 @@ -(let ((bs (bs/new!))) - (print! bs) - (bs/grow! 1 bs) - (bs/write8! bs 0 67) - (bs/spit! "test3.bin" bs) - ;; (bs/delete! bs) - ) diff --git a/pit/test/test3.pit b/pit/test/test3.pit new file mode 100644 index 0000000..2febb75 --- /dev/null +++ b/pit/test/test3.pit @@ -0,0 +1,7 @@ +(let ((bs (bs/new!))) + (print! bs) + (bs/grow! 1 bs) + (bs/write8! bs 0 67) + (bs/spit! "test3.bin" bs) + ;; (bs/delete! bs) + ) diff --git a/pit/test/test5.pit b/pit/test/test5.pit index 3ea3fc7..2ad3675 100644 --- a/pit/test/test5.pit +++ b/pit/test/test5.pit @@ -1,5 +1,6 @@ (defun! foo (x) - (print! x) + (if (equal? 0 (% x 10000)) + (print! x)) (foo (+ x 1))) (foo 0) \ No newline at end of file diff --git a/pit/test/thebug.lisp b/pit/test/thebug.lisp deleted file mode 100644 index ad87bd7..0000000 --- a/pit/test/thebug.lisp +++ /dev/null @@ -1,9 +0,0 @@ -(defun! foo (x) - (lambda (y) - (+ x y))) - -(setq! bar (foo 10)) -(setq! baz (foo 100)) - -(print! (funcall bar 4)) - diff --git a/pit/test/thebug.pit b/pit/test/thebug.pit new file mode 100644 index 0000000..ad87bd7 --- /dev/null +++ b/pit/test/thebug.pit @@ -0,0 +1,9 @@ +(defun! foo (x) + (lambda (y) + (+ x y))) + +(setq! bar (foo 10)) +(setq! baz (foo 100)) + +(print! (funcall bar 4)) + diff --git a/pit/test/thebug2.lisp b/pit/test/thebug2.lisp deleted file mode 100644 index 2376ff8..0000000 --- a/pit/test/thebug2.lisp +++ /dev/null @@ -1,13 +0,0 @@ - -(setq! z 40) -(setq! f - (lambda (x) - (lambda (y) - (lambda (w) - (+ - (funcall (lambda (z) (+ x y z)) 3) - w - z))))) -(let ((z 20)) - (print! (funcall (funcall (funcall f 1) 2) 3))) - diff --git a/pit/test/thebug2.pit b/pit/test/thebug2.pit new file mode 100644 index 0000000..2376ff8 --- /dev/null +++ b/pit/test/thebug2.pit @@ -0,0 +1,13 @@ + +(setq! z 40) +(setq! f + (lambda (x) + (lambda (y) + (lambda (w) + (+ + (funcall (lambda (z) (+ x y z)) 3) + w + z))))) +(let ((z 20)) + (print! (funcall (funcall (funcall f 1) 2) 3))) + diff --git a/pit/test/y.lisp b/pit/test/y.lisp deleted file mode 100644 index 5e9218b..0000000 --- a/pit/test/y.lisp +++ /dev/null @@ -1,5 +0,0 @@ -(setq! Y - (lambda (f) - (funcall - (lambda (x) (funcall f (funcall x x))) - (lambda (x) (funcall f (funcall x x)))))) diff --git a/pit/test/y.pit b/pit/test/y.pit new file mode 100644 index 0000000..5e9218b --- /dev/null +++ b/pit/test/y.pit @@ -0,0 +1,5 @@ +(setq! Y + (lambda (f) + (funcall + (lambda (x) (funcall f (funcall x x))) + (lambda (x) (funcall f (funcall x x)))))) -- cgit v1.3.1