From: fennecdjay Date: Thu, 11 Jul 2019 14:46:41 +0000 (+0200) Subject: :white_check_mark: More tests X-Git-Tag: nightly~2348^2~2 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=85f2744e8330da51891ff75b49e560c9170ac935;p=gwion.git :white_check_mark: More tests --- diff --git a/tests/error/fork_value.gw b/tests/error/fork_value.gw new file mode 100644 index 00000000..977f3e55 --- /dev/null +++ b/tests/error/fork_value.gw @@ -0,0 +1,2 @@ +#! [contains] forks must be stored in a value +fork { <<< 1 >>>; }; diff --git a/tests/error/fptr_other_class.gw b/tests/error/fptr_other_class.gw new file mode 100644 index 00000000..7a97e562 --- /dev/null +++ b/tests/error/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/error/non_public_typedef_global_scope.gw b/tests/error/non_public_typedef_global_scope.gw new file mode 100644 index 00000000..df46f923 --- /dev/null +++ b/tests/error/non_public_typedef_global_scope.gw @@ -0,0 +1,5 @@ +#! [contains] can't use non public typedef at global scope +class C { + typedef void t_ptr(); +} +C->t_ptr ptr; diff --git a/tests/error/non_static_from_member.gw b/tests/error/non_static_from_member.gw new file mode 100644 index 00000000..a08ab169 --- /dev/null +++ b/tests/error/non_static_from_member.gw @@ -0,0 +1,5 @@ +#! [contains] non-static member 'i' used from static function +class C { + int i; + fun static void test() { <<< i >>>; } +} diff --git a/tests/error/stack_overflow.gw b/tests/error/stack_overflow.gw new file mode 100644 index 00000000..71525195 --- /dev/null +++ b/tests/error/stack_overflow.gw @@ -0,0 +1,3 @@ +#! [contains] StackOverflow +fun void test() { test(); } +test(); diff --git a/tests/error/typedef_func_tmpl_types.gw b/tests/error/typedef_func_tmpl_types.gw new file mode 100644 index 00000000..71aa91d9 --- /dev/null +++ b/tests/error/typedef_func_tmpl_types.gw @@ -0,0 +1,15 @@ +#! [contains] pre-defined types +typedef void t_ptr<~A~>(); + +<~int~>t_ptr iptr; + +fun void test<~A~>() { + <<< __func__ >>>; +} + +test @=> iptr; +#!<<< iptr<~int~>() >>>; +<<< iptr() >>>; +<<< iptr<~int~>() >>>; +<<< iptr<~float~>() >>>; +<<< iptr<~Object~>() >>>; diff --git a/tests/error/typedef_func_tmpl_types2.gw b/tests/error/typedef_func_tmpl_types2.gw new file mode 100644 index 00000000..5a8210aa --- /dev/null +++ b/tests/error/typedef_func_tmpl_types2.gw @@ -0,0 +1,12 @@ +#! [contains] pre-defined types +typedef void t_ptr<~A~>(); +typedef <~int~>t_ptr B; + +fun void test<~A~>() { + <<< __func__ >>>; +} + +test @=> B b; +#!<<< iptr<~int~>() >>>; +<<< b() >>>; +<<< b<~int~>() >>>; diff --git a/tests/import/fptr.c b/tests/import/fptr.c new file mode 100644 index 00000000..82b9f838 --- /dev/null +++ b/tests/import/fptr.c @@ -0,0 +1,29 @@ +#include "gwion_util.h" +#include "gwion_ast.h" +#include "oo.h" +#include "vm.h" +#include "env.h" +#include "type.h" +#include "object.h" +#include "instr.h" +#include "gwion.h" +#include "operator.h" +#include "import.h" + +static MFUN(test_func) { puts("test"); } +GWION_IMPORT(typedef_test) { + Type t_func_typedef; + CHECK_OB((t_func_typedef = gwi_mk_type(gwi, "FuncTypedef", SZ_INT , NULL))) + CHECK_BB(gwi_fptr_ini(gwi, "void", "PtrType")) + CHECK_OB(gwi_fptr_end(gwi, 0)) + + CHECK_BB(gwi_class_ini(gwi, t_func_typedef, NULL, NULL)) + CHECK_BB(gwi_fptr_ini(gwi, "void", "PtrType")) + CHECK_OB(gwi_fptr_end(gwi, ae_flag_static)) + CHECK_BB(gwi_func_ini(gwi, "void", "test_func", test_func)) + CHECK_BB(gwi_func_end(gwi, ae_flag_static)) + CHECK_BB(gwi_item_ini(gwi, "PtrType", "ptr")) + CHECK_BB(gwi_item_end(gwi, ae_flag_static, NULL)) + CHECK_BB(gwi_class_end(gwi)) + return GW_OK; +} diff --git a/tests/import/fptr.gw b/tests/import/fptr.gw new file mode 100644 index 00000000..28639334 --- /dev/null +++ b/tests/import/fptr.gw @@ -0,0 +1,13 @@ +fun void test(){ <<< "test" >>>; } +PtrType ptr; +test(); +test @=> ptr; +ptr(); + + +FuncTypedef.test_func(); +<<< FuncTypedef.test_func @=> FuncTypedef.ptr >>>; + _ptr; +<<< FuncTypedef.ptr >>>; +FuncTypedef.ptr(); + diff --git a/tests/import/typedef.c b/tests/import/typedef.c index 82b9f838..5e08baf1 100644 --- a/tests/import/typedef.c +++ b/tests/import/typedef.c @@ -10,20 +10,8 @@ #include "operator.h" #include "import.h" -static MFUN(test_func) { puts("test"); } GWION_IMPORT(typedef_test) { - Type t_func_typedef; - CHECK_OB((t_func_typedef = gwi_mk_type(gwi, "FuncTypedef", SZ_INT , NULL))) - CHECK_BB(gwi_fptr_ini(gwi, "void", "PtrType")) - CHECK_OB(gwi_fptr_end(gwi, 0)) - - CHECK_BB(gwi_class_ini(gwi, t_func_typedef, NULL, NULL)) - CHECK_BB(gwi_fptr_ini(gwi, "void", "PtrType")) - CHECK_OB(gwi_fptr_end(gwi, ae_flag_static)) - CHECK_BB(gwi_func_ini(gwi, "void", "test_func", test_func)) - CHECK_BB(gwi_func_end(gwi, ae_flag_static)) - CHECK_BB(gwi_item_ini(gwi, "PtrType", "ptr")) - CHECK_BB(gwi_item_end(gwi, ae_flag_static, NULL)) - CHECK_BB(gwi_class_end(gwi)) + GWI_OB(gwi_typedef_ini(gwi, "int", "Typedef")) + GWI_OB(gwi_typedef_end(gwi, ae_flag_none)) return GW_OK; } diff --git a/tests/import/typedef.gw b/tests/import/typedef.gw index 28639334..7cbe1087 100644 --- a/tests/import/typedef.gw +++ b/tests/import/typedef.gw @@ -1,13 +1,4 @@ -fun void test(){ <<< "test" >>>; } -PtrType ptr; -test(); -test @=> ptr; -ptr(); - - -FuncTypedef.test_func(); -<<< FuncTypedef.test_func @=> FuncTypedef.ptr >>>; - _ptr; -<<< FuncTypedef.ptr >>>; -FuncTypedef.ptr(); - +Typedef t; +#!fun int test(int i) { <<< i >>>; } +#!test @=> t; +<<< t >>>; diff --git a/tests/sh/plugin.sh b/tests/sh/plugin.sh index b1cd9ac6..1d873c29 100644 --- a/tests/sh/plugin.sh +++ b/tests/sh/plugin.sh @@ -1,5 +1,5 @@ #!/bin/bash -# [test] #31 +# [test] #32 n=0 [ "$1" ] && n="$1" diff --git a/tests/tree/typedef_func.gw b/tests/tree/typedef_func.gw new file mode 100644 index 00000000..a521755d --- /dev/null +++ b/tests/tree/typedef_func.gw @@ -0,0 +1,8 @@ +typedef void t_ptr(int i); +typedef t_ptr A; +A a; +<<>>; + +fun void test(int i) { <<< __func__ , " ", i>>>; } +test @=> a; +a(1); diff --git a/tests/tree/typedef_func_class.gw b/tests/tree/typedef_func_class.gw new file mode 100644 index 00000000..f77ac2f7 --- /dev/null +++ b/tests/tree/typedef_func_class.gw @@ -0,0 +1,14 @@ +class C { +typedef void t_ptr(); +typedef t_ptr A; +A a; +<<>>; + +fun void test() { <<< __func__ >>>; } +test @=> a; +a(); +a(); +a(); +} + +C c; diff --git a/tests/tree/typedef_func_tmpl.gw b/tests/tree/typedef_func_tmpl.gw new file mode 100644 index 00000000..cfa7ddff --- /dev/null +++ b/tests/tree/typedef_func_tmpl.gw @@ -0,0 +1,16 @@ +typedef void t_ptr<~A~>(); + +<~int~>t_ptr iptr; +<~float~>t_ptr fptr; + +fun void test<~A~>() { + <<< __func__ >>>; +} + +test @=> iptr; +test @=> fptr; + +<<< iptr() >>>; +<<< iptr() >>>; +<<< fptr() >>>; +<<< fptr() >>>; diff --git a/tests/tree/typedef_func_tmpl2.gw b/tests/tree/typedef_func_tmpl2.gw new file mode 100644 index 00000000..98e11c31 --- /dev/null +++ b/tests/tree/typedef_func_tmpl2.gw @@ -0,0 +1,24 @@ +typedef void t_ptr<~A~>(); +fun void test<~A~>() { + <<< __func__ >>>; +} + +typedef <~int~>t_ptr B; +B b; +<<< b >>>; +test @=> b; +<<< b >>>; +<<< b() >>>; +<<< b() >>>; + + +typedef <~float~>t_ptr C; +C c; +<<< c >>>; +test @=> c; +<<< c >>>; +<<< c() >>>; +<<< c() >>>; + +<<< b() >>>; +<<< c() >>>; diff --git a/tests/tree/typedef_func_tmpl_class.gw b/tests/tree/typedef_func_tmpl_class.gw new file mode 100644 index 00000000..3b91c5a2 --- /dev/null +++ b/tests/tree/typedef_func_tmpl_class.gw @@ -0,0 +1,16 @@ +class C { + typedef void t_ptr<~A~>(); + + <~int~>t_ptr iptr; + + fun void test<~A~>() { + <<< this, " ", __func__ >>>; + } + + test @=> iptr; + <<< iptr() >>>; +#! <<< iptr() >>>; +} +<<>>; + <<< c.iptr() >>>; +#! <<< c.iptr() >>>;