hy/tests/native_tests/reader_macros.hy
Foxboron c9fdd40c9f Hy reader macros #377
Added first iteration of reader macros
Refactored defmacro and defreader
Added test inn hy/tests/lex/test_lex.py
Added new test in hy/tests/native/tests
Added new test in hy/tests/macros.

changed the error given in the dispatch macro and added some handling for missing symbol and invalid characters
2013-12-23 14:33:51 +01:00

33 lines
638 B
Hy

(defn test-reader-macro []
"Test a basic redaer macro"
(defreader ^ [expr]
expr)
(assert (= #^"works" "works")))
(defn test-reader-macro-expr []
"Test basic exprs like lists and arrays"
(defreader n [expr]
(get expr 1))
(assert (= #n[1 2] 2))
(assert (= #n(1 2) 2)))
(defn test-reader-macro-override []
"Test if we can override function symbols"
(defreader + [n]
(+ n 1))
(assert (= #+2 3)))
(defn test-reader-macro-compile-docstring []
"Test if we can compile with a docstring"
(try
(defreader d []
"Compiles with docstrings")
(except [Exception]
(assert False))))