From: fennecdjay Date: Fri, 11 Oct 2019 20:39:20 +0000 (+0200) Subject: :art: Test import names X-Git-Tag: nightly~2169 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=a5dfba6d692c14a7e3c7efbd769c037c6af15fef;p=gwion.git :art: Test import names --- diff --git a/src/lib/import.c b/src/lib/import.c index 78912a79..5180ec5e 100644 --- a/src/lib/import.c +++ b/src/lib/import.c @@ -100,22 +100,20 @@ ANN static m_bool name_valid(const Gwi gwi, const m_str a) { || (c == '_') || (c >= '0' && c <= '9')) continue; if(c == '<') { + if(a[++i] != '~') + GWI_ERR_B(_("illegal templating in name '%s'."), a) lvl++; ++i; continue; - } - if(c == ',') { + } else if(c == ',') { if(!lvl) GWI_ERR_B(_("illegal use of ',' outside of templating in name '%s'."), a) - continue; - } - if(c == '~') { - if(!lvl) + } else if(c == '~') { + if(!lvl || a[++i] != '>') GWI_ERR_B(_("illegal templating in name '%s'."), a) lvl--; - continue; - } - GWI_ERR_B(_("illegal character '%c' in name '%s'."), c, a) + } else + GWI_ERR_B(_("illegal character '%c' in name '%s'."), c, a) } return !lvl ? 1 : -1; } diff --git a/tests/import/invalid_names.c b/tests/import/invalid_names.c new file mode 100644 index 00000000..abb817cb --- /dev/null +++ b/tests/import/invalid_names.c @@ -0,0 +1,33 @@ +#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" + +GWION_IMPORT(trig) { + const Type t0 = gwi_mk_type(gwi, "T~", SZ_INT, NULL); + gwi_add_type(gwi, t0); + + const Type t1 = gwi_mk_type(gwi, "T,", SZ_INT, NULL); + gwi_add_type(gwi, t1); + + const Type t2 = gwi_mk_type(gwi, "T", SZ_INT, NULL); + gwi_add_type(gwi, t2); + + const Type t3 = gwi_mk_type(gwi, "<~a~>T", SZ_INT, NULL); + gwi_add_type(gwi, t3); + + return GW_OK; +} diff --git a/tests/sh/import.sh b/tests/sh/import.sh index d0c1b0e0..0b2c480b 100644 --- a/tests/sh/import.sh +++ b/tests/sh/import.sh @@ -1,5 +1,5 @@ #!/bin/bash -# [test] #39 +# [test] #40 n=0 [ "$1" ] && n="$1"