Merge pull request #110 from khinsen/integer_division
Implement integer division operator
This commit is contained in:
commit
a729b52155
@ -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}
|
||||
|
@ -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)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user