*val = '\0';
++val;
}
- const m_str key = str;
- for(m_uint i = 0; i < map_size(map); ++i) {
- if(!strcmp(key, (m_str)VKEY(map, i))) {
- free((m_str)VKEY(map, i));
- break;
- }
- }
- map_set(map, (vtype)key, (vtype)val);
+ map_set(map, (vtype)str, (vtype)val);
}
ANN m_bool _arg_parse(const Gwion gwion, Arg* arg) {
OperCK oper = {};
struct Gwi_ gwi = { .gwion=gwion, .loc=&loc, .oper=&oper };
const m_bool ret = f(&gwi);
+ if(ret < 0)
+ gwi_reset(&gwi);
gwion->env->name = name;
return ret;
}
typedef struct Plug_ {
void *dl;
void *self;
- int mod;
int imp;
} *Plug;
for(m_uint j = 0; j < map_size(map); ++j) {
if(!strcmp(name, (m_str)VKEY(map, j))) {
Plug plug = (Plug)VVAL(map, j);
- if(plug->mod)
- return;
- plug->mod = 1;
plug->self = ptr;
return;
}
--- /dev/null
+#include "gwion_util.h"
+#include "gwion_ast.h"
+#include "gwion_env.h"
+#include "vm.h"
+#include "gwion.h"
+#include "operator.h"
+#include "object.h"
+#include "instr.h"
+#include "import.h"
+
+GWION_IMPORT(end_class) {
+ (void)gwi;
+ return GW_OK;
+}
--- /dev/null
+#require NonExisting
+
+var ftbl f;
+<<< var SinOsc s >>>;
GWMODINI(get_module) {
puts(__func__);
- return (void*)2;
+ return NULL;
}
GWMODEND(get_module) {
}
GWION_IMPORT(dummy_module) {
- CHECK_OB(get_module(gwi->gwion, "dummy_module"))
+ set_module(gwi->gwion, "get_module", (void*)1);
+ CHECK_OB(get_module(gwi->gwion, "get_module"))
puts("test passed");
get_module(gwi->gwion, "non_existant_module");
return GW_OK;
--- /dev/null
+#require get_module
+<<< __file__ >>>;
#require coverage
+#require coverage
+
<<< var float f >>>;
var Coverage c;
c.s_i;
--- /dev/null
+#include "gwion_util.h"
+#include "gwion_ast.h"
+#include "gwion_env.h"
+#include "vm.h"
+#include "object.h"
+#include "instr.h"
+#include "gwion.h"
+#include "operator.h"
+#include "import.h"
+#include "gwi.h"
+
+GWION_IMPORT(deps) {
+ (void)gwi;
+ return GW_OK;
+}
+
+static const m_str deps[] = { "array", NULL };
+GWDEPEND { return deps; }
--- /dev/null
+#require deps
+
+<<< __file__ >>>;
+++ /dev/null
-op_already_imported.gw
#!/bin/bash
-# [test] #75
+# [test] #78
n=0
[ "$1" ] && n="$1"
export PRG="../../gwion"
export SUPP="../../scripts/supp"
make
-# we might have a test file for all now
if [ -f "$NAME.gw" ]
then GWOPT+="-p." test_gw "$NAME.gw" "$n"
else GWOPT+="-p." test_gw "no_file" "$n"
for test_file in *.c
do test_plugin "$(basename "$test_file" .c)"
done
+PRG="../../gwion" make NAME="array"
+test_plugin "deps" "$n"
+make NAME="array" clean
popd
+
pushd tests/driver || exit
for test_file in *.c
do
NAME="$(basename "$test_file" .c)"
- GWOPT+="-d $NAME" test_plugin "$(basename "$test_file" .c)"
+ DRIVER="$NAME=some_arg" test_plugin "$(basename "$test_file" .c)"
done
popd || exit
for test_file in *.c
do
NAME="$(basename "$test_file" .c)"
- GWOPT+="-m $NAME" test_plugin "$NAME"
+ MODULE="$NAME=some_arg" test_plugin "$NAME"
done
popd || exit
#!/bin/bash
-# [test] #20
+# [test] #21
n=0
[ "$1" ] && n="$1"
# config
n=$((n+1))
-RC=tmp_gwionrc
-cat << EOF >> "$RC"
+RC=./tmp_gwionrc
+cat << EOF > "$RC"
-p.
-l0
EOF
-run "$n" "config" "-c $RC" "file"
-rm "$RC"
+run "$n" "config" "-c$RC" "file"
+./gwion -c ./tmp_gwionrc
+#GWOPT="-c ./$RC" run "$n" "config" "" "file"
+#rm "$RC"
# loop
n=$((n+1))
n=$((n+1))
run "$n" "option needs argument" "-p" "file"
+# option needs argument
+n=$((n+1))
+echo "<<< __file__ >>>;" | run "$n" "stdin" "-" "file"
+
# invalid global type
n=$((n+1))
run "$n" "invalid global type" "examples/complex/invalid_type0.gw examples/complex/invalid_type1.gw" "file"
var A a1;
}
-var D:[int] si;
-var D:[float] sf;
+var S:[int] si;
+var S:[float] sf;
<<< si.a0 >>>;
<<< sf.a0 >>>;