Files
Toy/scripts/test/imports-and-exports.toy

49 lines
636 B
Plaintext

//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 oftype keyword
{
var t: type = int;
export t;
}
{
import t;
assert oftype t == type, "type retention failed";
}
print "All good";