summary refs log tree commit diff stats
path: root/tests/vm
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2023-08-21 21:08:00 +0300
committerGitHub <noreply@github.com>2023-08-21 20:08:00 +0200
commit942f846f04b4fa3c3154f7277ab1a8f6762d2714 (patch)
tree4949e988218d6fc76ab1ccaeea74e8bbb87cdd98 /tests/vm
parenta4781dc4bcdf6e76076af80d0b21cb09865b3d44 (diff)
downloadNim-942f846f04b4fa3c3154f7277ab1a8f6762d2714.tar.gz
fix getNullValue for cstring in VM, make other VM code aware of nil cstring (#22527)
* fix getNullValue for cstring in VM

fixes #22524

* very ugly fixes, but fix #15730

* nil cstring len works, more test lines

* fix high
Diffstat (limited to 'tests/vm')
-rw-r--r--tests/vm/tvmmisc.nim31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/vm/tvmmisc.nim b/tests/vm/tvmmisc.nim
index da8208f73..5760422a1 100644
--- a/tests/vm/tvmmisc.nim
+++ b/tests/vm/tvmmisc.nim
@@ -735,3 +735,34 @@ block: # bug #22190
     tab = mkOpTable(Berlin)
 
   doAssert not tab
+
+block: # issue #22524
+  const cnst = cstring(nil)
+  doAssert cnst.isNil
+  doAssert cnst == nil
+  let b = cnst
+  doAssert b.isNil
+  doAssert b == nil
+
+  let a = static: cstring(nil)
+  doAssert a.isNil
+
+  static:
+    var x: cstring
+    doAssert x.isNil
+    doAssert x == nil
+    doAssert x != ""
+
+block: # issue #15730
+  const s: cstring = ""
+  doAssert s != nil
+
+  static:
+    let s: cstring = ""
+    doAssert not s.isNil
+    doAssert s != nil
+    doAssert s == ""
+
+static: # more nil cstring issues
+  let x = cstring(nil)
+  doAssert x.len == 0