c9fdd40c9f
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
33 lines
638 B
Hy
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))))
|