diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-12-12 16:29:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-12 16:29:46 +0100 |
commit | a1bf9fd2b6525e613899c5dc0380fb80021ee3e7 (patch) | |
tree | d2bdb332c973d2f6d43391369229cc732642c74d /tests/vm | |
parent | a38f35359738534ba856d02f3564d5fbc2dfc822 (diff) | |
parent | 070bcf4cea28a3238089379f5884787b2084b2de (diff) | |
download | Nim-a1bf9fd2b6525e613899c5dc0380fb80021ee3e7.tar.gz |
Merge branch 'devel' into sorted_deduplicate
Diffstat (limited to 'tests/vm')
-rw-r--r-- | tests/vm/t2574.nim | 2 | ||||
-rw-r--r-- | tests/vm/tcastint.nim | 5 | ||||
-rw-r--r-- | tests/vm/tconstobj.nim | 22 | ||||
-rw-r--r-- | tests/vm/tforwardproc.nim | 2 | ||||
-rw-r--r-- | tests/vm/tmitems_vm.nim (renamed from tests/vm/tmitems.nim) | 0 | ||||
-rw-r--r-- | tests/vm/tsetlen.nim | 30 | ||||
-rw-r--r-- | tests/vm/tvmmisc.nim | 4 |
7 files changed, 55 insertions, 10 deletions
diff --git a/tests/vm/t2574.nim b/tests/vm/t2574.nim index 86602aeaf..4332667b4 100644 --- a/tests/vm/t2574.nim +++ b/tests/vm/t2574.nim @@ -1,6 +1,6 @@ discard """ - line: 14 errormsg: "cannot call method eval at compile time" + line: 14 """ type diff --git a/tests/vm/tcastint.nim b/tests/vm/tcastint.nim index f9d42fc54..437342a74 100644 --- a/tests/vm/tcastint.nim +++ b/tests/vm/tcastint.nim @@ -1,5 +1,4 @@ discard """ - file: "tcastint.nim" output: "OK" """ @@ -130,7 +129,7 @@ proc test_float_cast = doAssert(mantissa == 0, $mantissa) # construct 2^N float, where N is integer - let x = -2'i64 + let x = -2'i64 let xx = (x + exp_bias) shl exp_shift let xf = cast[float](xx) doAssert(xf == 0.25, $xf) @@ -151,7 +150,7 @@ proc test_float32_cast = doAssert(mantissa == 0, $mantissa) # construct 2^N float32 where N is integer - let x = 4'i32 + let x = 4'i32 let xx = (x + exp_bias) shl exp_shift let xf = cast[float32](xx) doAssert(xf == 16.0'f32, $xf) diff --git a/tests/vm/tconstobj.nim b/tests/vm/tconstobj.nim index 38fcdd844..021fcb728 100644 --- a/tests/vm/tconstobj.nim +++ b/tests/vm/tconstobj.nim @@ -1,10 +1,12 @@ discard """ - output: '''(name: "hello") -(-1, 0)''' + output: ''' +(name: "hello") +(-1, 0) +(FirstName: "James", LastName: "Franco") +''' """ # bug #2774, bug #3195 - type Foo = object name: string @@ -14,7 +16,6 @@ const fooArray = [ echo fooArray[0] - type Position = object x, y: int @@ -34,3 +35,16 @@ const ] echo offset[1] + +# bug #1547 +import tables + +type Person* = object + FirstName*: string + LastName*: string + +let people = { + "001": Person(FirstName: "James", LastName: "Franco") +}.toTable() + +echo people["001"] diff --git a/tests/vm/tforwardproc.nim b/tests/vm/tforwardproc.nim index 727ac6641..bcd929f0e 100644 --- a/tests/vm/tforwardproc.nim +++ b/tests/vm/tforwardproc.nim @@ -14,4 +14,4 @@ proc initArray(): array[10, int] = for f in 0..<10: result[f] = 3 -when isMainModule: echo repr(someTable) +when true: echo repr(someTable) diff --git a/tests/vm/tmitems.nim b/tests/vm/tmitems_vm.nim index 87835d1cd..87835d1cd 100644 --- a/tests/vm/tmitems.nim +++ b/tests/vm/tmitems_vm.nim diff --git a/tests/vm/tsetlen.nim b/tests/vm/tsetlen.nim new file mode 100644 index 000000000..9fd30f331 --- /dev/null +++ b/tests/vm/tsetlen.nim @@ -0,0 +1,30 @@ +type Foo = object + index: int + +block: + proc fun[T]() = + var foo: T + var n = 10 + + var foos: seq[T] + foos.setLen n + + n.inc + foos.setLen n + + for i in 0 ..< n: + let temp = foos[i] + when T is object: + doAssert temp.index == 0 + when T is ref object: + doAssert temp == nil + doAssert temp == foo + + static: + fun[Foo]() + fun[int]() + fun[float]() + fun[string]() + fun[(int, string)]() + fun[ref Foo]() + fun[seq[int]]() diff --git a/tests/vm/tvmmisc.nim b/tests/vm/tvmmisc.nim index 85de26e39..bd3aa2fcd 100644 --- a/tests/vm/tvmmisc.nim +++ b/tests/vm/tvmmisc.nim @@ -70,7 +70,9 @@ block: # Tests for VM ops block: static: - assert "vm" in getProjectPath() + # for joint test, the project path is different, so I disabled it: + when false: + assert "vm" in getProjectPath() let b = getEnv("UNSETENVVAR") assert b == "" |