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},
|
||||
{"eval", &parseEvalO},
|
||||
#ifdef STANDALONE
|
||||
{"loadfile", &loadFile},
|
||||
{"inp", &takeInput},
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -771,9 +771,20 @@ int readFile(const char *filename, struct Environment *env) {
|
|||
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)
|
||||
{
|
||||
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[])
|
||||
|
|
|
@ -66,6 +66,7 @@ Object parseEvalO(Object text, Object ignore, struct Environment *env);
|
|||
|
||||
#ifdef STANDALONE
|
||||
Object takeInput(Object i1, Object i2, struct Environment *i3);
|
||||
Object loadFile(Object filename, Object _, struct Environment *env);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -42,9 +42,9 @@ fail() {
|
|||
check() {
|
||||
local output
|
||||
if (($VALGRIND == 1)); then
|
||||
local output=$($VALCOM ./pl "$2")
|
||||
local output=$($VALCOM ./pl "(loadfile \"examples/lib.pbl\") $2")
|
||||
else
|
||||
local output=$(./pl "$2")
|
||||
local output=$(./pl "(loadfile \"examples/lib.pbl\") $2")
|
||||
fi
|
||||
|
||||
if [ "$output" == "$3" ]; then
|
||||
|
|
Loading…
Reference in New Issue