Clarify division behavior in tests

This commit is contained in:
Tangent 2024-05-20 20:39:12 -04:00
parent ce991fd12a
commit 7e21e71a07
2 changed files with 37 additions and 14 deletions

View file

@ -10,12 +10,24 @@ describe("expr", () => {
["1 - 2", "-1"],
["1 * 2", "2"],
["1 / 2", "0.5"],
["1 // 2", "0"],
["1 % 2", "1"],
["3 % 2", "1"],
["-1 % 2", "1"],
// TODO: might change this! negative dividend is weird no matter what, but positive modulo is arguably the better call?
["1 % -2", "-1"],
// floored division
["1 // 5", "0"],
["6 // 5", "1"],
["-1 // 5", "-1"],
["-6 // 5", "-2"],
["1 // -5", "-1"],
["6 // -5", "-2"],
["-1 // -5", "0"],
["-6 // -5", "1"],
// floored modulo
["1 % 5", "1"],
["6 % 5", "1"],
["-6 % 5", "4"],
["-1 % 5", "4"],
["1 % -5", "-4"],
["6 % -5", "-4"],
["-6 % -5", "-1"],
["-1 % -5", "-1"],
// TODO: operator precedence
// TODO: parentheses
])("%s", (expression, result) => {