From 2fda91ed55c0338d0d1a0f46fdba554ebfa649c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Mon, 4 May 2020 23:40:45 +0200 Subject: [PATCH] :white_check_mark: tree tests --- tests/tree/fptr_global0.gw | 3 +++ tests/tree/fptr_other_class.gw | 8 ++++++++ tests/tree/global_func0.gw | 11 +++++++++++ tests/tree/global_func3.gw | 4 ++++ tests/tree/global_func_already_defined.gw | 3 +++ tests/tree/global_var.gw | 1 + tests/tree/invalid_global_class.gw | 6 ++++++ tests/tree/invalid_global_file.gw | 4 ++++ tests/tree/not_global.gw | 6 ++++++ tests/tree/static_tmpl.gw | 14 ++++++++++++++ tests/tree/struct_global0.gw | 14 ++++++++++++++ 11 files changed, 74 insertions(+) create mode 100644 tests/tree/fptr_global0.gw create mode 100644 tests/tree/fptr_other_class.gw create mode 100644 tests/tree/global_func0.gw create mode 100644 tests/tree/global_func3.gw create mode 100644 tests/tree/global_func_already_defined.gw create mode 100644 tests/tree/global_var.gw create mode 100644 tests/tree/invalid_global_class.gw create mode 100644 tests/tree/invalid_global_file.gw create mode 100644 tests/tree/not_global.gw create mode 100644 tests/tree/static_tmpl.gw create mode 100644 tests/tree/struct_global0.gw diff --git a/tests/tree/fptr_global0.gw b/tests/tree/fptr_global0.gw new file mode 100644 index 00000000..2076ed56 --- /dev/null +++ b/tests/tree/fptr_global0.gw @@ -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 index 00000000..7a97e562 --- /dev/null +++ b/tests/tree/fptr_other_class.gw @@ -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 index 00000000..ee373b2e --- /dev/null +++ b/tests/tree/global_func0.gw @@ -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 index 00000000..061dfa3e --- /dev/null +++ b/tests/tree/global_func3.gw @@ -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 index 00000000..57358f7b --- /dev/null +++ b/tests/tree/global_func_already_defined.gw @@ -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 index 00000000..072245a2 --- /dev/null +++ b/tests/tree/global_var.gw @@ -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 index 00000000..a20ed9c0 --- /dev/null +++ b/tests/tree/invalid_global_class.gw @@ -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 index 00000000..c8eeaa35 --- /dev/null +++ b/tests/tree/invalid_global_file.gw @@ -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 index 00000000..e5ac6bbd --- /dev/null +++ b/tests/tree/not_global.gw @@ -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 index 00000000..b024fdd2 --- /dev/null +++ b/tests/tree/static_tmpl.gw @@ -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 index 00000000..57abb9ed --- /dev/null +++ b/tests/tree/struct_global0.gw @@ -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; -- 2.43.0