fix #17159 items(cstring) works in VM (#17160)

* fix #17159 items(cstring) works in VM

* improve test coverage tests/stdlib/tcstring.nim; add helpers: whenRuntimeJs, whenVMorJs

* document items(cstring)

* address comments
This commit is contained in:
Timothee Cour 2021-02-24 05:01:06 -08:00 • committed by GitHub
commit 11a7fa68f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 155 additions and 43 deletions

View file

@ -1,16 +0,0 @@
discard """
cmd: "nim c --gc:arc -r $file"
nimout: '''hello
h
o
'''
"""
# Issue #13321: [codegen] --gc:arc does not properly emit cstring, results in SIGSEGV
let a = "hello".cstring
echo a
echo a[0]
echo a[4]
doAssert a[a.len] == '\0'