Skip to content

Commit

Permalink
Add hy2py tests for macros and reader macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodiologist committed Apr 19, 2022
1 parent 71ad160 commit 0afcdab
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/resources/pydemo.hy
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
;; This Hy module is intended to concisely demonstrate all of
;; Python's major syntactic features for the purpose of testing hy2py.
;; It also tries out macros and reader macros to ensure they work with
;; hy2py.
"This is a module docstring."

(setv mystring (* "foo" 3))
Expand Down Expand Up @@ -185,3 +187,18 @@ Call me Ishmael. Some years ago—never mind how long precisely—having little
:async item (async-loop ["e" "f"])
item))
values)
(defmacro macaroni [expr]
`[~expr ~expr])
(setv cheese [])
(setv mac-results (macaroni (do
(.append cheese 1)
"x")))
(defreader chicken-strips
(setv expr (.parse-one-form &reader))
`[~expr ~expr])
(setv tendies [])
(setv chicken-results #chicken-strips (do
(.append tendies 2)
"y"))
6 changes: 6 additions & 0 deletions tests/test_hy2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,9 @@ class C:
assert m.py_accum == "01234"

assert asyncio.run(m.coro()) == list("abcdef")

assert m.cheese == [1, 1]
assert m.mac_results == ["x", "x"]

assert m.tendies == [2, 2]
assert m.chicken_results == ["y", "y"]

0 comments on commit 0afcdab

Please sign in to comment.