Merge branch 'devel' of github.com:Araq/Nimrod into devel
This commit is contained in:
commit
2cbe46daff
23 changed files with 280 additions and 55 deletions
|
|
@ -24,3 +24,5 @@ ok supports(`+`, 34)
|
|||
|
||||
no compiles(4+5.0 * "hallo")
|
||||
|
||||
no compiles(undeclaredIdentifier)
|
||||
no compiles(undeclaredIdentifier)
|
||||
|
|
|
|||
|
|
@ -11,3 +11,19 @@ proc q[T](x, y: T): T {.discardable.} =
|
|||
p(8, 2)
|
||||
q[float](0.8, 0.2)
|
||||
|
||||
# bug #942
|
||||
|
||||
template maybeMod(x: Tinteger, module:Natural):expr =
|
||||
if module > 0: x mod module
|
||||
else: x
|
||||
|
||||
proc foo(b: int):int =
|
||||
var x = 1
|
||||
result = x.maybeMod(b) # Works fine
|
||||
|
||||
proc bar(b: int):int =
|
||||
result = 1
|
||||
result = result.maybeMod(b) # Error: value returned by statement has to be discarded
|
||||
|
||||
echo foo(0)
|
||||
echo bar(0)
|
||||
|
|
|
|||
45
tests/system/alloc.nim
Normal file
45
tests/system/alloc.nim
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
var x: ptr int
|
||||
|
||||
x = cast[ptr int](alloc(7))
|
||||
assert x != nil
|
||||
|
||||
x = alloc(int, 3)
|
||||
assert x != nil
|
||||
x.dealloc()
|
||||
|
||||
x = alloc0(int, 4)
|
||||
assert cast[ptr array[4, int]](x)[0] == 0
|
||||
assert cast[ptr array[4, int]](x)[1] == 0
|
||||
assert cast[ptr array[4, int]](x)[2] == 0
|
||||
assert cast[ptr array[4, int]](x)[3] == 0
|
||||
|
||||
x = cast[ptr int](x.realloc(2))
|
||||
assert x != nil
|
||||
|
||||
x = x.reallocType(4)
|
||||
assert x != nil
|
||||
x.dealloc()
|
||||
|
||||
x = cast[ptr int](allocShared(100))
|
||||
assert x != nil
|
||||
deallocShared(x)
|
||||
|
||||
x = allocShared(int, 3)
|
||||
assert x != nil
|
||||
x.deallocShared()
|
||||
|
||||
x = allocShared0(int, 3)
|
||||
assert x != nil
|
||||
assert cast[ptr array[3, int]](x)[0] == 0
|
||||
assert cast[ptr array[3, int]](x)[1] == 0
|
||||
assert cast[ptr array[3, int]](x)[2] == 0
|
||||
|
||||
x = cast[ptr int](reallocShared(x, 2))
|
||||
assert x != nil
|
||||
|
||||
x = reallocType(x, 12)
|
||||
assert x != nil
|
||||
|
||||
x = reallocSharedType(x, 1)
|
||||
assert x != nil
|
||||
x.deallocShared()
|
||||
13
tests/vm/twrongwhen.nim
Normal file
13
tests/vm/twrongwhen.nim
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
discard """
|
||||
output: "Error: cannot evaluate at compile time: x"
|
||||
line: 7
|
||||
"""
|
||||
|
||||
proc bla(x:int) =
|
||||
when x == 0:
|
||||
echo "oops"
|
||||
else:
|
||||
echo "good"
|
||||
|
||||
bla(2) # echos "oops"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue