diff --git a/clvm/more_ops.py b/clvm/more_ops.py index 43df6cb5..3a3fd95a 100644 --- a/clvm/more_ops.py +++ b/clvm/more_ops.py @@ -176,10 +176,10 @@ def op_div(args): cost += (l0 + l1) * DIV_COST_PER_BYTE q, r = divmod(i0, i1) - # this is to preserve a buggy behavior from the initial implementation - # of this operator. - if q == -1 and r != 0: - q += 1 + if i0 < 0: + raise EvalError("div with negative operand", args.to(i0)) + if i1 < 0: + raise EvalError("div with negative operand", args.to(i1)) return malloc_cost(cost, args.to(q)) diff --git a/setup.py b/setup.py index a1a86be7..c3428e42 100755 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ ] dev_dependencies = [ - "clvm_tools>=0.4.2", + "clvm_tools>=0.4.4", "pytest", ] diff --git a/tests/brun/div-2.txt b/tests/brun/div-2.txt index 995d4353..f090ef70 100644 --- a/tests/brun/div-2.txt +++ b/tests/brun/div-2.txt @@ -1,3 +1,2 @@ brun -c '(/ 2 5)' '(-80001 73)' -cost = 1125 --1096 +FAIL: div with negative operand 0xfec77f diff --git a/tests/brun/div-3.txt b/tests/brun/div-3.txt index 40d589e5..c43412b8 100644 --- a/tests/brun/div-3.txt +++ b/tests/brun/div-3.txt @@ -1,3 +1,2 @@ brun -c '(/ 2 5)' '(80001 -73)' -cost = 1125 --1096 +FAIL: div with negative operand -73 diff --git a/tests/brun/div-7.txt b/tests/brun/div-7.txt index 94ec1d04..5954e5c9 100644 --- a/tests/brun/div-7.txt +++ b/tests/brun/div-7.txt @@ -1,3 +1,2 @@ brun -c '(/ (q . -3) (q . 10))' -cost = 1037 -() +FAIL: div with negative operand -3 diff --git a/tests/brun/div-8.txt b/tests/brun/div-8.txt index c6d9d23f..a5130a51 100644 --- a/tests/brun/div-8.txt +++ b/tests/brun/div-8.txt @@ -1,3 +1,2 @@ brun -c '(/ (q . 3) (q . -10))' -cost = 1037 -() +FAIL: div with negative operand -10 diff --git a/tests/brun/div-9.txt b/tests/brun/div-9.txt index fe3b0b88..aa9169da 100644 --- a/tests/brun/div-9.txt +++ b/tests/brun/div-9.txt @@ -1,3 +1,2 @@ brun -c '(/ (q . -3) (q . -10))' -cost = 1037 -() +FAIL: div with negative operand -3 diff --git a/tests/edge-cases/div-07.txt b/tests/edge-cases/div-07.txt index a8d0f289..499ed6d1 100644 --- a/tests/edge-cases/div-07.txt +++ b/tests/edge-cases/div-07.txt @@ -1,2 +1,2 @@ brun '(/ (q . 0xffff) (q . 0xffff))' -1 +FAIL: div with negative operand -1 diff --git a/tests/edge-cases/div-09.txt b/tests/edge-cases/div-09.txt index 00ce5d2d..c9795b02 100644 --- a/tests/edge-cases/div-09.txt +++ b/tests/edge-cases/div-09.txt @@ -1,2 +1,2 @@ brun '(/ (q . -1) (q . -1))' -1 +FAIL: div with negative operand -1