aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2020-03-20 01:31:54 -0500
committerGanesh Viswanathan <dev@genotrance.com>2020-03-20 01:31:54 -0500
commitf01c7ea60dab54c14a9d44b359dcb025812470bc (patch)
treeaccdc3bf2de15de6fcc8e5298ba20aaa78688493 /tests
parent0d1445a8ac26bd842edf491a780fffc515fa1066 (diff)
downloadnimterop-f01c7ea60dab54c14a9d44b359dcb025812470bc.tar.gz
nimterop-f01c7ea60dab54c14a9d44b359dcb025812470bc.zip
ast2 improve override/skip, duplicates
Diffstat (limited to 'tests')
-rw-r--r--tests/include/tast2.h53
-rw-r--r--tests/tast2.nim12
2 files changed, 63 insertions, 2 deletions
diff --git a/tests/include/tast2.h b/tests/include/tast2.h
index 7c595e4..5cabfac 100644
--- a/tests/include/tast2.h
+++ b/tests/include/tast2.h
@@ -1,3 +1,55 @@
+#define A 1
+#define B 1.0
+#define C 0x10
+#define D "hello"
+#define E 'c'
+
+struct A0;
+struct A1 {};
+typedef struct A2;
+typedef struct A3 {};
+typedef struct A4 A4, *A4p;
+typedef const int A5;
+typedef int *A6;
+typedef A0 **A7;
+typedef void *A8;
+
+typedef char *A9p[3]; //, A9[4];
+typedef char *A10[3][6];
+typedef char *(*A11)[3];
+typedef struct A1 *A111[12];
+
+typedef int **(*A12)(int, int b, int *c, int *, int *count[4], int (*func)(int, int));
+typedef int A13(int, int);
+
+struct A14 { volatile char a1; };
+struct A15 { char *a1; const int *a2[1]; };
+
+typedef struct A16 { char f1; };
+typedef struct A17 { char *a1; int *a2[1]; } A18, *A18p;
+typedef struct { char *a1; int *a2[1]; } A19, *A19p;
+
+typedef struct A20 { char a1; } A20, A21, *A21p;
+
+//Expression
+typedef struct A22 { int **f1; int *f2[123+132]; } A22;
+
+//Unions
+union U1 {int f1; float f2; };
+typedef union U2 { int **f1; int abc[123+132]; } U2;
+
+// Anonymous
+//typedef struct { char a1; };
+
+//struct A2 test_proc1(struct A0 a);
+
+
+
+
+
+
+
+// DUPLICATES
#define A 1
#define B 1.0
@@ -18,6 +70,7 @@ typedef void *A8;
typedef char *A9p[3]; //, A9[4];
typedef char *A10[3][6];
typedef char *(*A11)[3];
+typedef struct A1 *A111[12];
typedef int **(*A12)(int, int b, int *c, int *, int *count[4], int (*func)(int, int));
typedef int A13(int, int);
diff --git a/tests/tast2.nim b/tests/tast2.nim
index 9e32f6e..40c7886 100644
--- a/tests/tast2.nim
+++ b/tests/tast2.nim
@@ -5,6 +5,13 @@ import nimterop/[cimport]
static:
cDebug()
+cOverride:
+ const
+ A* = 2
+
+ type
+ A1* = A0
+
cImport("include/tast2.h", flags="-d -f:ast2")
proc testFields(t: typedesc, fields: Table[string, string] = initTable[string, string]()) =
@@ -18,7 +25,7 @@ proc testFields(t: typedesc, fields: Table[string, string] = initTable[string, s
"typeof(" & $t & ":" & name & ") != " & fields[name] & ", is " & $typeof(value)
assert count == fields.len, "Failed for " & $t
-assert A == 1
+assert A == 2
assert B == 1.0
assert C == 0x10
assert D == "hello"
@@ -26,7 +33,7 @@ assert E == 'c'
assert A0 is object
testFields(A0)
-assert A1 is object
+assert A1 is A0
testFields(A1)
assert A2 is object
testFields(A2)
@@ -44,6 +51,7 @@ assert A9p is array[3, cstring]
#assert A9 is array[4, cchar]
assert A10 is array[3, array[6, cstring]]
assert A11 is ptr array[3, cstring]
+assert A111 is array[12, ptr A1]
assert A12 is proc(a1: cint, b: cint, c: ptr cint, a4: ptr cint, count: array[4, ptr cint], `func`: proc(a1: cint, a2: cint): cint): ptr ptr cint
assert A13 is proc(a1: cint, a2: cint): cint