Add underflow/overflow tests.
This commit is contained in:
parent
b919ab790b
commit
52c6956d1a
6 changed files with 56 additions and 0 deletions
11
tests/vm/toverflowopcaddimmint.nim
Normal file
11
tests/vm/toverflowopcaddimmint.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "over- or underflow"
|
||||||
|
"""
|
||||||
|
|
||||||
|
static:
|
||||||
|
proc p =
|
||||||
|
var
|
||||||
|
x = int64.high
|
||||||
|
discard x + 1
|
||||||
|
assert false
|
||||||
|
p()
|
||||||
12
tests/vm/toverflowopcaddint.nim
Normal file
12
tests/vm/toverflowopcaddint.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "over- or underflow"
|
||||||
|
"""
|
||||||
|
|
||||||
|
static:
|
||||||
|
proc p =
|
||||||
|
var
|
||||||
|
x = int64.high
|
||||||
|
y = 1
|
||||||
|
discard x + y
|
||||||
|
assert false
|
||||||
|
p()
|
||||||
BIN
tests/vm/toverflowopcmulint
Executable file
BIN
tests/vm/toverflowopcmulint
Executable file
Binary file not shown.
11
tests/vm/toverflowopcmulint.nim
Normal file
11
tests/vm/toverflowopcmulint.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "over- or underflow"
|
||||||
|
"""
|
||||||
|
|
||||||
|
static:
|
||||||
|
proc p =
|
||||||
|
var
|
||||||
|
x = 1 shl 62
|
||||||
|
discard x * 2
|
||||||
|
assert false
|
||||||
|
p()
|
||||||
10
tests/vm/toverflowopcsubimmint.nim
Normal file
10
tests/vm/toverflowopcsubimmint.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "over- or underflow"
|
||||||
|
"""
|
||||||
|
|
||||||
|
static:
|
||||||
|
proc p =
|
||||||
|
var x = int64.low
|
||||||
|
discard x - 1
|
||||||
|
assert false
|
||||||
|
p()
|
||||||
12
tests/vm/toverflowopcsubint.nim
Normal file
12
tests/vm/toverflowopcsubint.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "over- or underflow"
|
||||||
|
"""
|
||||||
|
|
||||||
|
static:
|
||||||
|
proc p =
|
||||||
|
var
|
||||||
|
x = int64.low
|
||||||
|
y = 1
|
||||||
|
discard x - y
|
||||||
|
assert false
|
||||||
|
p()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue