From 6b82fe0a251c9d555912bfdf903ba1059d8bf3c6 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Thu, 8 Dec 2022 14:30:41 +0100 Subject: [PATCH] :art: update ctor and super tests --- src/parse/check.c | 9 --------- tests/ctor/ctor_return.gw | 1 + tests/ctor/parent_ctor_only_in_new.gw | 9 --------- tests/super/super.gw | 12 ++++++++++++ tests/super/super_not_call.gw | 12 ++++++++++++ tests/super/super_outside.gw | 12 ++++++++++++ 6 files changed, 37 insertions(+), 18 deletions(-) delete mode 100644 tests/ctor/parent_ctor_only_in_new.gw create mode 100644 tests/super/super.gw create mode 100644 tests/super/super_not_call.gw create mode 100644 tests/super/super_outside.gw diff --git a/src/parse/check.c b/src/parse/check.c index 9c043805..fe356397 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -974,15 +974,6 @@ ANN Type check_exp_call1(const Env env, Exp_Call *const exp) { if(t) return t; } } -//puts(t->name); -// if(!is_func(env->gwion, t)) { -// if(is_class(env->gwion, t)) { -// const Value v = nspc_lookup_value0(t->info->base_type->nspc, insert_symbol("new")); -// if(v) t = v->type; -// } -// else -// } -//exit(3); if(is_func(env->gwion, exp->func->type)) function_alternative(env, exp->func->type, exp->args, exp->func->pos); return NULL; diff --git a/tests/ctor/ctor_return.gw b/tests/ctor/ctor_return.gw index dc95d371..0e1659ff 100644 --- a/tests/ctor/ctor_return.gw +++ b/tests/ctor/ctor_return.gw @@ -1,3 +1,4 @@ +#! [contains] statement inside constructor function should have no expression class C { operator new() { return this; } } diff --git a/tests/ctor/parent_ctor_only_in_new.gw b/tests/ctor/parent_ctor_only_in_new.gw deleted file mode 100644 index 5b0d2d2c..00000000 --- a/tests/ctor/parent_ctor_only_in_new.gw +++ /dev/null @@ -1,9 +0,0 @@ -class C { - operator new() {} -} - -class D extends C{ -} - -var D d; -d.C(); diff --git a/tests/super/super.gw b/tests/super/super.gw new file mode 100644 index 00000000..812fb6d0 --- /dev/null +++ b/tests/super/super.gw @@ -0,0 +1,12 @@ +#! [contains] new@0@C +class C { + operator new() { <<< __func__ >>>; } +} +class D extends C { +} + +class E extends D { + operator new() { super();} +} + +new D(); diff --git a/tests/super/super_not_call.gw b/tests/super/super_not_call.gw new file mode 100644 index 00000000..9d1c6b09 --- /dev/null +++ b/tests/super/super_not_call.gw @@ -0,0 +1,12 @@ +#! [contains] as a function call +class C { + operator new() { <<< __func__ >>>; } +} +class D extends C { +} + +class E extends D { + operator new() { super; } +} + +new D(); diff --git a/tests/super/super_outside.gw b/tests/super/super_outside.gw new file mode 100644 index 00000000..c39e57f7 --- /dev/null +++ b/tests/super/super_outside.gw @@ -0,0 +1,12 @@ +#! [contains] outside of constructor +class C { + operator new() { <<< __func__ >>>; } +} +class D extends C { +} + +class E extends D { + super; +} + +new D(); -- 2.43.0