Improved division split
This commit is contained in:
22
tests/programs/division-split.q
Normal file
22
tests/programs/division-split.q
Normal file
@ -0,0 +1,22 @@
|
||||
main() {
|
||||
quotient := 0
|
||||
remainder := 0
|
||||
dividend := 256
|
||||
divisor := 100
|
||||
|
||||
quotient, remainder = 256 / 100
|
||||
assert quotient == 2
|
||||
assert remainder == 56
|
||||
|
||||
quotient, remainder = dividend / 100
|
||||
assert quotient == 2
|
||||
assert remainder == 56
|
||||
|
||||
quotient, remainder = 256 / divisor
|
||||
assert quotient == 2
|
||||
assert remainder == 56
|
||||
|
||||
quotient, remainder = dividend / divisor
|
||||
assert quotient == 2
|
||||
assert remainder == 56
|
||||
}
|
8
tests/programs/modulo-assign.q
Normal file
8
tests/programs/modulo-assign.q
Normal file
@ -0,0 +1,8 @@
|
||||
main() {
|
||||
x := 256
|
||||
x %= 100
|
||||
assert x == 56
|
||||
|
||||
x %= 10
|
||||
assert x == 6
|
||||
}
|
9
tests/programs/modulo.q
Normal file
9
tests/programs/modulo.q
Normal file
@ -0,0 +1,9 @@
|
||||
main() {
|
||||
assert 0 % 1 == 0
|
||||
assert 1 % 1 == 0
|
||||
assert 2 % 1 == 0
|
||||
assert 0 % 2 == 0
|
||||
assert 1 % 2 == 1
|
||||
assert 2 % 2 == 0
|
||||
assert 3 % 2 == 1
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
import sys
|
||||
|
||||
main() {
|
||||
if 0 % 1 != 0 {
|
||||
sys.exit(1)
|
||||
}
|
||||
|
||||
if 1 % 1 != 0 {
|
||||
sys.exit(1)
|
||||
}
|
||||
|
||||
if 2 % 1 != 0 {
|
||||
sys.exit(1)
|
||||
}
|
||||
|
||||
if 0 % 2 != 0 {
|
||||
sys.exit(1)
|
||||
}
|
||||
|
||||
if 1 % 2 != 1 {
|
||||
sys.exit(1)
|
||||
}
|
||||
|
||||
if 2 % 2 != 0 {
|
||||
sys.exit(1)
|
||||
}
|
||||
|
||||
if 3 % 2 != 1 {
|
||||
sys.exit(1)
|
||||
}
|
||||
|
||||
x := 256
|
||||
x %= 100
|
||||
|
||||
if x != 56 {
|
||||
sys.exit(1)
|
||||
}
|
||||
|
||||
x %= 10
|
||||
|
||||
if x != 6 {
|
||||
sys.exit(1)
|
||||
}
|
||||
|
||||
sys.exit(0)
|
||||
}
|
Reference in New Issue
Block a user