diff --git a/tests/compilers/test_ast.py b/tests/compilers/test_ast.py index 958c7b8..11d4915 100644 --- a/tests/compilers/test_ast.py +++ b/tests/compilers/test_ast.py @@ -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] diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index d4ec580..9abc43c 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -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)))