OLD | NEW |
(Empty) | |
| 1 dart_library.library('language/modulo_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__modulo_test(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const dart = dart_sdk.dart; |
| 8 const dartx = dart_sdk.dartx; |
| 9 const expect$ = expect.expect; |
| 10 const modulo_test = Object.create(null); |
| 11 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [])))(); |
| 12 let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.definiteFunctionT
ype(core.bool, [dart.dynamic])))(); |
| 13 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 14 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun
ctionType(dart.dynamic, [dart.dynamic])))(); |
| 15 modulo_test.main = function() { |
| 16 modulo_test.noDom(1); |
| 17 modulo_test.noDom(-1); |
| 18 for (let i = -30; i < 30; i++) { |
| 19 expect$.Expect.equals(i[dartx['%']](256), modulo_test.foo(i)); |
| 20 expect$.Expect.equals(i[dartx['%']](-256), modulo_test.boo(i)); |
| 21 expect$.Expect.throws(dart.fn(() => modulo_test.hoo(i), VoidTovoid()), dar
t.fn(e => core.IntegerDivisionByZeroException.is(e), dynamicTobool())); |
| 22 expect$.Expect.equals((i / 254)[dartx.truncate]() + i[dartx['%']](254), mo
dulo_test.fooTwo(i)); |
| 23 expect$.Expect.equals((i / -254)[dartx.truncate]() + i[dartx['%']](-254),
modulo_test.booTwo(i)); |
| 24 expect$.Expect.throws(dart.fn(() => modulo_test.hooTwo(i), VoidTovoid()),
dart.fn(e => core.IntegerDivisionByZeroException.is(e), dynamicTobool())); |
| 25 if (i > 0) { |
| 26 expect$.Expect.equals(i[dartx['%']](10), modulo_test.noDom(i)); |
| 27 } else { |
| 28 expect$.Expect.equals((i / 10)[dartx.truncate](), modulo_test.noDom(i)); |
| 29 } |
| 30 expect$.Expect.equals((i / 10)[dartx.truncate]() + i[dartx['%']](10) + i[d
artx['%']](10), modulo_test.threeOp(i)); |
| 31 expect$.Expect.equals((i / 10)[dartx.truncate]() + (i / 12)[dartx.truncate
]() + i[dartx['%']](10) + i[dartx['%']](12), modulo_test.fourOp(i)); |
| 32 if (i < 0) { |
| 33 expect$.Expect.equals(i[dartx['%']](-i), modulo_test.foo2(i)); |
| 34 expect$.Expect.equals((i / -i)[dartx.truncate]() + i[dartx['%']](-i), mo
dulo_test.fooTwo2(i)); |
| 35 } else if (i > 0) { |
| 36 expect$.Expect.equals(i[dartx['%']](i), modulo_test.foo2(i)); |
| 37 expect$.Expect.equals((i / i)[dartx.truncate]() + i[dartx['%']](i), modu
lo_test.fooTwo2(i)); |
| 38 } |
| 39 } |
| 40 expect$.Expect.throws(dart.fn(() => modulo_test.foo2(0), VoidTovoid()), dart
.fn(e => core.IntegerDivisionByZeroException.is(e), dynamicTobool())); |
| 41 expect$.Expect.throws(dart.fn(() => modulo_test.fooTwo2(0), VoidTovoid()), d
art.fn(e => core.IntegerDivisionByZeroException.is(e), dynamicTobool())); |
| 42 }; |
| 43 dart.fn(modulo_test.main, VoidTodynamic()); |
| 44 modulo_test.foo = function(i) { |
| 45 return dart.dsend(i, '%', 256); |
| 46 }; |
| 47 dart.fn(modulo_test.foo, dynamicTodynamic()); |
| 48 modulo_test.boo = function(i) { |
| 49 return dart.dsend(i, '%', -256); |
| 50 }; |
| 51 dart.fn(modulo_test.boo, dynamicTodynamic()); |
| 52 modulo_test.hoo = function(i) { |
| 53 return dart.dsend(i, '%', 0); |
| 54 }; |
| 55 dart.fn(modulo_test.hoo, dynamicTodynamic()); |
| 56 modulo_test.fooTwo = function(i) { |
| 57 return dart.dsend(dart.dsend(i, '~/', 254), '+', dart.dsend(i, '%', 254)); |
| 58 }; |
| 59 dart.fn(modulo_test.fooTwo, dynamicTodynamic()); |
| 60 modulo_test.booTwo = function(i) { |
| 61 return dart.dsend(dart.dsend(i, '~/', -254), '+', dart.dsend(i, '%', -254)); |
| 62 }; |
| 63 dart.fn(modulo_test.booTwo, dynamicTodynamic()); |
| 64 modulo_test.hooTwo = function(i) { |
| 65 return dart.dsend(dart.dsend(i, '~/', 0), '+', dart.dsend(i, '%', 0)); |
| 66 }; |
| 67 dart.fn(modulo_test.hooTwo, dynamicTodynamic()); |
| 68 modulo_test.noDom = function(a) { |
| 69 let x = null; |
| 70 if (dart.test(dart.dsend(a, '>', 0))) { |
| 71 x = dart.dsend(a, '%', 10); |
| 72 } else { |
| 73 x = dart.dsend(a, '~/', 10); |
| 74 } |
| 75 return x; |
| 76 }; |
| 77 dart.fn(modulo_test.noDom, dynamicTodynamic()); |
| 78 modulo_test.threeOp = function(a) { |
| 79 let x = dart.dsend(a, '~/', 10); |
| 80 let y = dart.dsend(a, '%', 10); |
| 81 let z = dart.dsend(a, '%', 10); |
| 82 return dart.dsend(dart.dsend(x, '+', y), '+', z); |
| 83 }; |
| 84 dart.fn(modulo_test.threeOp, dynamicTodynamic()); |
| 85 modulo_test.fourOp = function(a) { |
| 86 let x0 = dart.dsend(a, '~/', 10); |
| 87 let x1 = dart.dsend(a, '~/', 12); |
| 88 let y0 = dart.dsend(a, '%', 10); |
| 89 let y1 = dart.dsend(a, '%', 12); |
| 90 return dart.dsend(dart.dsend(dart.dsend(x0, '+', x1), '+', y0), '+', y1); |
| 91 }; |
| 92 dart.fn(modulo_test.fourOp, dynamicTodynamic()); |
| 93 modulo_test.foo2 = function(i) { |
| 94 let x = 0; |
| 95 if (dart.test(dart.dsend(i, '<', 0))) { |
| 96 x = core.int._check(dart.dsend(i, 'unary-')); |
| 97 } else { |
| 98 x = core.int._check(i); |
| 99 } |
| 100 return dart.dsend(i, '%', x); |
| 101 }; |
| 102 dart.fn(modulo_test.foo2, dynamicTodynamic()); |
| 103 modulo_test.fooTwo2 = function(i) { |
| 104 let x = 0; |
| 105 if (dart.test(dart.dsend(i, '<', 0))) { |
| 106 x = core.int._check(dart.dsend(i, 'unary-')); |
| 107 } else { |
| 108 x = core.int._check(i); |
| 109 } |
| 110 return dart.dsend(dart.dsend(i, '~/', x), '+', dart.dsend(i, '%', x)); |
| 111 }; |
| 112 dart.fn(modulo_test.fooTwo2, dynamicTodynamic()); |
| 113 // Exports: |
| 114 exports.modulo_test = modulo_test; |
| 115 }); |
OLD | NEW |