summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/js/tmangle.nim23
-rw-r--r--tests/stdlib/tsegfaults.nim29
2 files changed, 52 insertions, 0 deletions
diff --git a/tests/js/tmangle.nim b/tests/js/tmangle.nim
index 91193d5a7..c4167ba39 100644
--- a/tests/js/tmangle.nim
+++ b/tests/js/tmangle.nim
@@ -3,6 +3,8 @@ discard """
 true
 true
 true
+true
+true
 true'''
 """
 
@@ -64,6 +66,27 @@ block:
     result = result and obj2.`&&`.isNil()
   echo test()
 
+# Test codegen for fields with uppercase letters:
+block:
+  type MyObj = object
+    mField: int
+  proc test(): bool =
+    var a: MyObj
+    var b = a
+    result = b.mField == 0
+  echo test()
+
+# Test tuples
+block:
+  type T = tuple
+    a: int
+    b: int
+  proc test(): bool =
+    var a: T = (a: 1, b: 1)
+    result = a.a == 1
+    result = result and a.b == 1
+  echo test()
+
 # Test importc / exportc fields:
 block:
   type T = object
diff --git a/tests/stdlib/tsegfaults.nim b/tests/stdlib/tsegfaults.nim
new file mode 100644
index 000000000..1d8508c52
--- /dev/null
+++ b/tests/stdlib/tsegfaults.nim
@@ -0,0 +1,29 @@
+discard """
+  output: '''caught a crash!
+caught a crash!
+caught a crash!
+caught a crash!
+caught a crash!
+caught a crash!
+caught a crash!
+caught a crash!
+caught a crash!
+caught a crash!
+caught a crash!'''
+"""
+
+import segfaults
+
+proc main =
+  try:
+    var x: ptr int
+    echo x[]
+    try:
+      raise newException(ValueError, "not a crash")
+    except ValueError:
+      discard
+  except NilAccessError:
+    echo "caught a crash!"
+
+for i in 0..10:
+  main()