mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Resolved #45, Exports region removed
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
//test basic import/export
|
||||
{
|
||||
var variable: int = 42;
|
||||
export variable as field;
|
||||
}
|
||||
|
||||
{
|
||||
import field as value;
|
||||
assert value == 42, "import/export failed";
|
||||
}
|
||||
|
||||
|
||||
//test functions using import/export
|
||||
{
|
||||
fn f() {
|
||||
import field;
|
||||
|
||||
assert field == 42, "import in function failed";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//test importing/exporting of functions
|
||||
{
|
||||
fn func() {
|
||||
return 69;
|
||||
}
|
||||
|
||||
export func;
|
||||
}
|
||||
|
||||
{
|
||||
import func;
|
||||
assert func() == 69, "import/export of functions failed";
|
||||
}
|
||||
|
||||
|
||||
//test that variables retain their types with the typeof keyword
|
||||
{
|
||||
var t: type = int;
|
||||
|
||||
export t;
|
||||
}
|
||||
|
||||
{
|
||||
import t;
|
||||
|
||||
assert typeof t == type, "type retention failed";
|
||||
}
|
||||
|
||||
|
||||
print "All good";
|
||||
@@ -1,11 +0,0 @@
|
||||
//test exports
|
||||
var field: int = 42;
|
||||
|
||||
fn function() {
|
||||
return 69;
|
||||
}
|
||||
|
||||
export field;
|
||||
export function;
|
||||
|
||||
print "All good";
|
||||
@@ -1,10 +0,0 @@
|
||||
//test imports
|
||||
import field;
|
||||
//import function;
|
||||
|
||||
//assert field == 42, "import field failed";
|
||||
|
||||
//assert function() == 69, "import function failed";
|
||||
|
||||
print "All good";
|
||||
|
||||
@@ -186,7 +186,6 @@ int main() {
|
||||
"dot-chaining.toy",
|
||||
"dottify-bugfix.toy",
|
||||
"functions.toy",
|
||||
"imports-and-exports.toy",
|
||||
"index-arrays.toy",
|
||||
"index-dictionaries.toy",
|
||||
"index-strings.toy",
|
||||
@@ -212,38 +211,6 @@ int main() {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
//read source
|
||||
size_t dummy;
|
||||
size_t exportSize, importSize;
|
||||
char* exportSource = readFile("scripts/separate-exports.toy", &dummy);
|
||||
char* importSource = readFile("scripts/separate-imports.toy", &dummy);
|
||||
|
||||
//compile
|
||||
unsigned char* exportBinary = compileString(exportSource, &exportSize);
|
||||
unsigned char* importBinary = compileString(importSource, &importSize);
|
||||
|
||||
//run the interpreter over both binaries
|
||||
Interpreter interpreter;
|
||||
initInterpreter(&interpreter);
|
||||
|
||||
//NOTE: supress print output for testing
|
||||
setInterpreterPrint(&interpreter, noPrintFn);
|
||||
setInterpreterAssert(&interpreter, noAssertFn);
|
||||
|
||||
runInterpreter(&interpreter, exportBinary, exportSize); //automatically frees the binary data
|
||||
|
||||
resetInterpreter(&interpreter);
|
||||
|
||||
runInterpreter(&interpreter, importBinary, importSize); //automatically frees the binary data
|
||||
|
||||
freeInterpreter(&interpreter);
|
||||
|
||||
//cleanup
|
||||
free((void*)exportSource);
|
||||
free((void*)importSource);
|
||||
}
|
||||
|
||||
//1, to allow for the assertion test
|
||||
if (ignoredAssertions > 1) {
|
||||
fprintf(stderr, ERROR "Assertions hidden: %d\n", ignoredAssertions);
|
||||
|
||||
Reference in New Issue
Block a user