japl/tests/japl/comparisons.jpl

67 lines
861 B
Plaintext

//[Test: comparisons]
//[source: mixed]
var x = 4;
var y = 5;
var z = 6;
if (x < y)
print("1");//stdout:1
else
print("2");
if (x == y)
print("3");//stdout:4
else
print("4");
if (x > y)
print("5");//stdout:6
else if (x < y)
print("6");
if (y >= 5)
print("7");//stdout:7
else
print("8");
if (z >= 5)
print("9");//stdout:9
else
print("10");
if (x <= 4)
print("11");//stdout:11
else
print("12");
if (2 <= y)
print("13");//stdout:13
else
print("14");
if (8 <= z)
print("15");
else
print("16");//stdout:16
//[end]
//[end]
//[Test: multicomparisons]
//[skip]
//[source: mixed]
var x = 2 < 3 < 4;
print(x);//stdout:4
x = 1 > 3 < 5;
print(x);//stdout:false
x = 1 >= 0 >= 0;
print(x);//stdout:0
if ( 4 < x < 6 ) {
print("inside");
} else {
print("outside");//stdout:outside
}
//[end]
//[end]