mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-22 08:51:21 +00:00
new tester; all tests categorized
This commit is contained in:
12
tests/openarray/topena1.nim
Normal file
12
tests/openarray/topena1.nim
Normal file
@@ -0,0 +1,12 @@
|
||||
discard """
|
||||
file: "topena1.nim"
|
||||
line: 9
|
||||
errormsg: "invalid type"
|
||||
"""
|
||||
# Tests a special bug
|
||||
|
||||
var
|
||||
x: ref openarray[string] #ERROR_MSG invalid type
|
||||
|
||||
|
||||
|
||||
17
tests/openarray/topenarrayrepr.nim
Normal file
17
tests/openarray/topenarrayrepr.nim
Normal file
@@ -0,0 +1,17 @@
|
||||
discard """
|
||||
file: "topenarrayrepr.nim"
|
||||
output: "5 - [1]"
|
||||
"""
|
||||
type
|
||||
TProc = proc (n: int, m: openarray[int64]) {.nimcall.}
|
||||
|
||||
proc Foo(x: int, P: TProc) =
|
||||
P(x, [ 1'i64 ])
|
||||
|
||||
proc Bar(n: int, m: openarray[int64]) =
|
||||
echo($n & " - " & repr(m))
|
||||
|
||||
Foo(5, Bar) #OUT 5 - [1]
|
||||
|
||||
|
||||
|
||||
18
tests/openarray/topenlen.nim
Normal file
18
tests/openarray/topenlen.nim
Normal file
@@ -0,0 +1,18 @@
|
||||
discard """
|
||||
file: "topenlen.nim"
|
||||
output: "7"
|
||||
"""
|
||||
# Tests a special bug
|
||||
|
||||
proc choose(b: openArray[string]): string = return b[0]
|
||||
|
||||
proc p(a, b: openarray[string]): int =
|
||||
result = a.len + b.len - 1
|
||||
for j in 0 .. a.len: inc(result)
|
||||
discard choose(a)
|
||||
discard choose(b)
|
||||
|
||||
discard choose(["sh", "-c", $p([""], ["a"])])
|
||||
echo($p(["", "ha", "abc"], ["xyz"])) #OUT 7
|
||||
|
||||
|
||||
Reference in New Issue
Block a user