Add tests for &key arguments in functions
This commit is contained in:
parent
04b2d9d291
commit
5dbf6c6ca9
@ -350,6 +350,11 @@ def test_ast_non_kwapplyable():
|
||||
pass
|
||||
|
||||
|
||||
def test_ast_lambda_lists():
|
||||
"""Ensure the compiler chokes on invalid lambda-lists"""
|
||||
cant_compile('(fn [&key {"a" b} &key {"foo" bar}] [a foo])')
|
||||
|
||||
|
||||
def test_ast_print():
|
||||
code = hy_compile(tokenize("(print \"foo\")")).body[0]
|
||||
|
||||
|
@ -637,6 +637,14 @@
|
||||
(assert (= (foo 10 20 30) [10 (, 20 30) {}])))
|
||||
|
||||
|
||||
(defn test-key-arguments []
|
||||
"NATIVE: test &key function arguments"
|
||||
(defn foo [&key {"a" None "b" 1}] [a b])
|
||||
(assert (= (foo) [None 1]))
|
||||
(assert (= (kwapply (foo) {"a" 2}) [2 1]))
|
||||
(assert (= (kwapply (foo) {"b" 42}) [None 42])))
|
||||
|
||||
|
||||
(defn test-quoted-hoistable []
|
||||
"NATIVE: test quoted hoistable"
|
||||
(setf f (quote (if true true true)))
|
||||
|
Loading…
Reference in New Issue
Block a user