1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- discard """
- input: "hi"
- output: '''
- hi
- Nim
- '''
- matrix: "--gc:arc -d:useMalloc; --gc:arc"
- """
- {.experimental: "views".}
- block: # bug 18627
- proc setPosition(params: openArray[string]) =
- for i in params.toOpenArray(0, params.len - 1):
- echo i
- proc uciLoop() =
- let params = @[readLine(stdin)]
- setPosition(params)
- uciLoop()
- proc uciLoop2() =
- let params = @["Nim"]
- for i in params.toOpenArray(0, params.len - 1):
- echo i
- uciLoop2()
- when defined(nimPreviewSlimSystem):
- import std/assertions
- block: # bug #20954
- block:
- doAssertRaises(IndexDefect):
- var v: array[10, int]
- echo len(toOpenArray(v, 20, 30))
- block:
- doAssertRaises(IndexDefect):
- var v: seq[int]
- echo len(toOpenArray(v, 20, 30))
- # bug #20422
- proc f(a: var string) =
- var v = a.toOpenArray(1, 3)
- v[0] = 'a'
- var a = "Hello"
- f(a)
- doAssert a == "Hallo"
- # bug #22132
- block:
- func foo[T](arr: openArray[T], idx: int = arr.low): string =
- doAssert idx == 0
- return $arr
- let bug = ["0", "c", "a"]
- let str = foo(bug)
- const expected = """["0", "c", "a"]"""
- doAssert str == expected
- const noBugConst = ["0", "c", "a"]
- doAssert foo(noBugConst) == expected
- let noBugSeq = @["0", "c", "a"]
- doAssert foo(noBugSeq) == expected
|