Skip to content

Commit

Permalink
Simplify modulo tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Demian Ferreiro committed Jan 24, 2014
1 parent 1288786 commit 6a43de7
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions test/operators.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,9 @@ test "floor division operator compound assignment", ->

test "modulo operator", ->
check = (a, b, expected) ->
res = a %% b
# Don't use eq because it treats 0 as different to -0.
ok res == expected or isNaN(res) and isNaN(expected),
"expected #{a} %%%% #{b} to be #{expected}"
eq expected, a %% b, "expected #{a} %%%% #{b} to be #{expected}"
check 0, 1, 0
check 0, -1, 0
check 0, -1, -0
check 1, 0, NaN
check 1, 2, 1
check 1, -2, -1
Expand Down

0 comments on commit 6a43de7

Please sign in to comment.