diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/accept/compile/toop.nim | 18 | ||||
-rwxr-xr-x | tests/accept/compile/tquicksort.nim | 4 | ||||
-rwxr-xr-x | tests/accept/run/spec.csv | 1 | ||||
-rw-r--r-- | tests/accept/run/titer6.nim | 31 |
4 files changed, 53 insertions, 1 deletions
diff --git a/tests/accept/compile/toop.nim b/tests/accept/compile/toop.nim new file mode 100644 index 000000000..d103c6304 --- /dev/null +++ b/tests/accept/compile/toop.nim @@ -0,0 +1,18 @@ + +type + TA = object + x, y: int + + TB = object of TA + z: int + + TC = object of TB + whatever: string + +proc p(a: var TA) = nil +proc p(b: var TB) = nil + +var c: TC + +p(c) + diff --git a/tests/accept/compile/tquicksort.nim b/tests/accept/compile/tquicksort.nim index 421564ecd..6706a185e 100755 --- a/tests/accept/compile/tquicksort.nim +++ b/tests/accept/compile/tquicksort.nim @@ -9,7 +9,9 @@ proc QuickSort(list: seq[int]): seq[int] = left.add(list[i]) elif list[i] > pivot: right.add(list[i]) - result = QuickSort(left) & pivot & QuickSort(right) + result = QuickSort(left) & + pivot & + QuickSort(right) proc echoSeq(a: seq[int]) = for i in low(a)..high(a): diff --git a/tests/accept/run/spec.csv b/tests/accept/run/spec.csv index 68954cf48..c57463770 100755 --- a/tests/accept/run/spec.csv +++ b/tests/accept/run/spec.csv @@ -34,6 +34,7 @@ tisopr.nim;falsetrue titer2.nim;123 titer3.nim;1231 titer5.nim;abcxyz +titer6.nim;000 tlenopenarray.nim;1 tlowhigh.nim;10 tmatrix.nim;111 diff --git a/tests/accept/run/titer6.nim b/tests/accept/run/titer6.nim new file mode 100644 index 000000000..8a1d9cf1b --- /dev/null +++ b/tests/accept/run/titer6.nim @@ -0,0 +1,31 @@ +# Test iterator with more than 1 yield statement + +import strutils + +iterator tokenize2(s: string, seps: set[char] = Whitespace): tuple[ + token: string, isSep: bool] = + var i = 0 + while i < s.len: + var j = i + if s[j] in seps: + while j < s.len and s[j] in seps: inc(j) + if j > i: + yield (copy(s, i, j-1), true) + else: + while j < s.len and s[j] notin seps: inc(j) + if j > i: + yield (copy(s, i, j-1), false) + i = j + +for word, isSep in tokenize2("ta da", whiteSpace): + var titer2TestVar = 0 + stdout.write(titer2TestVar) + +proc wordWrap2(s: string, maxLineWidth = 80, + splitLongWords = true, + seps: set[char] = whitespace, + newLine = "\n"): string = + result = "" + for word, isSep in tokenize2(s, seps): + var w = 0 + |