From: fennecdjay Date: Mon, 21 Oct 2019 18:02:16 +0000 (+0200) Subject: :art: More tests X-Git-Tag: nightly~2116^2~47 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=99eb2f682c7f8bde6d8b5078ae580d531e1979a6;p=gwion.git :art: More tests --- diff --git a/tests/import/class_template_invalid.c b/tests/import/class_template_invalid.c new file mode 100644 index 00000000..ba3dbc51 --- /dev/null +++ b/tests/import/class_template_invalid.c @@ -0,0 +1,48 @@ +#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 "value.h" +#include "operator.h" +#include "import.h" +#include "gwi.h" + +static m_int o_map_key; +static m_int o_map_value; +#define MAP_KEY(a) *((M_Object*)(a->data + o_map_key)) +#define MAP_VAL(a) *((M_Object*)(a->data + o_map_value)) +static CTOR(class_template_ctor) { + /*char* name = strdup(o->type_ref->name);*/ + /*char* tmp = strsep(&name, "@");*/ + /*char* name1 = strsep(&name, "@");*/ +/*Type t1 = nspc_lookup_type1(o->type_ref->info->parent, insert_symbol(name1));*/ + /*Type t2 = nspc_lookup_type0(shred->vm->emit->env->curr, insert_symbol(name));*/ +/*free(tmp);*/ +/**(M_Object*)(o->data) = new_array(t1->size, 0, t1->array_depth);*/ + /**(M_Object*)(o->data + SZ_INT) = new_array(t2->size, 0, t2->array_depth);*/ +} + +GWION_IMPORT(class_template) { + Type t_class_template; + const m_str list[2] = { "A", "B" }; + gwi_tmpl_ini(gwi, 2, list); + GWI_OB((t_class_template = gwi_mk_type(gwi, "ClassTemplate", SZ_INT, "Object"))) + GWI_BB(gwi_class_ini(gwi, t_class_template, class_template_ctor, NULL)) + gwi_tmpl_end(gwi); + GWI_BB(gwi_item_ini(gwi, "A[]", "key")) + GWI_BB((o_map_key = gwi_item_end(gwi, ae_flag_member | ae_flag_template, NULL))) + GWI_BB(gwi_item_ini(gwi, "B[]", "value")) + GWI_BB((o_map_value = gwi_item_end(gwi, ae_flag_member, NULL))) + GWI_BB(gwi_func_ini(gwi, "int", "<~C,D'~>test", (f_xfun)1)) + GWI_BB(gwi_func_end(gwi, ae_flag_none)) + + GWI_BB(gwi_class_end(gwi)) + GWI_BB(gwi_item_ini(gwi, "ClassTemplate<~Ptr<~int~>,int[]~>", "testObject")) + GWI_BB(gwi_item_end(gwi, ae_flag_none, NULL)) + return GW_OK; +} diff --git a/tests/sh/import.sh b/tests/sh/import.sh index e44592d8..2221b7dd 100644 --- a/tests/sh/import.sh +++ b/tests/sh/import.sh @@ -1,5 +1,5 @@ #!/bin/bash -# [test] #56 +# [test] #57 n=0 [ "$1" ] && n="$1"