OLD | NEW |
(Empty) | |
| 1 dart_library.library('language/arithmetic2_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__arithmetic2_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 arithmetic2_test = Object.create(null); |
| 11 let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.definiteFunctionT
ype(core.bool, [dart.dynamic])))(); |
| 12 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 13 let VoidToint = () => (VoidToint = dart.constFn(dart.definiteFunctionType(core
.int, [])))(); |
| 14 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun
ctionType(dart.dynamic, [dart.dynamic])))(); |
| 15 let dynamicTonum = () => (dynamicTonum = dart.constFn(dart.definiteFunctionTyp
e(core.num, [dart.dynamic])))(); |
| 16 let dynamicTodouble = () => (dynamicTodouble = dart.constFn(dart.definiteFunct
ionType(core.double, [dart.dynamic])))(); |
| 17 let dynamicToint = () => (dynamicToint = dart.constFn(dart.definiteFunctionTyp
e(core.int, [dart.dynamic])))(); |
| 18 arithmetic2_test.A = class A extends core.Object { |
| 19 static foo() { |
| 20 return 499; |
| 21 } |
| 22 }; |
| 23 dart.setSignature(arithmetic2_test.A, { |
| 24 statics: () => ({foo: dart.definiteFunctionType(dart.dynamic, [])}), |
| 25 names: ['foo'] |
| 26 }); |
| 27 arithmetic2_test.throwsNoSuchMethod = function(f) { |
| 28 try { |
| 29 dart.dcall(f); |
| 30 return false; |
| 31 } catch (e) { |
| 32 if (core.NoSuchMethodError.is(e)) { |
| 33 return true; |
| 34 } else |
| 35 throw e; |
| 36 } |
| 37 |
| 38 return false; |
| 39 }; |
| 40 dart.fn(arithmetic2_test.throwsNoSuchMethod, dynamicTobool()); |
| 41 arithmetic2_test.throwsBecauseOfBadArgument = function(f) { |
| 42 try { |
| 43 dart.dcall(f); |
| 44 return false; |
| 45 } catch (e$) { |
| 46 if (core.NoSuchMethodError.is(e$)) { |
| 47 let e = e$; |
| 48 return true; |
| 49 } else if (core.ArgumentError.is(e$)) { |
| 50 let e = e$; |
| 51 return true; |
| 52 } else if (core.TypeError.is(e$)) { |
| 53 let e = e$; |
| 54 return true; |
| 55 } else |
| 56 throw e$; |
| 57 } |
| 58 |
| 59 return false; |
| 60 }; |
| 61 dart.fn(arithmetic2_test.throwsBecauseOfBadArgument, dynamicTobool()); |
| 62 arithmetic2_test.numberOpBadSecondArgument = function(f) { |
| 63 expect$.Expect.isTrue(arithmetic2_test.throwsBecauseOfBadArgument(dart.fn(()
=> dart.dcall(f, true), VoidTodynamic()))); |
| 64 expect$.Expect.isTrue(arithmetic2_test.throwsBecauseOfBadArgument(dart.fn(()
=> dart.dcall(f, new arithmetic2_test.A()), VoidTodynamic()))); |
| 65 expect$.Expect.isTrue(arithmetic2_test.throwsBecauseOfBadArgument(dart.fn(()
=> dart.dcall(f, "foo"), VoidTodynamic()))); |
| 66 expect$.Expect.isTrue(arithmetic2_test.throwsBecauseOfBadArgument(dart.fn(()
=> dart.dcall(f, "5"), VoidTodynamic()))); |
| 67 expect$.Expect.isTrue(arithmetic2_test.throwsBecauseOfBadArgument(dart.fn(()
=> dart.dcall(f, dart.fn(() => 499, VoidToint())), VoidTodynamic()))); |
| 68 expect$.Expect.isTrue(arithmetic2_test.throwsBecauseOfBadArgument(dart.fn(()
=> dart.dcall(f, null), VoidTodynamic()))); |
| 69 expect$.Expect.isTrue(arithmetic2_test.throwsBecauseOfBadArgument(dart.fn(()
=> dart.dcall(f, false), VoidTodynamic()))); |
| 70 expect$.Expect.isTrue(arithmetic2_test.throwsBecauseOfBadArgument(dart.fn(()
=> dart.dcall(f, []), VoidTodynamic()))); |
| 71 expect$.Expect.isTrue(arithmetic2_test.throwsBecauseOfBadArgument(dart.fn(()
=> dart.dcall(f, dart.map()), VoidTodynamic()))); |
| 72 expect$.Expect.isTrue(arithmetic2_test.throwsBecauseOfBadArgument(dart.fn(()
=> dart.dcall(f, arithmetic2_test.A.foo), VoidTodynamic()))); |
| 73 }; |
| 74 dart.fn(arithmetic2_test.numberOpBadSecondArgument, dynamicTodynamic()); |
| 75 arithmetic2_test.badOperations = function(b) { |
| 76 expect$.Expect.isTrue(arithmetic2_test.throwsNoSuchMethod(dart.fn(() => dart
.dsend(b, '-', 3), VoidTodynamic()))); |
| 77 expect$.Expect.isTrue(arithmetic2_test.throwsNoSuchMethod(dart.fn(() => dart
.dsend(b, '*', 3), VoidTodynamic()))); |
| 78 expect$.Expect.isTrue(arithmetic2_test.throwsNoSuchMethod(dart.fn(() => dart
.dsend(b, '~/', 3), VoidTodynamic()))); |
| 79 expect$.Expect.isTrue(arithmetic2_test.throwsNoSuchMethod(dart.fn(() => dart
.dsend(b, '/', 3), VoidTodynamic()))); |
| 80 expect$.Expect.isTrue(arithmetic2_test.throwsNoSuchMethod(dart.fn(() => dart
.dsend(b, '%', 3), VoidTodynamic()))); |
| 81 expect$.Expect.isTrue(arithmetic2_test.throwsNoSuchMethod(dart.fn(() => dart
.dsend(b, '+', 3), VoidTodynamic()))); |
| 82 expect$.Expect.isTrue(arithmetic2_test.throwsNoSuchMethod(dart.fn(() => dart
.dindex(b, 3), VoidTodynamic()))); |
| 83 expect$.Expect.isTrue(arithmetic2_test.throwsNoSuchMethod(dart.fn(() => dart
.dsend(b, '~'), VoidTodynamic()))); |
| 84 expect$.Expect.isTrue(arithmetic2_test.throwsNoSuchMethod(dart.fn(() => dart
.dsend(b, 'unary-'), VoidTodynamic()))); |
| 85 }; |
| 86 dart.fn(arithmetic2_test.badOperations, dynamicTodynamic()); |
| 87 arithmetic2_test.main = function() { |
| 88 arithmetic2_test.numberOpBadSecondArgument(dart.fn(x => 3 + dart.notNull(cor
e.num._check(x)), dynamicTonum())); |
| 89 arithmetic2_test.numberOpBadSecondArgument(dart.fn(x => 3 - dart.notNull(cor
e.num._check(x)), dynamicTonum())); |
| 90 arithmetic2_test.numberOpBadSecondArgument(dart.fn(x => 3 * dart.notNull(cor
e.num._check(x)), dynamicTonum())); |
| 91 arithmetic2_test.numberOpBadSecondArgument(dart.fn(x => 3 / dart.notNull(cor
e.num._check(x)), dynamicTodouble())); |
| 92 arithmetic2_test.numberOpBadSecondArgument(dart.fn(x => (3 / dart.notNull(co
re.num._check(x)))[dartx.truncate](), dynamicToint())); |
| 93 arithmetic2_test.numberOpBadSecondArgument(dart.fn(x => (3)[dartx['%']](core
.num._check(x)), dynamicTonum())); |
| 94 arithmetic2_test.badOperations(true); |
| 95 arithmetic2_test.badOperations(false); |
| 96 arithmetic2_test.badOperations(dart.fn(() => 499, VoidToint())); |
| 97 arithmetic2_test.badOperations(arithmetic2_test.A.foo); |
| 98 }; |
| 99 dart.fn(arithmetic2_test.main, VoidTodynamic()); |
| 100 // Exports: |
| 101 exports.arithmetic2_test = arithmetic2_test; |
| 102 }); |
OLD | NEW |