add mod operator

This commit is contained in:
Paul R. Tagliamonte 2013-03-18 21:46:58 -04:00
parent a0ff144686
commit a94831beac
2 changed files with 7 additions and 1 deletions

View File

@ -341,6 +341,7 @@ class HyASTCompiler(object):
col_offset=e.start_column)
@builds("+")
@builds("%")
@builds("-")
@builds("/")
@builds("*")
@ -352,7 +353,8 @@ class HyASTCompiler(object):
ops = {"+": ast.Add,
"/": ast.Div,
"*": ast.Mult,
"-": ast.Sub}
"-": ast.Sub,
"%": ast.Mod}
inv = expression.pop(0)
op = ops[inv]

View File

@ -28,3 +28,7 @@
(def test_div (fn []
"NATIVE: Test division"
(assert (= 25 (/ 100 2 2)))))
(defn test-modulo []
"NATIVE: test mod"
(assert (= (% 10 2) 0)))