summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2022-09-24 01:37:21 +0800
committerGitHub <noreply@github.com>2022-09-24 01:37:21 +0800
commit37ca97dd76c8e02228338c68aa3c5aed03074ed2 (patch)
tree9c5ca2cc6739a49bb58f74d1876456c7a12a4503 /tests
parent7739e23420c9a7a4ec7eccdddc0a39df9e905aa8 (diff)
downloadNim-37ca97dd76c8e02228338c68aa3c5aed03074ed2.tar.gz
close #15955; add a test case (#20414)
Diffstat (limited to 'tests')
-rw-r--r--tests/misc/m15955.nim4
-rw-r--r--tests/misc/m15955_main.nim11
-rw-r--r--tests/misc/t15955.nim22
3 files changed, 37 insertions, 0 deletions
diff --git a/tests/misc/m15955.nim b/tests/misc/m15955.nim
new file mode 100644
index 000000000..22da345db
--- /dev/null
+++ b/tests/misc/m15955.nim
@@ -0,0 +1,4 @@
+proc add*(a, b: int): int {.cdecl, exportc.} =
+    a + b
+proc sub*(a, b: int): int {.cdecl, exportc.} =
+    a - b
\ No newline at end of file
diff --git a/tests/misc/m15955_main.nim b/tests/misc/m15955_main.nim
new file mode 100644
index 000000000..a71af8121
--- /dev/null
+++ b/tests/misc/m15955_main.nim
@@ -0,0 +1,11 @@
+import stdtest/specialpaths
+import std/os
+
+const buildLib = buildDir / "libD20220923T19380"
+
+{.passL: buildLib.}
+proc add*(a, b: int):int {.cdecl, importc.}
+proc sub*(a, b: int):int {.cdecl, importc.}
+
+echo add(10, 5)
+echo sub(10, 5)
diff --git a/tests/misc/t15955.nim b/tests/misc/t15955.nim
new file mode 100644
index 000000000..7441e5398
--- /dev/null
+++ b/tests/misc/t15955.nim
@@ -0,0 +1,22 @@
+discard """
+joinable: false
+"""
+
+import stdtest/specialpaths
+import std/[osproc, strformat, os]
+
+const
+  nim = getCurrentCompilerExe()
+  buildLib = buildDir / "libD20220923T19380"
+  currentDir = splitFile(currentSourcePath).dir
+  file = currentDir / "m15955.nim"
+  main = currentDir / "m15955_main.nim"
+
+
+proc runCmd(cmd: string) =
+  let (msg, code) = execCmdEx(cmd)
+  doAssert code == 0, msg
+
+
+runCmd fmt"{nim} c -o:{buildLib} --nomain --nimMainPrefix:libA -f --app:staticlib {file}"
+runCmd fmt"{nim} c -r {main}"