forked from arendst/Tasmota
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Berry upstream fix mod 0 (arendst#21174)
* Berry upstream fix mod 0 * Add test case
- Loading branch information
1 parent
a2ad349
commit 105aa03
Showing
2 changed files
with
76 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
try | ||
# Test integer division | ||
var div = 1/0 | ||
assert(false) # Should not reach this point | ||
except .. as e,m | ||
|
||
assert(e == "divzero_error") | ||
assert(m == "division by zero") | ||
end | ||
|
||
|
||
try | ||
# Test integer modulo | ||
var div = 1%0 | ||
assert(false) | ||
except .. as e,m | ||
assert(e == "divzero_error") | ||
assert(m == "division by zero") | ||
end | ||
|
||
try | ||
# Test float division | ||
var div = 1.1/0.0 | ||
assert(false) | ||
except .. as e,m | ||
assert(e == "divzero_error") | ||
assert(m == "division by zero") | ||
end | ||
|
||
try | ||
# Test float modulo | ||
var div = 1.1%0.0 | ||
assert(false) | ||
except .. as e,m | ||
assert(e == "divzero_error") | ||
assert(m == "division by zero") | ||
end | ||
|
||
|
||
# Check normal division & modulo | ||
assert(1/2 == 0) | ||
assert(1%2 == 1) | ||
assert(1.0/2.0 == 0.5) | ||
assert(1.0%2.0 == 1.0) | ||
assert(4/2 == 2) | ||
assert(4%2 == 0) |