From 9c1c9043ae9cd3287bdce363e64ebdee0820c4c9 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Sat, 12 Oct 2019 03:30:10 +0200 Subject: [PATCH] :art: Test class_ext --- tests/import/extend_fail_before.c | 20 ++++++++++++++++++ tests/import/extend_fail_empty.c | 28 +++++++++++++++++++++++++ tests/import/extend_fail_set.c | 28 +++++++++++++++++++++++++ tests/import/str2decl.c | 34 +++++++++++++++++++++++++++++++ tests/sh/common.sh | 2 +- 5 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 tests/import/extend_fail_before.c create mode 100644 tests/import/extend_fail_empty.c create mode 100644 tests/import/extend_fail_set.c create mode 100644 tests/import/str2decl.c diff --git a/tests/import/extend_fail_before.c b/tests/import/extend_fail_before.c new file mode 100644 index 00000000..032bd271 --- /dev/null +++ b/tests/import/extend_fail_before.c @@ -0,0 +1,20 @@ +#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 "instr.h" +#include "vm.h" +#include "gwion.h" +#include "value.h" +#include "operator.h" +#include "import.h" +#include "gwi.h" + +GWION_IMPORT(extend_event_test) { + Type_Decl* td = new_type_decl(gwi->gwion->st->p, new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "Event"), GWI_LOC)); + return gwi_class_ext(gwi, td); +} diff --git a/tests/import/extend_fail_empty.c b/tests/import/extend_fail_empty.c new file mode 100644 index 00000000..2cd87ee7 --- /dev/null +++ b/tests/import/extend_fail_empty.c @@ -0,0 +1,28 @@ +#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 "instr.h" +#include "vm.h" +#include "gwion.h" +#include "value.h" +#include "operator.h" +#include "import.h" +#include "gwi.h" + +static CTOR(ev_ctor) { printf(" %p this to test ctor\n", (void*)o); } + +GWION_IMPORT(extend_event_test) { + Type t_ev ; + GWI_OB((t_ev = gwi_mk_type(gwi, "Ev", SZ_INT , NULL))) + GWI_BB(gwi_class_ini(gwi, t_ev, ev_ctor, NULL)) + Type_Decl* td = new_type_decl(gwi->gwion->st->p, new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "Event"), GWI_LOC)); + td->array = new_array_sub(gwi->gwion->mp, NULL); + GWI_BB(gwi_class_ext(gwi, td)) + GWI_BB(gwi_class_end(gwi)) + return GW_OK; +} diff --git a/tests/import/extend_fail_set.c b/tests/import/extend_fail_set.c new file mode 100644 index 00000000..323eff80 --- /dev/null +++ b/tests/import/extend_fail_set.c @@ -0,0 +1,28 @@ +#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 "instr.h" +#include "vm.h" +#include "gwion.h" +#include "value.h" +#include "operator.h" +#include "import.h" +#include "gwi.h" + +static CTOR(ev_ctor) { printf(" %p this to test ctor\n", (void*)o); } + +GWION_IMPORT(extend_event_test) { + Type t_ev ; + GWI_OB((t_ev = gwi_mk_type(gwi, "Ev", SZ_INT , NULL))) + GWI_BB(gwi_class_ini(gwi, t_ev, ev_ctor, NULL)) + Type_Decl* td = new_type_decl(gwi->gwion->st->p, new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "Event"), GWI_LOC)); + GWI_BB(gwi_class_ext(gwi, td)) + GWI_BB(gwi_class_ext(gwi, td)) + GWI_BB(gwi_class_end(gwi)) + return GW_OK; +} diff --git a/tests/import/str2decl.c b/tests/import/str2decl.c new file mode 100644 index 00000000..b27a4053 --- /dev/null +++ b/tests/import/str2decl.c @@ -0,0 +1,34 @@ +#include +#include +#include "gwion_util.h" +#include "gwion_ast.h" +#include "oo.h" +#include "env.h" +#include "vm.h" +#include "gwion.h" +#include "type.h" +#include "instr.h" +#include "object.h" +#include "value.h" +#include "operator.h" +#include "import.h" +#include "ugen.h" +#include "func.h" +#include "gwi.h" + +ANN /*static */m_bool _path_valid(const Env env, const m_str path, const loc_t); +GWION_IMPORT(str2decl) { +// const m_str list[2] = { "A", "B" }; +// gwi_tmpl_ini(gwi, 2, list); + const Type t_t0 = gwi_mk_type(gwi, "Test", SZ_INT, "Object"); + GWI_BB(gwi_class_ini(gwi, t_t0, NULL, NULL)) +// gwi_tmpl_end(gwi); + const Type t_t2 = gwi_mk_type(gwi, "Child", SZ_INT, "Object"); + GWI_BB(gwi_class_ini(gwi, t_t2, NULL, NULL)) + GWI_BB(gwi_class_end(gwi)) + GWI_BB(gwi_class_end(gwi)) +// const Type t_t1 = gwi_mk_type(gwi, "Test2", SZ_INT, "<~int,<~int~>Ptr~>Test.Child"); + const Type t_t1 = gwi_mk_type(gwi, "Test2", SZ_INT, "Test.Child"); + GWI_BB(gwi_class_ini(gwi, t_t1, NULL, NULL)) + return gwi_class_end(gwi); +} diff --git a/tests/sh/common.sh b/tests/sh/common.sh index 68b45243..bbb9906c 100644 --- a/tests/sh/common.sh +++ b/tests/sh/common.sh @@ -1,5 +1,5 @@ #!/bin/bash -# [test] #0 +# [test] #53 set -m : "${GWOPT:=}" -- 2.43.0