mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-19 02:00:26 +02:00
Implemented prog1, prog2, dotimes, dolist control structures.
* module/language/elisp/README: Document it and some further ideas written down. * module/language/elisp/compile-tree-il.scm: Implement prog1, dolist. * module/language/elisp/runtime/macro-slot.scm: prog2 and dotimes. * test-suite/tests/elisp-compiler.test: Test prog1, prog2, dotimes, dolist.
This commit is contained in:
parent
f614ca12cd
commit
fb66a47a8e
4 changed files with 105 additions and 7 deletions
|
@ -50,7 +50,19 @@
|
|||
(pass-if-equal "progn" 1
|
||||
(progn (setq a 0)
|
||||
(setq a (1+ a))
|
||||
a)))
|
||||
a))
|
||||
|
||||
(pass-if "prog1"
|
||||
(progn (setq a 0)
|
||||
(setq b (prog1 a (setq a (1+ a))))
|
||||
(and (= a 1) (= b 0))))
|
||||
|
||||
(pass-if "prog2"
|
||||
(progn (setq a 0)
|
||||
(setq b (prog2 (setq a (1+ a))
|
||||
(setq a (1+ a))
|
||||
(setq a (1+ a))))
|
||||
(and (= a 3) (= b 2)))))
|
||||
|
||||
(with-test-prefix/compile "Conditionals"
|
||||
|
||||
|
@ -122,7 +134,18 @@
|
|||
(setq j (1+ i))
|
||||
(setq a (+ a j))))
|
||||
(setq c (dotimes (i 10 42) nil))
|
||||
(and (= a 5050) (equal b nil) (= c 42)))))
|
||||
(and (= a 5050) (equal b nil) (= c 42))))
|
||||
|
||||
(pass-if "dolist"
|
||||
(let ((mylist '(7 2 5)))
|
||||
(setq sum 0)
|
||||
(setq a (dolist (i mylist)
|
||||
(setq sum (+ sum i))))
|
||||
(setq b (dolist (i mylist 5) 0))
|
||||
(and (= sum (+ 7 2 5))
|
||||
(equal a nil)
|
||||
(equal mylist '(7 2 5))
|
||||
(equal b 5)))))
|
||||
|
||||
|
||||
; Test handling of variables.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue