summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorn5m <72841454+n5m@users.noreply.github.com>2020-10-18 16:57:13 +0000
committerGitHub <noreply@github.com>2020-10-18 12:57:13 -0400
commit78cbb52fa01d6c73307fe276bdf7d4c34d7a556c (patch)
treeb18910c0abacbebb81790821e1dfc5736f9e3793
parentba2a477e648513fac0183ae77990dfe16f890960 (diff)
downloadNim-78cbb52fa01d6c73307fe276bdf7d4c34d7a556c.tar.gz
add tests for #15584 (#15619)
* add test for #15584

* Rename userlocks.nim to trlocks.nim

* add bug comment

* improve cmd

* reference bugfix, not bug

* add test that runs rlocks

* disallow joining

joining with other test cases (e.g., a test case that invokes `RLock.initRLock()`) may cause this test to compile, when the goal is to test if these lines can be compiled in isolation
-rw-r--r--tests/stdlib/trlocks.nim14
-rw-r--r--tests/stdlib/tuserlocks.nim13
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/stdlib/trlocks.nim b/tests/stdlib/trlocks.nim
new file mode 100644
index 000000000..135d9b028
--- /dev/null
+++ b/tests/stdlib/trlocks.nim
@@ -0,0 +1,14 @@
+discard """
+  action: "compile"
+  # Disallow joining to ensure it can compile in isolation.
+  # See #15584
+  joinable: false
+  cmd: "nim $target --threads:on $options $file"
+"""
+
+# bugfix #15584
+
+import rlocks
+
+var r: RLock
+r.initRLock()
diff --git a/tests/stdlib/tuserlocks.nim b/tests/stdlib/tuserlocks.nim
new file mode 100644
index 000000000..f6eafa05d
--- /dev/null
+++ b/tests/stdlib/tuserlocks.nim
@@ -0,0 +1,13 @@
+discard """
+  cmd: "nim $target --threads:on $options $file"
+"""
+
+import rlocks
+
+var r: RLock
+r.initRLock()
+doAssert r.tryAcquire()
+doAssert r.tryAcquire()
+r.release()
+r.release()
+r.deinitRLock()