summary refs log tree commit diff stats
path: root/tests/toverflw.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/toverflw.nim')
-rwxr-xr-xtests/toverflw.nim18
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