Newer
Older
zweic / tests / 5 / antoineyersion / arithmetic(2).zwei
@glproj03 glproj03 on 6 Feb 2006 1 KB compiler working!
//#isut
// Evaluate arithmetic expression and logical expression in an arithmetic context

{
	// arithmetic binary expression
	// all results should be equal to 2
	printInt(1 + 1);printChar(10);printChar(13);
	printInt(3 - 1);printChar(10);printChar(13);
	printInt(2 * 1);printChar(10);printChar(13);
	printInt(17 / 6);printChar(10);printChar(13);
	printInt(754 % 16);printChar(10);printChar(13);
	
	// logical binary expression
	// the result should be a succession of 0 and 1
	printInt(1 == 1);printChar(10);printChar(13);
	printInt(1 == 0);printChar(10);printChar(13);
	printInt(1 != 0);printChar(10);printChar(13);
	printInt(1 != 1);printChar(10);printChar(13);
	printInt(1 < 2);printChar(10);printChar(13);
	printInt(1 < 1);printChar(10);printChar(13);
	printInt(2 > 1);printChar(10);printChar(13);
	printInt(2 > 2);printChar(10);printChar(13);
	printInt(1 <= 1);printChar(10);printChar(13);
	printInt(2 <= 1);printChar(10);printChar(13);
	printInt(1 >= 1);printChar(10);printChar(13);
	printInt(1 >= 2);printChar(10);printChar(13);
	printInt(true && true);printChar(10);printChar(13);
	printInt(true && false);printChar(10);printChar(13);
	printInt(true || false);printChar(10);printChar(13);
	printInt(false || false);printChar(10);printChar(13);
	
	// unary operators
	printInt(-1);printChar(10);printChar(13);
	printInt(-(-1));printChar(10);printChar(13);
	printInt(!true);printChar(10);printChar(13);
	printInt(!(!true));printChar(10);printChar(13);
	
	// more complicate expression to evaluate
	// the result should be 100{0, 1, 2, 3}
	printInt(!((12%4) || (!true))* 1000);printChar(10);printChar(13);
	printInt((!((1987 - (1987 % 35)) % 35) && (true + true)) * 1001);printChar(10);printChar(13);
	printInt((1 && 2 && 3 && 4) * 1002);printChar(10);printChar(13);
	printInt((0 || 1 || 2 || 3) * 1003);printChar(10);printChar(13);
}