aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgenotrance <dev@genotrance.com>2018-12-29 18:54:04 -0600
committerGitHub <noreply@github.com>2018-12-29 18:54:04 -0600
commit6538424290feb1ced1d44938dcfc445686484814 (patch)
treeee9a7628d6f9b6c195c63197ca6887c73c60739b
parent1e086d59595c24ee8ec3f1dcc02b55d97fe9e2ec (diff)
parent6cc1e66ee20d081403faeacb10761a33747ea64f (diff)
downloadnimterop-6538424290feb1ced1d44938dcfc445686484814.tar.gz
nimterop-6538424290feb1ced1d44938dcfc445686484814.zip
Merge pull request #30 from timotheecour/pr_add_failing_tests
various fixes
-rw-r--r--nimterop.nimble2
-rw-r--r--tests/include/test.h3
-rw-r--r--tests/tnimterop_c.nim34
3 files changed, 34 insertions, 5 deletions
diff --git a/nimterop.nimble b/nimterop.nimble
index 13bafae..c3c87a7 100644
--- a/nimterop.nimble
+++ b/nimterop.nimble
@@ -18,7 +18,7 @@ proc execCmd(cmd:string)=
task test, "Test":
execCmd "nim c -r tests/tnimterop_c.nim"
- #execCmd "nim cpp -r tests/tnimterop_c.nim"
+ execCmd "nim cpp -r tests/tnimterop_c.nim"
execCmd "nim cpp -r tests/tnimterop_cpp.nim"
# when defined(windows):
# execCmd "nim c -r tests/tmath.nim"
diff --git a/tests/include/test.h b/tests/include/test.h
index 741fa97..8a8c579 100644
--- a/tests/include/test.h
+++ b/tests/include/test.h
@@ -20,6 +20,9 @@ extern "C" {
#define OSDEF 30
#endif
+#define foobar1(x) OSDEF * x
+#define foobar2(x) x + 1
+
typedef uint8_t PRIMTYPE;
typedef PRIMTYPE CUSTTYPE;
diff --git a/tests/tnimterop_c.nim b/tests/tnimterop_c.nim
index 74e1afa..0f53556 100644
--- a/tests/tnimterop_c.nim
+++ b/tests/tnimterop_c.nim
@@ -20,6 +20,10 @@ elif defined(windows):
else:
check OSDEF == 30
+block:
+ # workaround for https://github.com/nim-lang/Nim/issues/10129
+ const ok = OSDEF
+
var
pt: PRIMTYPE
ct: CUSTTYPE
@@ -50,7 +54,11 @@ s.field1 = 5
s2.field1 = 6
s3.field1 = 7
s4.field2[2] = 5
-s4.field3[3] = enum1
+when defined(cpp):
+ discard # TODO
+else: # TODO: what's `defined(cpp)` for c ?
+ s4.field3[3] = enum1
+
s5.tci = test_call_int
s5.tcp = test_call_param
s5.tcp8 = test_call_param8
@@ -67,15 +75,33 @@ check test_call_int() == 5
check test_call_param(5).field1 == 5
check test_call_param2(5, s2).field1 == 11
check test_call_param3(5, s).field1 == 10
-check test_call_param4(e) == e2
+# error: assigning to 'enum ENUM' from incompatible type 'NI' (aka 'long long')
+when defined(cpp):
+ discard # TODO
+else:
+ check test_call_param4(e) == e2
check test_call_param5(5.0).field2 == 5.0
check test_call_param6(u2) == 'c'
u.field1 = 4
check test_call_param7(u) == 4
-check test_call_param8(addr i) == 25.0
-check i == 25
+
+when defined(cpp):
+ # TODO
+ # note: candidate function not viable: no known conversion from 'NI *' (aka 'long long *') to 'int *' for 1st argument
+ # check test_call_param8(cast[ptr int](addr i)) == 25.0
+ discard
+else:
+ check test_call_param8(addr i) == 25.0
+ check i == 25
check e3 == enum7
check e4 == enum11
cAddStdDir()
+
+## failing tests
+when false:
+ static: # Error: undeclared identifier: 'foobar1'
+ doAssert foobar1(3) == OSDEF * 3
+when false: # Error: undeclared identifier: 'foobar2'
+ doAssert foobar2(3) == 3 + 1