diff options
Diffstat (limited to 'tests/let')
-rw-r--r-- | tests/let/timportc.nim | 24 | ||||
-rw-r--r-- | tests/let/timportc2.nim | 8 |
2 files changed, 32 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 diff --git a/tests/let/timportc2.nim b/tests/let/timportc2.nim new file mode 100644 index 000000000..964305923 --- /dev/null +++ b/tests/let/timportc2.nim @@ -0,0 +1,8 @@ +discard """ + errormsg: "'let' symbol requires an initialization" + line: "7" +""" + +# Test that this still works when not annotated with importc +let test: cint +echo test |