diff --git a/hy/compiler.py b/hy/compiler.py index 6d29418..7cd7362 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -92,8 +92,25 @@ class HyASTCompiler(object): col_offset=e.start_column) @builds("=") + @builds("<") + @builds("<=") + @builds(">") + @builds(">=") + @builds("is") + @builds("in") + @builds("is-not") + @builds("not-in") def compile_compare_op_expression(self, expression): - ops = {"=": ast.Eq} + # NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn + ops = {"=": ast.Eq, + "<": ast.Lt, + "<=": ast.LtE, + ">": ast.Gt, + ">=": ast.GtE, + "is": ast.Is, + "is-not": ast.IsNot, + "in": ast.In, + "not-in": ast.NotIn} inv = expression.pop(0) op = ops[inv] diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index c4b808d..3ae92bf 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -12,3 +12,25 @@ (for [x [1 2 3 4 5]] (def count (+ count x))) (assert (= count 15))) + + +(defn test_in [] + "NATIVE: test in" + (assert (in "a" ["a" "b" "c" "d"])) + (assert (not-in "f" ["a" "b" "c" "d"]))) + + +(defn test_numops [] + "NATIVE: test numpos" + (assert (> 5 4 3 2 1)) + (assert (< 1 2 3 4 5)) + (assert (<= 5 5 5 5 )) + (assert (>= 5 5 5 5 ))) + + +; implement null +;(defn test_is [] +; "NATIVE: test is" +; (def a null) +; (assert (is a null)) +; (assert (is-not a "b")))