blob: 22a935ab8148c827de84f39ff8e37aee37899814 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
discard """
matrix: "--gc:refc; --gc:orc"
"""
import "$lib/.." / compiler/strutils2
import std/assertions
block: # setLen
var a = "abc"
a.setLen 0
a.setLen 3, isInit = false
when defined(gcRefc): # bug #19763
doAssert a[1] == 'b'
a.setLen 0
a.setLen 3, isInit = true
doAssert a[1] == '\0'
block: # forceCopy
var a: string
a = "foo"
shallow(a)
var b: string
b = a
doAssert b[0].addr == a[0].addr
var c: string
c.forceCopy a
doAssert c == a
doAssert c[0].addr != a[0].addr
block: # toLowerAscii
var a = "fooBAr"
a.toLowerAscii
doAssert a == "foobar"
block: # dataPointer
var a: string
discard a.dataPointer
# doAssert a.dataPointer == nil # not guaranteed
|