Changeset d011038 in mainline for uspace/dist/src/sysel/demos/arith.sy
- Timestamp:
- 2011-03-29T20:12:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8f17503
- Parents:
- c4fb95d3 (diff), 93ebe4e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/dist/src/sysel/demos/arith.sy
rc4fb95d3 rd011038 30 30 fun Main(), static 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(" (expected: 8)");32 Console.Write("2*2 + 2*2 = "); 33 Console.Write(2*2 + 2*2); 34 Console.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(" (expected: 0)");37 Console.Write("1111 - 1 - 10 - 10*10 - 10*10*10 = "); 38 Console.Write(1111 - 1 - 10 - 10*10 - 10*10*10); 39 Console.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(" (expected: 0)");42 Console.Write("10 * (1 - 1) = "); 43 Console.Write(10 * (1 - 1)); 44 Console.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(" (expected: 0)");47 Console.Write("(+1) - (-1) - (+(+1)) + (+(-1)) = "); 48 Console.Write((+1) - (-1) - (+(+1)) + (+(-1))); 49 Console.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)");52 Console.Write("+1 * +1 = "); 53 Console.Write(+1 * +1); 54 Console.WriteLine(" (expected: 1)"); 55 55 56 Builtin.Write("-1 * -1 = ");57 Builtin.Write(-1 * -1);58 Builtin.WriteLine(" (expected: 1)");56 Console.Write("-1 * -1 = "); 57 Console.Write(-1 * -1); 58 Console.WriteLine(" (expected: 1)"); 59 59 60 Builtin.Write("+1 * -1 = ");61 Builtin.Write(+1 * -1);62 Builtin.WriteLine(" (expected: -1)");60 Console.Write("+1 * -1 = "); 61 Console.Write(+1 * -1); 62 Console.WriteLine(" (expected: -1)"); 63 63 64 Builtin.Write("-1 * +1 = ");65 Builtin.Write(-1 * +1);66 Builtin.WriteLine(" (expected: -1)");64 Console.Write("-1 * +1 = "); 65 Console.Write(-1 * +1); 66 Console.WriteLine(" (expected: -1)"); 67 67 68 68 -- Test multiplication with large result. 69 Builtin.Write("1000000 * 1000000 * 1000000 * 1000000 = ");70 Builtin.Write(1000000 * 1000000 * 1000000 * 1000000);71 Builtin.WriteLine(" (expected: 1000000000000000000000000)");69 Console.Write("1000000 * 1000000 * 1000000 * 1000000 = "); 70 Console.Write(1000000 * 1000000 * 1000000 * 1000000); 71 Console.WriteLine(" (expected: 1000000000000000000000000)"); 72 72 73 73 -- Test large literals. 74 Builtin.Write("1000000000000000000000000 = ");75 Builtin.Write(1000000000000000000000000);76 Builtin.WriteLine(" (expected: 1000000000000000000000000)");74 Console.Write("1000000000000000000000000 = "); 75 Console.Write(1000000000000000000000000); 76 Console.WriteLine(" (expected: 1000000000000000000000000)"); 77 77 78 78 -- Test large factorials. 79 79 var n : int; 80 80 81 Builtin.WriteLine("Factorials:");81 Console.WriteLine("Factorials:"); 82 82 n = 1; 83 83 while n <= 40 do 84 Builtin.WriteLine(Factorial(n));84 Console.WriteLine(Factorial(n)); 85 85 n = n + 1; 86 86 end
Note:
See TracChangeset
for help on using the changeset viewer.