summary refs log tree commit diff stats
path: root/tests/openarray
diff options
context:
space:
mode:
Diffstat (limited to 'tests/openarray')
-rw-r--r--tests/openarray/topena1.nim12
-rw-r--r--tests/openarray/topenarrayrepr.nim17
-rw-r--r--tests/openarray/topenlen.nim18
3 files changed, 47 insertions, 0 deletions
diff --git a/tests/openarray/topena1.nim b/tests/openarray/topena1.nim
new file mode 100644
index 000000000..0dbc5506a
--- /dev/null
+++ b/tests/openarray/topena1.nim
@@ -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
+
+
+
diff --git a/tests/openarray/topenarrayrepr.nim b/tests/openarray/topenarrayrepr.nim
new file mode 100644
index 000000000..d276756bc
--- /dev/null
+++ b/tests/openarray/topenarrayrepr.nim
@@ -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]
+
+
+
diff --git a/tests/openarray/topenlen.nim b/tests/openarray/topenlen.nim
new file mode 100644
index 000000000..fec8e87b7
--- /dev/null
+++ b/tests/openarray/topenlen.nim
@@ -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
+
+