mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Added to ternary expression tests
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
assert false ? false : true, "Basic false ternary failed";
|
assert false ? false : true, "Basic false ternary failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//test nesting
|
//test nesting
|
||||||
{
|
{
|
||||||
fn least(a, b, c) {
|
fn least(a, b, c) {
|
||||||
@@ -16,6 +15,23 @@
|
|||||||
assert least(9, 7, 5) == 5, "Least 9, 7, 5 failed";
|
assert least(9, 7, 5) == 5, "Least 9, 7, 5 failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//test division prevention
|
||||||
|
{
|
||||||
|
var x = 0;
|
||||||
|
assert x ? 0 : 1 / x == 0, "Division by zero prevention failed";
|
||||||
|
}
|
||||||
|
|
||||||
|
//test ambiguous syntax
|
||||||
|
{
|
||||||
|
var a = 1;
|
||||||
|
var b = 2;
|
||||||
|
var c = 3;
|
||||||
|
var d = 4;
|
||||||
|
var e = 5;
|
||||||
|
|
||||||
|
assert a ? b ? c : d : e == 3, "Ambiguous syntax failed";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
print "All good";
|
print "All good";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user