From 3cad4af1d68bc507771e634c8c089098fa219c93 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Tue, 22 Oct 2019 12:09:44 +0200 Subject: [PATCH] :art: More testing --- src/lib/import.c | 8 +++++--- tests/import/fptr_tmpl_fail.c | 5 +---- tests/import/func_tmpl.gw | 2 +- tests/import/func_tmpl_fail.c | 23 +++++++++++++++++++++++ tests/sh/import.sh | 2 +- 5 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 tests/import/func_tmpl_fail.c diff --git a/src/lib/import.c b/src/lib/import.c index 735a9a77..4df6d1e2 100644 --- a/src/lib/import.c +++ b/src/lib/import.c @@ -158,13 +158,15 @@ ANN static m_bool tmpl_list(const Gwion gwion, struct tmpl_checker *ck) { if(!i || s[i+1] != '>') break; c[i] = '\0'; - ck->list = new_id_list(gwion->mp, insert_symbol(gwion->st, c), ck->pos); + ck->list = new_id_list(gwion->mp, insert_symbol(gwion->st, c), + loc_cpy(gwion->mp, ck->pos)); return GW_OK; } if(s[i] == ',') { if(!i)break; c[i] = '\0'; - ck->list = new_id_list(gwion->mp, insert_symbol(gwion->st, c), ck->pos); + ck->list = new_id_list(gwion->mp, insert_symbol(gwion->st, c), + loc_cpy(gwion->mp, ck->pos)); struct tmpl_checker _ck = { .str=ck->str + i + 1, .pos=ck->pos }; CHECK_BB(tmpl_list(gwion, &_ck)) ck->list->next = _ck.list; @@ -681,7 +683,7 @@ ANN static Fptr_Def import_fptr(const Gwi gwi, DL_Func* dl_fun, ae_flag flag) { } ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag) { - const Fptr_Def fptr = import_fptr(gwi, &gwi->func, flag); + DECL_OO(const Fptr_Def, fptr, = import_fptr(gwi, &gwi->func, flag)) const m_bool ret = traverse_fptr_def(gwi->gwion->env, fptr); if(ret > 0) SET_FLAG(fptr->base->func, builtin); diff --git a/tests/import/fptr_tmpl_fail.c b/tests/import/fptr_tmpl_fail.c index 696ed983..03a311ba 100644 --- a/tests/import/fptr_tmpl_fail.c +++ b/tests/import/fptr_tmpl_fail.c @@ -11,11 +11,8 @@ #include "operator.h" #include "import.h" -static MFUN(test_func) { puts("test"); } GWION_IMPORT(typedef_test) { - Type t_func_typedef; - GWI_OB((t_func_typedef = gwi_mk_type(gwi, "FuncTypedef", SZ_INT , NULL))) - GWI_BB(gwi_fptr_ini(gwi, "int", "<~A.~>test")) + GWI_BB(gwi_fptr_ini(gwi, "int~", "<~A~>test")) GWI_OB(gwi_fptr_end(gwi, 0)) return GW_OK; } diff --git a/tests/import/func_tmpl.gw b/tests/import/func_tmpl.gw index a963bb52..4866c009 100644 --- a/tests/import/func_tmpl.gw +++ b/tests/import/func_tmpl.gw @@ -1,2 +1,2 @@ test<~int~>(1); -#!test(1); +test(1); diff --git a/tests/import/func_tmpl_fail.c b/tests/import/func_tmpl_fail.c new file mode 100644 index 00000000..338c5f79 --- /dev/null +++ b/tests/import/func_tmpl_fail.c @@ -0,0 +1,23 @@ +#include "gwion_util.h" +#include "gwion_ast.h" +#include "oo.h" +#include "vm.h" +#include "env.h" +#include "type.h" +#include "instr.h" +#include "object.h" +#include "gwion.h" +#include "value.h" +#include "operator.h" +#include "import.h" +#include "instr.h" + +static SFUN(func_tmpl_xfun) { + +} + +GWION_IMPORT(func_tmpl) { + GWI_BB(gwi_func_ini(gwi, "voit", "<~A~>test", func_tmpl_xfun)) + GWI_BB(gwi_func_end(gwi, 0)) + return GW_OK; +} diff --git a/tests/sh/import.sh b/tests/sh/import.sh index 921183dc..6edaf1a9 100644 --- a/tests/sh/import.sh +++ b/tests/sh/import.sh @@ -1,5 +1,5 @@ #!/bin/bash -# [test] #59 +# [test] #60 n=0 [ "$1" ] && n="$1" -- 2.43.0