Merge ../Nim into devel

This commit is contained in:
Charles Blake
2015-08-09 06:58:36 -04:00
22 changed files with 455 additions and 102 deletions

View File

@@ -0,0 +1,47 @@
discard """
output: '''assign
destroy
destroy
destroy Foo: 5
5
destroy Foo: 123
123'''
"""
# bug #2821
{.experimental.}
type T = object
proc `=`(lhs: var T, rhs: T) =
echo "assign"
proc `=destroy`(v: var T) =
echo "destroy"
block:
var v1 : T
var v2 : T = v1
# bug #1632
type
Foo = object of RootObj
x: int
proc `=destroy`(a: var Foo) =
echo "destroy Foo: " & $a.x
template toFooPtr(a: int{lit}): ptr Foo =
var temp = Foo(x:a)
temp.addr
proc test(a: ptr Foo) =
echo a[].x
proc main =
test(toFooPtr(5))
test(toFooPtr(123))
main()

View File

@@ -1,6 +1,11 @@
discard """
output: '''hi
hi'''
hi
1
hi
2
B
A'''
"""
# bug #1742
@@ -16,3 +21,23 @@ import strutils
let x = try: parseInt("133a")
except: -1
finally: echo "hi"
template atFuncEnd =
defer:
echo "A"
defer:
echo "B"
template testB(): expr =
let a = 0
defer: echo "hi" # Delete this line to make it work
a
proc main =
atFuncEnd()
echo 1
let i = testB()
echo 2
main()

View File

@@ -0,0 +1,10 @@
type R* = object
type Data*[T] = object
d*: T
proc same(r:R, d:int) = echo "TEST2"
proc doIt*(d:Data, r:R) =
r.same(1) # Expecting this to invoke the local `same()` method

View File

@@ -0,0 +1,11 @@
discard """
output: "TEST2"
"""
# bug #2664
import mclosed_sym
proc same(r:R, d:int) = echo "TEST1"
doIt(Data[int](d:123), R())

View File

@@ -21,6 +21,11 @@ test "unittest typedescs":
check(none(int) != some(1))
test "unittest multiple requires":
require(true)
require(true)
import math
from strutils import parseInt
proc defectiveRobot() =

View File

@@ -0,0 +1,13 @@
discard """
output: "hi"
"""
# bug #2670
template testTemplate(b: bool): stmt =
when b:
var a = "hi"
else:
var a = 5
echo a
testTemplate(true)