summary refs log tree commit diff stats
path: root/tests/let/timportc.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/let/timportc.nim')
-rw-r--r--tests/let/timportc.nim24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/let/timportc.nim b/tests/let/timportc.nim
new file mode 100644
index 000000000..85244da9f
--- /dev/null
+++ b/tests/let/timportc.nim
@@ -0,0 +1,24 @@
+discard """
+targets: "c cpp js"
+"""
+
+when defined(c) or defined(cpp):
+  {.emit:"""
+  const int TEST1 = 123;
+  #define TEST2 321
+  """.}
+
+when defined(js):
+  {.emit:"""
+  const TEST1 = 123;
+  const TEST2 = 321; // JS doesn't have macros, so we just duplicate
+  """.}
+
+let
+  TEST0 = 1
+  TEST1 {.importc, nodecl.}: cint
+  TEST2 {.importc, nodecl.}: cint
+
+doAssert TEST0 == 1
+doAssert TEST1 == 123
+doAssert TEST2 == 321