diff --git a/hy/compiler.py b/hy/compiler.py index d1d4772..9b1c337 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -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} diff --git a/tests/native_tests/math.hy b/tests/native_tests/math.hy index 2310905..8570ceb 100644 --- a/tests/native_tests/math.hy +++ b/tests/native_tests/math.hy @@ -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)))