diff options
author | Miran <narimiran@users.noreply.github.com> | 2018-10-12 17:02:46 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-10-12 17:02:46 +0200 |
commit | 7f18d7cbc1fc8ad87c389b8d4d873e1d1169f794 (patch) | |
tree | 8c4839495fd6fc10376dc44cc8f9c7e3c625d18f /tests/cnstseq/tcnstseq.nim | |
parent | d2b04a8bc7a78845d25e8b789184ae54e98073ec (diff) | |
download | Nim-7f18d7cbc1fc8ad87c389b8d4d873e1d1169f794.tar.gz |
Merge tests into a larger file (part 1 of ∞) (#9318)
* merge actiontable tests * merge arithm tests * merge array tests * merge assign tests * merge bind tests * merge casestmt tests * merge closure tests * merge cnt seq tests * merge collections tests * merge concept issues tests * merge concept tests * fix failing tests * smaller outputs Use `doAssert` where possible. * fix wrong output * split `tcomputedgoto` * revert merging concepts * fix failing test
Diffstat (limited to 'tests/cnstseq/tcnstseq.nim')
-rw-r--r-- | tests/cnstseq/tcnstseq.nim | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/tests/cnstseq/tcnstseq.nim b/tests/cnstseq/tcnstseq.nim index ad0527f10..e044b9f3f 100644 --- a/tests/cnstseq/tcnstseq.nim +++ b/tests/cnstseq/tcnstseq.nim @@ -1,17 +1,69 @@ discard """ file: "tcnstseq.nim" - output: "AngelikaAnneAnnaAnkaAnja" + output: ''' +AngelikaAnneAnnaAnkaAnja +AngelikaAnneAnnaAnkaAnja +AngelikaAnneAnnaAnkaAnja +onetwothree +onetwothree +onetwothree +one1two2three3 +''' """ # Test the new implicit conversion from sequences to arrays in a constant # context. import strutils -const - myWords = "Angelika Anne Anna Anka Anja".split() -for x in items(myWords): - write(stdout, x) #OUT AngelikaAnneAnnaAnkaAnja +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 "" |