summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-05-05 20:23:38 +0800
committerGitHub <noreply@github.com>2023-05-05 14:23:38 +0200
commit07233ceca0fa220418f1691e70c9e8d49e440737 (patch)
treec877f95eb850b0333c6cb58ca2612237609551b1 /tests
parent724866b14fad9398d1d003839037fe7cb21547eb (diff)
downloadNim-07233ceca0fa220418f1691e70c9e8d49e440737.tar.gz
fixes #21792; enable checks for sum, prod, cumsummed and cumsum (#21793)
* enable checks for sum, prod, cumsummed  and cumsum

* fixes #21792

* add test cases
Diffstat (limited to 'tests')
-rw-r--r--tests/stdlib/tmath.nim16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/stdlib/tmath.nim b/tests/stdlib/tmath.nim
index 8ddb09bf5..2076a6eff 100644
--- a/tests/stdlib/tmath.nim
+++ b/tests/stdlib/tmath.nim
@@ -439,6 +439,20 @@ template main() =
       doAssert lgamma(-0.0) == Inf
       doAssert lgamma(-1.0) == Inf
 
-
 static: main()
 main()
+
+when not defined(js) and not defined(danger):
+  block: # bug #21792
+    block:
+      type Digit = 0..9
+      var x = [Digit 4, 7]
+
+      doAssertRaises(RangeDefect):
+        discard sum(x)
+
+    block:
+      var x = [int8 124, 127]
+
+      doAssertRaises(OverflowDefect):
+        discard sum(x)