diff options
Diffstat (limited to 'tests/stdlib')
-rw-r--r-- | tests/stdlib/tlocks.nim | 10 | ||||
-rw-r--r-- | tests/stdlib/tmarshal.nim | 2 | ||||
-rw-r--r-- | tests/stdlib/tnre.nim | 17 | ||||
-rw-r--r-- | tests/stdlib/tparsecfg.nim | 23 | ||||
-rw-r--r-- | tests/stdlib/tpegs.nim | 22 | ||||
-rw-r--r-- | tests/stdlib/uselocks.nim | 11 |
6 files changed, 65 insertions, 20 deletions
diff --git a/tests/stdlib/tlocks.nim b/tests/stdlib/tlocks.nim new file mode 100644 index 000000000..e567cfde8 --- /dev/null +++ b/tests/stdlib/tlocks.nim @@ -0,0 +1,10 @@ +discard """ + output: '''3''' + cmd: "nim $target --threads:on $options $file" +""" + +#bug #6049 +import uselocks + +var m = createMyType[int]() +echo $m.use() diff --git a/tests/stdlib/tmarshal.nim b/tests/stdlib/tmarshal.nim index 6a53a2964..434caa281 100644 --- a/tests/stdlib/tmarshal.nim +++ b/tests/stdlib/tmarshal.nim @@ -9,7 +9,7 @@ omega 200 import marshal -template testit(x: expr) = discard $$to[type(x)]($$x) +template testit(x) = discard $$to[type(x)]($$x) var x: array[0..4, array[0..4, string]] = [ ["test", "1", "2", "3", "4"], ["test", "1", "2", "3", "4"], diff --git a/tests/stdlib/tnre.nim b/tests/stdlib/tnre.nim index 030319ebf..fabbb69a8 100644 --- a/tests/stdlib/tnre.nim +++ b/tests/stdlib/tnre.nim @@ -20,12 +20,13 @@ discard """ [Suite] Misc tests''' """ + import nre -import nre.init -import nre.captures -import nre.find -import nre.split -import nre.match -import nre.replace -import nre.escape -import nre.misc +import nre/init +import nre/captures +import nre/find +import nre/split +import nre/match +import nre/replace +import nre/escape +import nre/misc diff --git a/tests/stdlib/tparsecfg.nim b/tests/stdlib/tparsecfg.nim new file mode 100644 index 000000000..1c214e5d2 --- /dev/null +++ b/tests/stdlib/tparsecfg.nim @@ -0,0 +1,23 @@ +discard """ + output: '''OK''' +""" + +#bug #6046 +import parsecfg + +var config = newConfig() +config.setSectionKey("foo","bar","-1") +config.setSectionKey("foo","foo","abc") +config.writeConfig("test.ini") + +# test.ini now contains +# [foo] +# bar=-1 +# foo=abc + +var config2 = loadConfig("test.ini") +let bar = config2.getSectionValue("foo","bar") +let foo = config2.getSectionValue("foo","foo") +assert(bar == "-1") +assert(foo == "abc") +echo "OK" diff --git a/tests/stdlib/tpegs.nim b/tests/stdlib/tpegs.nim index ec839e288..e2a5a1715 100644 --- a/tests/stdlib/tpegs.nim +++ b/tests/stdlib/tpegs.nim @@ -149,7 +149,7 @@ proc addChoice(dest: var TPeg, elem: TPeg) = else: add(dest, elem) else: add(dest, elem) -template multipleOp(k: TPegKind, localOpt: expr) = +template multipleOp(k: TPegKind, localOpt) = result.kind = k result.sons = @[] for x in items(a): @@ -350,32 +350,32 @@ proc newNonTerminal*(name: string, line, column: int): PNonTerminal {. result.line = line result.col = column -template letters*: expr = +template letters*: TPeg = ## expands to ``charset({'A'..'Z', 'a'..'z'})`` charset({'A'..'Z', 'a'..'z'}) -template digits*: expr = +template digits*: TPeg = ## expands to ``charset({'0'..'9'})`` charset({'0'..'9'}) -template whitespace*: expr = +template whitespace*: TPeg = ## expands to ``charset({' ', '\9'..'\13'})`` charset({' ', '\9'..'\13'}) -template identChars*: expr = +template identChars*: TPeg = ## expands to ``charset({'a'..'z', 'A'..'Z', '0'..'9', '_'})`` charset({'a'..'z', 'A'..'Z', '0'..'9', '_'}) -template identStartChars*: expr = +template identStartChars*: TPeg = ## expands to ``charset({'A'..'Z', 'a'..'z', '_'})`` charset({'a'..'z', 'A'..'Z', '_'}) -template ident*: expr = +template ident*: TPeg = ## same as ``[a-zA-Z_][a-zA-z_0-9]*``; standard identifier sequence(charset({'a'..'z', 'A'..'Z', '_'}), *charset({'a'..'z', 'A'..'Z', '0'..'9', '_'})) -template natural*: expr = +template natural*: TPeg = ## same as ``\d+`` +digits @@ -534,10 +534,10 @@ proc bounds*(c: TCaptures, when not useUnicode: type Rune = char - template fastRuneAt(s, i, ch: expr) = + template fastRuneAt(s, i, ch) = ch = s[i] inc(i) - template runeLenAt(s, i: expr): expr = 1 + template runeLenAt(s, i): untyped = 1 proc isAlpha(a: char): bool {.inline.} = return a in {'a'..'z','A'..'Z'} proc isUpper(a: char): bool {.inline.} = return a in {'A'..'Z'} @@ -847,7 +847,7 @@ proc findAll*(s: string, pattern: TPeg, start = 0): seq[string] {. ## If it does not match, @[] is returned. accumulateResult(findAll(s, pattern, start)) -template `=~`*(s: string, pattern: TPeg): expr = +template `=~`*(s: string, pattern: TPeg): untyped = ## This calls ``match`` with an implicit declared ``matches`` array that ## can be used in the scope of the ``=~`` call: ## diff --git a/tests/stdlib/uselocks.nim b/tests/stdlib/uselocks.nim new file mode 100644 index 000000000..cde9641b2 --- /dev/null +++ b/tests/stdlib/uselocks.nim @@ -0,0 +1,11 @@ +import locks + +type MyType* [T] = object + lock: Lock + +proc createMyType*[T]: MyType[T] = + initLock(result.lock) + +proc use* (m: var MyType): int = + withLock m.lock: + result = 3 |