diff options
author | hlaaftana <10591326+hlaaftana@users.noreply.github.com> | 2021-02-11 19:04:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-11 17:04:32 +0100 |
commit | 81533a0014a8372207426dc9d067aff4b59db8af (patch) | |
tree | 8f34f7f70a0a2b2b7e1400315f74e9c97c51fdf2 /tests/system | |
parent | f3c39bf2d99d964c5b8fd88c3b8940b0cf5c1b9b (diff) | |
download | Nim-81533a0014a8372207426dc9d067aff4b59db8af.tar.gz |
[backport:1.4] JS cstring null fixes (#16979)
* [backport:1.4] JS cstring null fixes * fix JS move string * make it look cleaner
Diffstat (limited to 'tests/system')
-rw-r--r-- | tests/system/tdollars.nim | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/system/tdollars.nim b/tests/system/tdollars.nim index 1b2602ad0..62f77c857 100644 --- a/tests/system/tdollars.nim +++ b/tests/system/tdollars.nim @@ -71,12 +71,35 @@ block: # `$`(SomeInteger) testType int64 testType BiggestInt -block: # #14350 for JS +block: # #14350, #16674, #16686 for JS var cstr: cstring doAssert cstr == cstring(nil) doAssert cstr == nil doAssert cstr.isNil doAssert cstr != cstring("") + doAssert cstr.len == 0 + + when defined(js): + cstr.add(cstring("abc")) + doAssert cstr == cstring("abc") + + var nil1, nil2: cstring = nil + + nil1.add(nil2) + doAssert nil1 == cstring(nil) + doAssert nil2 == cstring(nil) + + nil1.add(cstring("")) + doAssert nil1 == cstring("") + doAssert nil2 == cstring(nil) + + nil1.add(nil2) + doAssert nil1 == cstring("") + doAssert nil2 == cstring(nil) + + nil2.add(nil1) + doAssert nil1 == cstring("") + doAssert nil2 == cstring("") proc main()= |