diff options
author | metagn <metagngn@gmail.com> | 2023-06-06 07:54:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-06 06:54:07 +0200 |
commit | b97d603cd00a210547bda1a2a1c3e09f97fcc49e (patch) | |
tree | 080b4ad7b5826b88a9483c6a0e4d697096f12cc1 /tests/vm/tcnstseq.nim | |
parent | 2ab948ce53e3d9b80bf9b02644c8ec8991f34d0a (diff) | |
download | Nim-b97d603cd00a210547bda1a2a1c3e09f97fcc49e.tar.gz |
some test cleanups & category reorganization (#22010)
* clean up some test categories * mention exact slice issue * magics into system * move trangechecks into overflow * move tmemory to system * try fix CI * try fix CI * final CI fix
Diffstat (limited to 'tests/vm/tcnstseq.nim')
-rw-r--r-- | tests/vm/tcnstseq.nim | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/vm/tcnstseq.nim b/tests/vm/tcnstseq.nim new file mode 100644 index 000000000..5679a6e37 --- /dev/null +++ b/tests/vm/tcnstseq.nim @@ -0,0 +1,68 @@ +discard """ +output: ''' +AngelikaAnneAnnaAnkaAnja +AngelikaAnneAnnaAnkaAnja +AngelikaAnneAnnaAnkaAnja +onetwothree +onetwothree +onetwothree +one1two2three3 +''' +""" +# Test the new implicit conversion from sequences to arrays in a constant +# context. + +import strutils + + +block t1: + const + myWords = "Angelika Anne Anna Anka Anja".split() + + for x in items(myWords): + write(stdout, x) #OUT AngelikaAnneAnnaAnkaAnja + echo "" + + +block t2: + const + myWords = @["Angelika", "Anne", "Anna", "Anka", "Anja"] + + for i in 0 .. high(myWords): + write(stdout, myWords[i]) #OUT AngelikaAnneAnnaAnkaAnja + echo "" + + +block t3: + for w in items(["Angelika", "Anne", "Anna", "Anka", "Anja"]): + write(stdout, w) #OUT AngelikaAnneAnnaAnkaAnja + echo "" + + +block t2656: + iterator it1(args: seq[string]): string = + for s in args: yield s + iterator it2(args: seq[string]): string {.closure.} = + for s in args: yield s + iterator it3(args: openArray[string]): string {.closure.} = + for s in args: yield s + iterator it4(args: openArray[(string, string)]): string {.closure.} = + for s1, s2 in items(args): yield s1 & s2 + + block: + const myConstSeq = @["one", "two", "three"] + for s in it1(myConstSeq): + stdout.write s + echo "" + for s in it2(myConstSeq): + stdout.write s + echo "" + for s in it3(myConstSeq): + stdout.write s + echo "" + + block: + const myConstSeq = @[("one", "1"), ("two", "2"), ("three", "3")] + for s in it4(myConstSeq): + stdout.write s + echo "" |