1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-17 17:20:29 +02:00

Implemented catch and throw in elisp.

* module/language/elisp/README: Document this.
* module/language/elisp/compile-tree-il.scm: Implement catch and throw.
* test-suite/tests/elisp-compiler.test: Test catch/throw.
This commit is contained in:
Daniel Kraft 2009-07-22 12:23:03 +02:00
parent 5d221ca375
commit 35b2e41d6d
3 changed files with 65 additions and 3 deletions

View file

@ -147,6 +147,28 @@
(equal mylist '(7 2 5))
(equal b 5)))))
(with-test-prefix/compile "Exceptions"
(pass-if "catch without exception"
(and (setq a 0)
(= (catch 'foobar
(setq a (1+ a))
(setq a (1+ a))
a)
2)
(= (catch (+ 1 2) a) 2)))
; FIXME: Figure out how to do this...
;(pass-if-exception "uncaught exception" 'elisp-exception
; (throw 'abc 1))
(pass-if "catch and throw"
(and (setq mylist '(1 2))
(= (catch 'abc (throw 'abc 2) 1) 2)
(= (catch 'abc (catch 'def (throw 'abc 1) 2) 3) 1)
(= (catch 'abc (catch 'def (throw 'def 1) 2) 3) 3)
(= (catch mylist (catch '(1 2) (throw mylist 1) 2) 3) 1))))
; Test handling of variables.
; ===========================