diff options
Diffstat (limited to 'tests/toverflw.nim')
-rwxr-xr-x | tests/toverflw.nim | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/toverflw.nim b/tests/toverflw.nim new file mode 100755 index 000000000..97234d702 --- /dev/null +++ b/tests/toverflw.nim @@ -0,0 +1,18 @@ +# Tests emc's ability to detect overflows + +import + io + +{.push overflowChecks: on.} + +var + a, b: int +a = high(int) +b = -2 +try: + writeln(stdout, b - a) +except EOverflow: + writeln(stdout, "the computation overflowed") + +{.pop.} # overflow check +#OUT the computation overflowed |