OLD | NEW |
(Empty) | |
| 1 dart_library.library('language/truncdiv_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__truncdiv_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 truncdiv_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 dynamicAnddynamicTodynamic = () => (dynamicAnddynamicTodynamic = dart.cons
tFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic, dart.dynamic])))(); |
| 15 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun
ctionType(dart.dynamic, [dart.dynamic])))(); |
| 16 truncdiv_test.main = function() { |
| 17 for (let i = -30; i < 30; i++) { |
| 18 expect$.Expect.equals(i[dartx['%']](9), truncdiv_test.foo(i, 9)); |
| 19 if (i < 0) { |
| 20 expect$.Expect.equals((i / -i)[dartx.truncate](), truncdiv_test.foo2(i))
; |
| 21 } else if (i > 0) { |
| 22 expect$.Expect.equals((i / i)[dartx.truncate](), truncdiv_test.foo2(i)); |
| 23 } |
| 24 } |
| 25 expect$.Expect.throws(dart.fn(() => truncdiv_test.foo(12, 0), VoidTovoid()),
dart.fn(e => core.IntegerDivisionByZeroException.is(e), dynamicTobool())); |
| 26 expect$.Expect.throws(dart.fn(() => truncdiv_test.foo2(0), VoidTovoid()), da
rt.fn(e => core.IntegerDivisionByZeroException.is(e), dynamicTobool())); |
| 27 }; |
| 28 dart.fn(truncdiv_test.main, VoidTodynamic()); |
| 29 truncdiv_test.foo = function(i, x) { |
| 30 return dart.dsend(i, '%', x); |
| 31 }; |
| 32 dart.fn(truncdiv_test.foo, dynamicAnddynamicTodynamic()); |
| 33 truncdiv_test.foo2 = function(i) { |
| 34 let x = 0; |
| 35 if (dart.test(dart.dsend(i, '<', 0))) { |
| 36 x = core.int._check(dart.dsend(i, 'unary-')); |
| 37 } else { |
| 38 x = core.int._check(i); |
| 39 } |
| 40 return dart.dsend(i, '~/', x); |
| 41 }; |
| 42 dart.fn(truncdiv_test.foo2, dynamicTodynamic()); |
| 43 // Exports: |
| 44 exports.truncdiv_test = truncdiv_test; |
| 45 }); |
OLD | NEW |