mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
Add underflow/overflow tests.
This commit is contained in:
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()
|
||||
Reference in New Issue
Block a user