adding a bit more coverage
This commit is contained in:
parent
db39a81a30
commit
7c7a613c9c
@ -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]
|
||||
|
@ -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")))
|
||||
|
Loading…
x
Reference in New Issue
Block a user