mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-20 14:25:23 +00:00
Merge branch 'devel' into uint-range-checks
This commit is contained in:
@@ -13,6 +13,3 @@ f3(typeof(nil))
|
||||
|
||||
proc f4[T](_: T) = discard
|
||||
f4(nil)
|
||||
|
||||
proc f5(): typeof(nil) = nil
|
||||
discard f5()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user