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
This commit is contained in:
Miran 2018-10-12 17:02:46 +02:00 • committed by Andreas Rumpf
commit 7f18d7cbc1
103 changed files with 3736 additions and 3368 deletions

View file

@ -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 ""