Implement integer division operator

Fixes #107
This commit is contained in:
Konrad Hinsen 2013-04-11 10:09:15 +02:00
parent eee65f3051
commit e3a9909a7e
2 changed files with 6 additions and 0 deletions

View File

@ -708,6 +708,7 @@ class HyASTCompiler(object):
@builds("%")
@builds("-")
@builds("/")
@builds("//")
@builds("*")
@checkargs(min=2)
def compile_maths_expression(self, expression):
@ -717,6 +718,7 @@ class HyASTCompiler(object):
ops = {"+": ast.Add,
"/": ast.Div,
"//": ast.FloorDiv,
"*": ast.Mult,
"-": ast.Sub,
"%": ast.Mod}

View File

@ -29,6 +29,10 @@
"NATIVE: Test division"
(assert (= 25 (/ 100 2 2)))))
(setv test_int_div (fn []
"NATIVE: Test integer division"
(assert (= 25 (// 101 2 2)))))
(defn test-modulo []
"NATIVE: test mod"
(assert (= (% 10 2) 0)))