Merge branch 'devel' of github.com:nim-lang/Nim into devel

This commit is contained in:
Andreas Rumpf 2018-01-25 16:02:22 +01:00
commit 394757dbf5
6 changed files with 60 additions and 57 deletions

View file

@ -35,7 +35,7 @@ proc isUndefined[T](x: T): bool {.inline.} = {.emit: "`result` = `x` === undefin
proc reprEnum(e: int, typ: PNimType): string {.compilerRtl.} = proc reprEnum(e: int, typ: PNimType): string {.compilerRtl.} =
if not typ.node.sons[e].isUndefined: if not typ.node.sons[e].isUndefined:
result = $typ.node.sons[e].name result = makeNimstrLit(typ.node.sons[e].name)
else: else:
result = $e & " (invalid data!)" result = $e & " (invalid data!)"

View file

@ -92,7 +92,7 @@ This project exists thanks to all the people who contribute. [Read on to find ou
<a href="https://github.com/nim-lang/Nim/graphs/contributors"><img src="https://opencollective.com/Nim/contributors.svg?width=890" /></a> <a href="https://github.com/nim-lang/Nim/graphs/contributors"><img src="https://opencollective.com/Nim/contributors.svg?width=890" /></a>
## Contributing ## Contributing
[![Backers on Open Collective](https://opencollective.com/nim/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/nim/sponsors/badge.svg)](#sponsors) [![Contribute to Nim via Gratipay][badge-nim-gratipay]][nim-gratipay] [![Backers on Open Collective](https://opencollective.com/nim/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/nim/sponsors/badge.svg)](#sponsors)
[![Setup a bounty via Bountysource][badge-nim-bountysource]][nim-bountysource] [![Setup a bounty via Bountysource][badge-nim-bountysource]][nim-bountysource]
[![Donate Bitcoins][badge-nim-bitcoin]][nim-bitcoin] [![Donate Bitcoins][badge-nim-bitcoin]][nim-bitcoin]
@ -137,7 +137,6 @@ You can also help with the development of Nim by making donations. Donations can
made using: made using:
* [Open Collective](https://opencollective.com/nim) * [Open Collective](https://opencollective.com/nim)
* [Gratipay][nim-gratipay]
* [Bountysource][nim-bountysource] * [Bountysource][nim-bountysource]
* [Bitcoin][nim-bitcoin] * [Bitcoin][nim-bitcoin]
@ -189,7 +188,6 @@ Copyright © 2006-2017 Andreas Rumpf, all rights reserved.
[nim-stackoverflow]: https://stackoverflow.com/questions/tagged/nim [nim-stackoverflow]: https://stackoverflow.com/questions/tagged/nim
[nim-stackoverflow-newest]: https://stackoverflow.com/questions/tagged/nim?sort=newest&pageSize=15 [nim-stackoverflow-newest]: https://stackoverflow.com/questions/tagged/nim?sort=newest&pageSize=15
[nim-gitter]: https://gitter.im/nim-lang/Nim [nim-gitter]: https://gitter.im/nim-lang/Nim
[nim-gratipay]: https://gratipay.com/nim/
[nim-bountysource]: https://www.bountysource.com/teams/nim [nim-bountysource]: https://www.bountysource.com/teams/nim
[nim-bitcoin]: https://blockchain.info/address/1BXfuKM2uvoD6mbx4g5xM3eQhLzkCK77tJ [nim-bitcoin]: https://blockchain.info/address/1BXfuKM2uvoD6mbx4g5xM3eQhLzkCK77tJ
[nimble-repo]: https://github.com/nim-lang/nimble [nimble-repo]: https://github.com/nim-lang/nimble
@ -201,7 +199,6 @@ Copyright © 2006-2017 Andreas Rumpf, all rights reserved.
[badge-nim-forum-gethelp]: https://img.shields.io/badge/Forum-get%20help-4eb899.svg?style=flat-square [badge-nim-forum-gethelp]: https://img.shields.io/badge/Forum-get%20help-4eb899.svg?style=flat-square
[badge-nim-twitter]: https://img.shields.io/twitter/follow/nim_lang.svg?style=social [badge-nim-twitter]: https://img.shields.io/twitter/follow/nim_lang.svg?style=social
[badge-nim-stackoverflow]: https://img.shields.io/badge/stackoverflow-nim_tag-yellow.svg?style=flat-square [badge-nim-stackoverflow]: https://img.shields.io/badge/stackoverflow-nim_tag-yellow.svg?style=flat-square
[badge-nim-gratipay]: https://img.shields.io/gratipay/team/nim.svg?style=flat-square
[badge-nim-bountysource]: https://img.shields.io/bountysource/team/nim/activity.svg?style=flat-square [badge-nim-bountysource]: https://img.shields.io/bountysource/team/nim/activity.svg?style=flat-square
[badge-nim-bitcoin]: https://img.shields.io/badge/bitcoin-1BXfuKM2uvoD6mbx4g5xM3eQhLzkCK77tJ-D69134.svg?style=flat-square [badge-nim-bitcoin]: https://img.shields.io/badge/bitcoin-1BXfuKM2uvoD6mbx4g5xM3eQhLzkCK77tJ-D69134.svg?style=flat-square
[pull-request-instructions]: https://help.github.com/articles/using-pull-requests/ [pull-request-instructions]: https://help.github.com/articles/using-pull-requests/

View file

@ -3,7 +3,7 @@ discard """
""" """
block ints: block ints:
let let
na: int8 = -120'i8 na: int8 = -120'i8
nb: int16 = -32700'i16 nb: int16 = -32700'i16
nc: int32 = -2147483000'i32 nc: int32 = -2147483000'i32
@ -12,9 +12,9 @@ block ints:
pa: int8 = 120'i8 pa: int8 = 120'i8
pb: int16 = 32700'i16 pb: int16 = 32700'i16
pc: int32 = 2147483000'i32 pc: int32 = 2147483000'i32
pd: int64 = 9223372036854775000'i64 pd: int64 = 9223372036854775000'i64
pe: int = 1234567 pe: int = 1234567
doAssert(repr(na) == "-120") doAssert(repr(na) == "-120")
doAssert(repr(nb) == "-32700") doAssert(repr(nb) == "-32700")
doAssert(repr(nc) == "-2147483000") doAssert(repr(nc) == "-2147483000")
@ -27,13 +27,13 @@ block ints:
doAssert(repr(pe) == "1234567") doAssert(repr(pe) == "1234567")
block uints: block uints:
let let
a: uint8 = 254'u8 a: uint8 = 254'u8
b: uint16 = 65300'u16 b: uint16 = 65300'u16
c: uint32 = 4294967290'u32 c: uint32 = 4294967290'u32
# d: uint64 = 18446744073709551610'u64 -> unknown node type # d: uint64 = 18446744073709551610'u64 -> unknown node type
e: uint = 1234567 e: uint = 1234567
doAssert(repr(a) == "254") doAssert(repr(a) == "254")
doAssert(repr(b) == "65300") doAssert(repr(b) == "65300")
doAssert(repr(c) == "4294967290") doAssert(repr(c) == "4294967290")
@ -41,26 +41,26 @@ block uints:
doAssert(repr(e) == "1234567") doAssert(repr(e) == "1234567")
block floats: block floats:
let let
a: float32 = 3.4e38'f32 a: float32 = 3.4e38'f32
b: float64 = 1.7976931348623157e308'f64 b: float64 = 1.7976931348623157e308'f64
c: float = 1234.567e89 c: float = 1234.567e89
when defined js: when defined js:
doAssert(repr(a) == "3.4e+38") # in C: 3.399999952144364e+038 doAssert(repr(a) == "3.4e+38") # in C: 3.399999952144364e+038
doAssert(repr(b) == "1.7976931348623157e+308") # in C: 1.797693134862316e+308 doAssert(repr(b) == "1.7976931348623157e+308") # in C: 1.797693134862316e+308
doAssert(repr(c) == "1.234567e+92") # in C: 1.234567e+092 doAssert(repr(c) == "1.234567e+92") # in C: 1.234567e+092
block bools: block bools:
let let
a: bool = true a: bool = true
b: bool = false b: bool = false
doAssert(repr(a) == "true") doAssert(repr(a) == "true")
doAssert(repr(b) == "false") doAssert(repr(b) == "false")
block enums: block enums:
type type
AnEnum = enum AnEnum = enum
aeA aeA
aeB aeB
@ -69,28 +69,34 @@ block enums:
heA = -12 heA = -12
heB = 15 heB = 15
heC = 123 heC = 123
doAssert(repr(aeA) == "aeA") doAssert(repr(aeA) == "aeA")
doAssert(repr(aeB) == "aeB") doAssert(repr(aeB) == "aeB")
doAssert(repr(aeC) == "aeC") doAssert(repr(aeC) == "aeC")
doAssert(repr(heA) == "heA") doAssert(repr(heA) == "heA")
doAssert(repr(heB) == "heB") doAssert(repr(heB) == "heB")
doAssert(repr(heC) == "heC") doAssert(repr(heC) == "heC")
block emums_and_unicode: #6741
type K = enum Kanji = "漢字"
let kanji = Kanji
doAssert(kanji == Kanji, "Enum values are not equal")
doAssert($kanji == $Kanji, "Enum string values are not equal")
block chars: block chars:
let let
a = 'a' a = 'a'
b = 'z' b = 'z'
one = '1' one = '1'
nl = '\x0A' nl = '\x0A'
doAssert(repr(a) == "'a'") doAssert(repr(a) == "'a'")
doAssert(repr(b) == "'z'") doAssert(repr(b) == "'z'")
doAssert(repr(one) == "'1'") doAssert(repr(one) == "'1'")
doAssert(repr(nl) == "'\\10'") doAssert(repr(nl) == "'\\10'")
block strings: block strings:
let let
a: string = "12345" a: string = "12345"
b: string = "hello,repr" b: string = "hello,repr"
c: string = "hi\nthere" c: string = "hi\nthere"
@ -103,19 +109,19 @@ block sets:
let let
a: set[int16] = {1'i16, 2'i16, 3'i16} a: set[int16] = {1'i16, 2'i16, 3'i16}
b: set[char] = {'A', 'k'} b: set[char] = {'A', 'k'}
doAssert(repr(a) == "{1, 2, 3}") doAssert(repr(a) == "{1, 2, 3}")
doAssert(repr(b) == "{'A', 'k'}") doAssert(repr(b) == "{'A', 'k'}")
block ranges: block ranges:
let let
a: range[0..12] = 6 a: range[0..12] = 6
b: range[-12..0] = -6 b: range[-12..0] = -6
doAssert(repr(a) == "6") doAssert(repr(a) == "6")
doAssert(repr(b) == "-6") doAssert(repr(b) == "-6")
block tuples: block tuples:
type type
ATuple = tuple ATuple = tuple
a: int a: int
b: float b: float
@ -124,7 +130,7 @@ block tuples:
OtherTuple = tuple OtherTuple = tuple
a: bool a: bool
b: int8 b: int8
let let
ot: OtherTuple = (a: true, b: 120'i8) ot: OtherTuple = (a: true, b: 120'i8)
t: ATuple = (a: 42, b: 12.34, c: "tuple", d: ot) t: ATuple = (a: 42, b: 12.34, c: "tuple", d: ot)
@ -176,7 +182,7 @@ block arrays:
o = AObj(x: 42, y: a) o = AObj(x: 42, y: a)
c = [o, o, o] c = [o, o, o]
d = ["hi", "array", "!"] d = ["hi", "array", "!"]
doAssert(repr(a) == "[0.0, 1.0, 2.0]\n") doAssert(repr(a) == "[0.0, 1.0, 2.0]\n")
doAssert(repr(b) == "[[0.0, 1.0, 2.0], [0.0, 1.0, 2.0], [0.0, 1.0, 2.0]]\n") doAssert(repr(b) == "[[0.0, 1.0, 2.0], [0.0, 1.0, 2.0], [0.0, 1.0, 2.0]]\n")
doAssert(repr(c) == """ doAssert(repr(c) == """
@ -198,7 +204,7 @@ block seqs:
o = AObj(x: 42, y: a) o = AObj(x: 42, y: a)
c = @[o, o, o] c = @[o, o, o]
d = @["hi", "array", "!"] d = @["hi", "array", "!"]
doAssert(repr(a) == "@[0.0, 1.0, 2.0]\n") doAssert(repr(a) == "@[0.0, 1.0, 2.0]\n")
doAssert(repr(b) == "@[@[0.0, 1.0, 2.0], @[0.0, 1.0, 2.0], @[0.0, 1.0, 2.0]]\n") doAssert(repr(b) == "@[@[0.0, 1.0, 2.0], @[0.0, 1.0, 2.0], @[0.0, 1.0, 2.0]]\n")
doAssert(repr(c) == """ doAssert(repr(c) == """
@ -210,16 +216,16 @@ y = @[0.0, 1.0, 2.0]]]
doAssert(repr(d) == "@[\"hi\", \"array\", \"!\"]\n") doAssert(repr(d) == "@[\"hi\", \"array\", \"!\"]\n")
block ptrs: block ptrs:
type type
AObj = object AObj = object
x: ptr array[2, AObj] x: ptr array[2, AObj]
y: int y: int
var var
a = [12.0, 13.0, 14.0] a = [12.0, 13.0, 14.0]
b = addr a[0] b = addr a[0]
c = addr a[2] c = addr a[2]
d = AObj() d = AObj()
doAssert(repr(a) == "[12.0, 13.0, 14.0]\n") doAssert(repr(a) == "[12.0, 13.0, 14.0]\n")
doAssert(repr(b) == "ref 0 --> 12.0\n") doAssert(repr(b) == "ref 0 --> 12.0\n")
doAssert(repr(c) == "ref 2 --> 14.0\n") doAssert(repr(c) == "ref 2 --> 14.0\n")
@ -229,13 +235,13 @@ y = 0]
""") """)
block ptrs: block ptrs:
type type
AObj = object AObj = object
x: ref array[2, AObj] x: ref array[2, AObj]
y: int y: int
var var
a = AObj() a = AObj()
new(a.x) new(a.x)
doAssert(repr(a) == """ doAssert(repr(a) == """
@ -248,10 +254,10 @@ y = 0]
block procs: block procs:
proc test(): int = proc test(): int =
echo "hello" echo "hello"
var var
ptest = test ptest = test
nilproc: proc(): int nilproc: proc(): int
doAssert(repr(test) == "0\n") doAssert(repr(test) == "0\n")
doAssert(repr(ptest) == "0\n") doAssert(repr(ptest) == "0\n")
doAssert(repr(nilproc) == "nil\n") doAssert(repr(nilproc) == "nil\n")
@ -262,7 +268,7 @@ block bunch:
eA, eB, eC eA, eB, eC
B = object B = object
a: string a: string
b: seq[char] b: seq[char]
A = object A = object
a: uint32 a: uint32
b: int b: int
@ -281,17 +287,17 @@ block bunch:
o: tuple[x: B, y: string] o: tuple[x: B, y: string]
p: proc(b: B): ref B p: proc(b: B): ref B
q: cstring q: cstring
proc refB(b:B):ref B = proc refB(b:B):ref B =
new result new result
result[] = b result[] = b
var var
aa: A aa: A
bb: B = B(a: "inner", b: @['o', 'b', 'j']) bb: B = B(a: "inner", b: @['o', 'b', 'j'])
cc: A = A(a: 12, b: 1, c: 1.2, d: '\0', e: eC, cc: A = A(a: 12, b: 1, c: 1.2, d: '\0', e: eC,
f: "hello", g: {'A'}, h: {2'i16}, f: "hello", g: {'A'}, h: {2'i16},
i: ["hello", "world", "array"], i: ["hello", "world", "array"],
j: @["hello", "world", "seq"], k: -1, j: @["hello", "world", "seq"], k: -1,
l: bb, m: refB(bb), n: addr bb, l: bb, m: refB(bb), n: addr bb,
o: (bb, "tuple!"), p: refB, q: "cstringtest" ) o: (bb, "tuple!"), p: refB, q: "cstringtest" )
@ -344,12 +350,12 @@ q = "cstringtest"]
""") """)
block another: block another:
type type
Size1 = enum Size1 = enum
s1a, s1b s1a, s1b
Size2 = enum Size2 = enum
s2c=0, s2d=20000 s2c=0, s2d=20000
Size3 = enum Size3 = enum
s3e=0, s3f=2000000000 s3e=0, s3f=2000000000
doAssert(repr([s1a, s1b]) == "[s1a, s1b]\n") doAssert(repr([s1a, s1b]) == "[s1a, s1b]\n")
@ -357,7 +363,7 @@ block another:
doAssert(repr([s3e, s3f]) == "[s3e, s3f]\n") doAssert(repr([s3e, s3f]) == "[s3e, s3f]\n")
block another2: block another2:
type type
AnEnum = enum AnEnum = enum
en1, en2, en3, en4, en5, en6 en1, en2, en3, en4, en5, en6

View file

@ -1,8 +1,8 @@
#ifdef WIN #ifdef WIN
#include <windows.h> #include <windows.h>
#else #else
#include <dlfcn.h> #include <dlfcn.h>
#include <unistd.h> /* for sleep(3) */
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View file

@ -1,21 +1,21 @@
Test the realtime GC without linking nimrtl.dll/so. Test the realtime GC without linking nimrtl.dll/so.
Note, this is a long running test, default is 35 minutes. To change the Note, this is a long running test, default is 35 minutes. To change the
the run time see RUNTIME in main.nim and main.c. the run time see RUNTIME in nmain.nim and cmain.c.
You can build shared.nim, main.nim, and main.c by running make (nix systems) You can build shared.nim, nmain.nim, and cmain.c by running make (nix systems)
or maike.bat (Windows systems). They both assume GCC and that it's in your or make.bat (Windows systems). They both assume GCC and that it's in your
path. Output: shared.(dll/so), camin(.exe), nmain(.exe). path. Output: shared.(dll/so), cmain(.exe), nmain(.exe).
To run the test: execute either nmain or cmain in a shell window. To run the test: execute either nmain or cmain in a shell window.
To build buy hand: To build by hand:
- build the shared object (shared.nim): - build the shared object (shared.nim):
$ nim c shared.nim $ nim c tests/realtimeGC/shared.nim
- build the client executables: - build the client executables:
$ nim c -o:nmain main.nim $ nim c --threads:on tests/realtimeGC/nmain.nim
$ gcc -o cmain main.c -ldl $ gcc -o tests/realtimeGC/cmain tests/realtimeGC/cmain.c -ldl

View file

@ -167,9 +167,9 @@ proc gcTests(r: var TResults, cat: Category, options: string) =
proc longGCTests(r: var TResults, cat: Category, options: string) = proc longGCTests(r: var TResults, cat: Category, options: string) =
when defined(windows): when defined(windows):
let cOptions = "gcc -ldl -DWIN" let cOptions = "-ldl -DWIN"
else: else:
let cOptions = "gcc -ldl" let cOptions = "-ldl"
var c = initResults() var c = initResults()
# According to ioTests, this should compile the file # According to ioTests, this should compile the file