Changes in uspace/dist/src/sysel/demos/arith.sy [38aaacc2:23de644] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/dist/src/sysel/demos/arith.sy
r38aaacc2 r23de644 30 30 fun Main() is 31 31 -- Test addition, multiplication and precedence. 32 Builtin.Write ("2*2 + 2*2 =");33 Builtin.Write (2*2 + 2*2);34 Builtin.WriteLine(" 32 Builtin.WriteLine("2*2 + 2*2 ="); 33 Builtin.WriteLine(2*2 + 2*2); 34 Builtin.WriteLine("(expected: 8)"); 35 35 36 36 -- Test subtraction, multiplication and precedence. 37 Builtin.Write ("1111 - 1 - 10 - 10*10 - 10*10*10 =");38 Builtin.Write (1111 - 1 - 10 - 10*10 - 10*10*10);39 Builtin.WriteLine(" 37 Builtin.WriteLine("1111 - 1 - 10 - 10*10 - 10*10*10 ="); 38 Builtin.WriteLine(1111 - 1 - 10 - 10*10 - 10*10*10); 39 Builtin.WriteLine("(expected: 0)"); 40 40 41 41 -- Test parenthesized sub-expressions. 42 Builtin.Write ("10 * (1 - 1) =");43 Builtin.Write (10 * (1 - 1));44 Builtin.WriteLine(" 42 Builtin.WriteLine("10 * (1 - 1) ="); 43 Builtin.WriteLine(10 * (1 - 1)); 44 Builtin.WriteLine("(expected: 0)"); 45 45 46 46 -- Test unary plus and minus. 47 Builtin.Write ("(+1) - (-1) - (+(+1)) + (+(-1)) = ");48 Builtin.Write ((+1) - (-1) - (+(+1)) + (+(-1)));49 Builtin.WriteLine(" 47 Builtin.WriteLine("(+1) - (-1) - (+(+1)) + (+(-1)) = "); 48 Builtin.WriteLine((+1) - (-1) - (+(+1)) + (+(-1))); 49 Builtin.WriteLine("(expected: 0)"); 50 50 51 51 -- Test signed multiplication. 52 Builtin.Write("+1 * +1 = "); 53 Builtin.Write(+1 * +1); 54 Builtin.WriteLine(" (expected: 1)"); 55 56 Builtin.Write("-1 * -1 = "); 57 Builtin.Write(-1 * -1); 58 Builtin.WriteLine(" (expected: 1)"); 59 60 Builtin.Write("+1 * -1 = "); 61 Builtin.Write(+1 * -1); 62 Builtin.WriteLine(" (expected: -1)"); 63 64 Builtin.Write("-1 * +1 = "); 65 Builtin.Write(-1 * +1); 66 Builtin.WriteLine(" (expected: -1)"); 52 Builtin.WriteLine("+1 * +1 = "); 53 Builtin.WriteLine(+1 * +1); 54 Builtin.WriteLine("(expected: 1)"); 55 Builtin.WriteLine("-1 * -1 = "); 56 Builtin.WriteLine(-1 * -1); 57 Builtin.WriteLine("(expected: 1)"); 58 Builtin.WriteLine("+1 * -1 = "); 59 Builtin.WriteLine(+1 * -1); 60 Builtin.WriteLine("(expected: -1)"); 61 Builtin.WriteLine("-1 * +1 = "); 62 Builtin.WriteLine(-1 * +1); 63 Builtin.WriteLine("(expected: -1)"); 67 64 68 65 -- Test multiplication with large result. 69 Builtin.Write ("1000000 * 1000000 * 1000000 * 1000000 =");70 Builtin.Write (1000000 * 1000000 * 1000000 * 1000000);71 Builtin.WriteLine(" 66 Builtin.WriteLine("1000000 * 1000000 * 1000000 * 1000000 ="); 67 Builtin.WriteLine(1000000 * 1000000 * 1000000 * 1000000); 68 Builtin.WriteLine("(expected: 1000000000000000000000000)"); 72 69 73 70 -- Test large literals. 74 Builtin.Write ("1000000000000000000000000 =");75 Builtin.Write (1000000000000000000000000);76 Builtin.WriteLine(" 71 Builtin.WriteLine("1000000000000000000000000 ="); 72 Builtin.WriteLine(1000000000000000000000000); 73 Builtin.WriteLine("(expected: 1000000000000000000000000)"); 77 74 78 75 -- Test large factorials.
Note:
See TracChangeset
for help on using the changeset viewer.