From acc561366f3fe6ec0377103f52ef0f7e923711c9 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Mon, 1 Aug 2022 19:35:19 -0700 Subject: Modify the project structure. Now the lib directory contains what will eventually end up on the user's /usr/lib/csc. When I write make install, it will copy all of the .csc files from lib into the destination lib directory. This means I can start working on the standard library in lib/scheme. --- csc/loop-test.csc | 294 ------------------------------------------------------ 1 file changed, 294 deletions(-) delete mode 100644 csc/loop-test.csc (limited to 'csc/loop-test.csc') diff --git a/csc/loop-test.csc b/csc/loop-test.csc deleted file mode 100644 index 50090e0..0000000 --- a/csc/loop-test.csc +++ /dev/null @@ -1,294 +0,0 @@ -(define-library (csc loop-test) - (import (scheme base) - (only (csc format) printf) - (only (csc testing) - assert-equal - test) - (csc loop)) - (begin - - - (test loop-for-collect - (assert-equal - '(1 2 3 4 5) - (loop for x in '(1 2 3 4 5) - collect x))) - - - (test loop-for-collect-add - (assert-equal - '(2 3 4 5 6) - (loop for x in '(1 2 3 4 5) - collect (+ 1 x)))) - - - (test loop-collect-nothing - (assert-equal - '() - (loop for x in '() - collect x))) - - - (test loop-for-arithmetic - (assert-equal - '(1 2 3 4 5) - (loop for x from 1 to 5 - collect x))) - - - (test loop-for-arithmetic-step - (assert-equal - '(1 3 5 7 9) - (loop for x from 1 to 10 by 2 - collect x))) - - - (test loop-finally-noop - (assert-equal - '(1 2 3) - (loop for x from 1 to 3 - finally (if #f #f) - collect x))) - - - (test loop-collect-into - (assert-equal - '((1 2 3) (1 2 3) (1 2 3)) - (loop for x from 1 to 3 - collect x into l - collect l))) - - - (test loop-finally-set - (assert-equal - '(1 2 3) - (let ((res #f)) - (loop for x from 1 to 3 - collect x into l - finally (set! res l)) - res))) - - - (test loop-do - (assert-equal - '(3 2 1) - (let ((res '())) - (loop for x from 1 to 3 - do (set! res (cons x res))) - res))) - - - (test loop-return - (assert-equal - '(1 2 3) - (loop do (return '(1 2 3))))) - - - (test loop-finally-return - (assert-equal - '(1 2 3) - (loop for x from 1 to 3 - collect x into l - finally (return l)))) - - - (test loop-for-as-equals-then - (assert-equal - '((1 2 3) (2 3) (3)) - (loop for i from 1 to 3 - for tail = '(1 2 3) then (cdr tail) - collect tail))) - - - (test loop-for-as-equals - (assert-equal - '((1) (2) (3)) - (loop for i from 1 to 3 - for j = (list i) - collect j))) - - - (test loop-return-multiple-values - (let-values (((x1 x2) (loop do (return (values 1 2))))) - (assert-equal - 1 - x1) - (assert-equal - 2 - x2))) - - - (test nested-loops - (assert-equal - '(1 2 3) - (loop do (define x (loop do (return '(1 2 3)))) - (return x)))) - - - (test loop-with-return - (assert-equal - 5 - (loop with x = 5 - return x))) - - - (test loop-for-x-on-l - (assert-equal - '((1 2 3) (2 3) (3)) - (loop for x on '(1 2 3) - collect x))) - - - (test loop-for-across - (assert-equal - '(1 2 3) - (loop for x across #(1 2 3) - collect x))) - - - (test loop-for-downfrom - (assert-equal - '(3 2 1) - (loop for x to 1 downfrom 3 - collect x))) - - - (test loop-for-to - (assert-equal - '(0 1 2 3) - (loop for x to 3 - collect x))) - - - (test loop-for-downto - (assert-equal - '(3 2 1) - (loop for x downto 1 from 3 - collect x))) - - - (test loop-for-below - (assert-equal - '(0 1 2) - (loop for x below 3 - collect x))) - - - (test loop-for-above - (assert-equal - '(3 2 1) - (loop for x above 0 from 3 - collect x))) - - - (test loop-for-by - (assert-equal - '(0 2 4) - (loop for x by 2 to 4 - collect x))) - - - (test loop-append - (assert-equal - '(1 2 3 4) - (loop for x in '((1 2) (3 4)) - append x))) - - - (test loop-count - (assert-equal - 50 - (loop for x from 1 to 100 - count (even? x)))) - - - (test loop-sum - (assert-equal - 15 - (loop for x from 1 to 5 - sum x))) - - - (test loop-maximize - (assert-equal - 10 - (loop for x in '(3 10 1 4) - maximize x))) - - - (test loop-maximize-none - (assert-equal - 0 - (loop for x in '() - maximize x))) - - - (test loop-minimize - (assert-equal - 1 - (loop for x in '(3 10 1 4) - minimize x))) - - - (test loop-minimize-none - (assert-equal - 0 - (loop for x in '() - minimize x))) - - - (test loop-if - (assert-equal - 5 - (loop for x from 0 - if (>= x 5) return x))) - - - (test loop-when - (assert-equal - 5 - (loop for x from 0 - when (>= x 5) return x))) - - - (test loop-else - (assert-equal - '((0 2 4) . (1 3 5)) - (loop for x to 5 - if (even? x) collect x into evens - else collect x into odds - finally (return (cons evens odds))))) - - - (test loop-if-compound - (assert-equal - '((0 2 4) . (1 3 5)) - (loop for x to 5 - if (even? x) collect x into list1 - and collect (+ 1 x) into list2 - finally (return (cons list1 list2))))) - - - (test loop-if-end - (assert-equal - 5 - (loop for x from 0 - if (>= x 5) return x end))) - - - (test loop-if-collect-and - (assert-equal - '(1 2 3 4 5 6 7 8 9 10) - (loop for i from 1 to 10 - if (odd? i) - collect i - and collect (+ 1 i)))) - - - (test loop-collect-advanced - (assert-equal - '(fred bob ken sue alice joe kris sunshine june) - (loop for name in '(fred sue alice joe june) - for kids in '((bob ken) () () (kris sunshine) ()) - collect name - append kids))))) -- cgit v1.3.1