Files
Toy/test/scripts/coercions.toy

30 lines
405 B
Plaintext

//test int -> float coercion
{
var f: float = 0;
assert typeof f == float, "coercion on decl failed";
f = 42;
assert typeof f == float, "coercion on assign failed";
}
//test function coercion
{
fn f(arg: float) {
assert typeof arg == float, "argument coercion failed";
}
f(42);
fn g(): float {
return 42;
}
assert typeof g() == float, "return coercion failed";
}
print "All good";