Added `loadfile` to standalone.
Tests now manually load the library file, instead of needing it to be installed.
This commit is contained in:
parent
cc199b0e57
commit
3d48c2eae0
|
@ -204,6 +204,7 @@ struct Environment defaultEnv()
|
||||||
{"prn", &print}, {"pch", &pChar}, {"penv", &printEnvO},
|
{"prn", &print}, {"pch", &pChar}, {"penv", &printEnvO},
|
||||||
{"eval", &parseEvalO},
|
{"eval", &parseEvalO},
|
||||||
#ifdef STANDALONE
|
#ifdef STANDALONE
|
||||||
|
{"loadfile", &loadFile},
|
||||||
{"inp", &takeInput},
|
{"inp", &takeInput},
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -771,9 +771,20 @@ int readFile(const char *filename, struct Environment *env) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Object loadFile(Object filename, Object _, struct Environment *env) {
|
||||||
|
if (isStringy(filename)) {
|
||||||
|
readFile(filename.string, env);
|
||||||
|
return numberObject(0);
|
||||||
|
}
|
||||||
|
return numberObject(1);
|
||||||
|
}
|
||||||
|
|
||||||
void repl(struct Environment *env)
|
void repl(struct Environment *env)
|
||||||
{
|
{
|
||||||
readFile(SCRIPTDIR "/repl.pbl", env);
|
if (readFile(SCRIPTDIR "/repl.pbl", env) == 1) {
|
||||||
|
fprintf(stderr, "Could not read '%s'\n", SCRIPTDIR "/repl.pbl");
|
||||||
|
fprintf(stderr, "Consider installing or reinstalling pebblisp.\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
int main(int argc, const char* argv[])
|
||||||
|
|
|
@ -66,6 +66,7 @@ Object parseEvalO(Object text, Object ignore, struct Environment *env);
|
||||||
|
|
||||||
#ifdef STANDALONE
|
#ifdef STANDALONE
|
||||||
Object takeInput(Object i1, Object i2, struct Environment *i3);
|
Object takeInput(Object i1, Object i2, struct Environment *i3);
|
||||||
|
Object loadFile(Object filename, Object _, struct Environment *env);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,9 +42,9 @@ fail() {
|
||||||
check() {
|
check() {
|
||||||
local output
|
local output
|
||||||
if (($VALGRIND == 1)); then
|
if (($VALGRIND == 1)); then
|
||||||
local output=$($VALCOM ./pl "$2")
|
local output=$($VALCOM ./pl "(loadfile \"examples/lib.pbl\") $2")
|
||||||
else
|
else
|
||||||
local output=$(./pl "$2")
|
local output=$(./pl "(loadfile \"examples/lib.pbl\") $2")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$output" == "$3" ]; then
|
if [ "$output" == "$3" ]; then
|
||||||
|
|
Loading…
Reference in New Issue