mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 09:24:36 +00:00
* define gcRefc symbols * add comments * add a changelog item * Update changelog.md Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> * Update changelog.md Co-authored-by: Yardanico <tiberiumk12@gmail.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: Yardanico <tiberiumk12@gmail.com>
38 lines
689 B
Nim
38 lines
689 B
Nim
discard """
|
|
matrix: "--gc:refc; --gc:orc"
|
|
"""
|
|
|
|
import "$lib/.." / compiler/strutils2
|
|
|
|
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
|