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