summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-09-02 22:03:10 +0200
committerAndreas Rumpf <rumpf_a@web.de>2019-09-02 22:03:10 +0200
commitac6fcab7a4fc79ba0ca45f531ad5f4f213e9d4e7 (patch)
tree54f03ebd8539f4562d4e2f077d67812aea854889 /tests
parentd70e292571754f1c00baf9651c558378537cdba8 (diff)
parent5a03eea518ba3cfeaa9f57ef0b6f1cf7bc8ed1d9 (diff)
downloadNim-ac6fcab7a4fc79ba0ca45f531ad5f4f213e9d4e7.tar.gz
Merge branch 'devel' into uint-range-checks
Diffstat (limited to 'tests')
-rw-r--r--tests/ccgbugs/tnil_type.nim3
-rw-r--r--tests/destructor/tnewruntime_misc.nim13
-rw-r--r--tests/range/trange.nim6
-rw-r--r--tests/system/tsystem_misc.nim12
-rw-r--r--tests/template/tparams_gensymed.nim19
5 files changed, 49 insertions, 4 deletions
diff --git a/tests/ccgbugs/tnil_type.nim b/tests/ccgbugs/tnil_type.nim
index 12310dae9..9921b24a3 100644
--- a/tests/ccgbugs/tnil_type.nim
+++ b/tests/ccgbugs/tnil_type.nim
@@ -13,6 +13,3 @@ f3(typeof(nil))
 
 proc f4[T](_: T) = discard
 f4(nil)
-
-proc f5(): typeof(nil) = nil
-discard f5()
diff --git a/tests/destructor/tnewruntime_misc.nim b/tests/destructor/tnewruntime_misc.nim
index d6c03b9b0..8abf0d30b 100644
--- a/tests/destructor/tnewruntime_misc.nim
+++ b/tests/destructor/tnewruntime_misc.nim
@@ -85,3 +85,16 @@ testWrongAt()
 
 let (a, d) = allocCounters()
 discard cprintf("%ld  new: %ld\n", a - unpairedEnvAllocs() - d, allocs)
+
+#-------------------------------------------------
+type
+  Table[A, B] = object
+    x: seq[(A, B)]
+
+
+proc toTable[A,B](p: sink openArray[(A, B)]): Table[A, B] = 
+  for zz in mitems(p):
+    result.x.add move(zz)
+
+
+let table = {"a": new(int)}.toTable()
diff --git a/tests/range/trange.nim b/tests/range/trange.nim
index aac967777..c864387f6 100644
--- a/tests/range/trange.nim
+++ b/tests/range/trange.nim
@@ -136,3 +136,9 @@ block:
     const x11: range[0'f..1'f] = 2'f
   reject:
     const x12: range[0'f..1'f] = 2
+
+# ensure unsigned array indexing is remains lenient:
+var a: array[4'u, string]
+
+for i in 0..<a.len:
+  a[i] = "foo"
diff --git a/tests/system/tsystem_misc.nim b/tests/system/tsystem_misc.nim
index 9dcd9ac9f..38be01a13 100644
--- a/tests/system/tsystem_misc.nim
+++ b/tests/system/tsystem_misc.nim
@@ -160,7 +160,6 @@ block: # `$`*[T: tuple|object](x: T)
   doAssert $Foo(x:2) == "(x: 2, x2: 0.0)"
   doAssert $() == "()"
 
-
 # this is a call indirection to prevent `toInt` to be resolved at compile time.
 proc testToInt(arg: float64, a: int, b: BiggestInt) =
   doAssert toInt(arg) == a
@@ -174,3 +173,14 @@ testToInt(13.37, 13, 13)    # should round towards 0
 testToInt(-13.37, -13, -13) # should round towards 0
 testToInt(7.8, 8, 8)     # should round away from 0
 testToInt(-7.8, -8, -8)  # should round away from 0
+
+# test min/max for correct NaN handling
+
+proc testMinMax(a,b: float32) =
+  doAssert max(float32(a),float32(b)) == 0'f32
+  doAssert min(float32(a),float32(b)) == 0'f32
+  doAssert max(float64(a),float64(b)) == 0'f64
+  doAssert min(float64(a),float64(b)) == 0'f64
+
+testMinMax(0.0, NaN)
+testMinMax(NaN, 0.0)
diff --git a/tests/template/tparams_gensymed.nim b/tests/template/tparams_gensymed.nim
index f7a02efa0..fe5608add 100644
--- a/tests/template/tparams_gensymed.nim
+++ b/tests/template/tparams_gensymed.nim
@@ -9,6 +9,11 @@ output: '''
 2
 3
 wth
+3
+2
+1
+0
+(total: 6)
 '''
 """
 # bug #1915
@@ -145,3 +150,17 @@ macro m(): untyped =
 
 let meh = m()
 meh("wth")
+
+
+macro foo(body: untyped): untyped =
+  result = body
+
+template baz(): untyped =
+  foo:
+    proc bar2(b: int): int =
+      echo b
+      if b > 0: b + bar2(b = b - 1)
+      else: 0
+  echo (total: bar2(3))
+
+baz()