]> Nishi Git Mirror - gwion.git/commitdiff
:white_check_mark: tree tests
authorJérémie Astor <astor.jeremie@wanadoo.fr>
Mon, 4 May 2020 21:40:45 +0000 (23:40 +0200)
committerJérémie Astor <astor.jeremie@wanadoo.fr>
Mon, 4 May 2020 21:40:45 +0000 (23:40 +0200)
tests/tree/fptr_global0.gw [new file with mode: 0644]
tests/tree/fptr_other_class.gw [new file with mode: 0644]
tests/tree/global_func0.gw [new file with mode: 0644]
tests/tree/global_func3.gw [new file with mode: 0644]
tests/tree/global_func_already_defined.gw [new file with mode: 0644]
tests/tree/global_var.gw [new file with mode: 0644]
tests/tree/invalid_global_class.gw [new file with mode: 0644]
tests/tree/invalid_global_file.gw [new file with mode: 0644]
tests/tree/not_global.gw [new file with mode: 0644]
tests/tree/static_tmpl.gw [new file with mode: 0644]
tests/tree/struct_global0.gw [new file with mode: 0644]

diff --git a/tests/tree/fptr_global0.gw b/tests/tree/fptr_global0.gw
new file mode 100644 (file)
index 0000000..2076ed5
--- /dev/null
@@ -0,0 +1,3 @@
+class C {
+typedef global void global_fptr(int i);
+}
diff --git a/tests/tree/fptr_other_class.gw b/tests/tree/fptr_other_class.gw
new file mode 100644 (file)
index 0000000..7a97e56
--- /dev/null
@@ -0,0 +1,8 @@
+#! [contains] can't use non global fptr of other class
+class C {
+  typedef void t_ptr() {}
+}
+class D {
+  typedef void t_ptr() {}
+  C->t_ptr ptr;
+}
diff --git a/tests/tree/global_func0.gw b/tests/tree/global_func0.gw
new file mode 100644 (file)
index 0000000..ee373b2
--- /dev/null
@@ -0,0 +1,11 @@
+123 => global int g_i;
+class global C {
+  13 => int i;
+}
+<<< g_i >>>;
+global C g_c;
+<<< g_c, "->i => ", g_c.i >>>;
+fun global void g_test() { <<< g_i >>>; <<< g_c >>>; <<< g_c.i >>>; <<< "test" >>>; }
+#!fun global void g_test() { <<< "test" >>>; }
+<<< g_test >>>;
+<<< g_test() >>>;
diff --git a/tests/tree/global_func3.gw b/tests/tree/global_func3.gw
new file mode 100644 (file)
index 0000000..061dfa3
--- /dev/null
@@ -0,0 +1,4 @@
+<<< int i >>>;
+fun global void this_global_func_will_fail_to_compile() {
+  <<< i >>>;
+}
diff --git a/tests/tree/global_func_already_defined.gw b/tests/tree/global_func_already_defined.gw
new file mode 100644 (file)
index 0000000..57358f7
--- /dev/null
@@ -0,0 +1,3 @@
+#! [contains] global function 'test' already defined for those arguments
+fun void test(){}
+fun void test(){}
diff --git a/tests/tree/global_var.gw b/tests/tree/global_var.gw
new file mode 100644 (file)
index 0000000..072245a
--- /dev/null
@@ -0,0 +1 @@
+<<< global int g_i >>>;
diff --git a/tests/tree/invalid_global_class.gw b/tests/tree/invalid_global_class.gw
new file mode 100644 (file)
index 0000000..a20ed9c
--- /dev/null
@@ -0,0 +1,6 @@
+#! [contains] 'global' can only be used at class scope
+class C {
+  {
+    global int i;
+  }
+}
diff --git a/tests/tree/invalid_global_file.gw b/tests/tree/invalid_global_file.gw
new file mode 100644 (file)
index 0000000..c8eeaa3
--- /dev/null
@@ -0,0 +1,4 @@
+#! [contains] 'global' can only be used at file scope
+{
+global int i;
+}
diff --git a/tests/tree/not_global.gw b/tests/tree/not_global.gw
new file mode 100644 (file)
index 0000000..e5ac6bb
--- /dev/null
@@ -0,0 +1,6 @@
+#! [contains] is not global
+class C {
+
+}
+
+global C c;
diff --git a/tests/tree/static_tmpl.gw b/tests/tree/static_tmpl.gw
new file mode 100644 (file)
index 0000000..b024fdd
--- /dev/null
@@ -0,0 +1,14 @@
+class global C {
+  fun static void t<~A~>() { <<< __func__ >>>; }
+}
+class D extends C {
+
+}
+
+fun void test(C c) {
+  C.t<~int~>();
+}
+
+#!D d;
+#!d.t<~int~>();
+#!d => test;
diff --git a/tests/tree/struct_global0.gw b/tests/tree/struct_global0.gw
new file mode 100644 (file)
index 0000000..57abb9e
--- /dev/null
@@ -0,0 +1,14 @@
+struct global GlobalStruct {
+  int i;
+  float f;
+  string s;
+}
+
+struct global GlobalStructWithCtor {
+  int i;
+  float f;
+  string s;
+}
+
+global GlobalStruct s;
+GlobalStructWithCtor sctor;