OLD | NEW |
(Empty) | |
| 1 dart_library.library('language/no_such_method_mock_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__no_such_method_mock_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 no_such_method_mock_test = Object.create(null); |
| 11 let VoidToint = () => (VoidToint = dart.constFn(dart.definiteFunctionType(core
.int, [])))(); |
| 12 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [])))(); |
| 13 no_such_method_mock_test.Cat = class Cat extends core.Object { |
| 14 eatFood(food) { |
| 15 return true; |
| 16 } |
| 17 scratch(furniture) { |
| 18 return 100; |
| 19 } |
| 20 }; |
| 21 dart.setSignature(no_such_method_mock_test.Cat, { |
| 22 methods: () => ({ |
| 23 eatFood: dart.definiteFunctionType(core.bool, [core.String]), |
| 24 scratch: dart.definiteFunctionType(core.int, [core.String]) |
| 25 }) |
| 26 }); |
| 27 no_such_method_mock_test.MockCat = class MockCat extends core.Object { |
| 28 noSuchMethod(invocation) { |
| 29 return core.String.as(invocation.positionalArguments[dartx.get](0))[dartx.
isNotEmpty]; |
| 30 } |
| 31 eatFood(food) { |
| 32 return core.bool._check(this.noSuchMethod(new dart.InvocationImpl('eatFood
', [food], {isMethod: true}))); |
| 33 } |
| 34 scratch(furniture) { |
| 35 return core.int._check(this.noSuchMethod(new dart.InvocationImpl('scratch'
, [furniture], {isMethod: true}))); |
| 36 } |
| 37 }; |
| 38 no_such_method_mock_test.MockCat[dart.implements] = () => [no_such_method_mock
_test.Cat]; |
| 39 no_such_method_mock_test.MockCat2 = class MockCat2 extends no_such_method_mock
_test.MockCat { |
| 40 eatFood(food) { |
| 41 return core.bool._check(this.noSuchMethod(new dart.InvocationImpl('eatFood
', [food], {isMethod: true}))); |
| 42 } |
| 43 scratch(furniture) { |
| 44 return core.int._check(this.noSuchMethod(new dart.InvocationImpl('scratch'
, [furniture], {isMethod: true}))); |
| 45 } |
| 46 }; |
| 47 let const$; |
| 48 no_such_method_mock_test.MockCat3 = class MockCat3 extends no_such_method_mock
_test.MockCat2 { |
| 49 noSuchMethod(invocation) { |
| 50 return dart.test(core.String.as(invocation.positionalArguments[dartx.get](
0))[dartx.isNotEmpty]) && dart.test(dart.dsend(invocation.namedArguments[dartx.g
et](const$ || (const$ = dart.const(core.Symbol.new('amount')))), '>', 0.5)); |
| 51 } |
| 52 eatFood(food, opts) { |
| 53 return core.bool._check(this.noSuchMethod(new dart.InvocationImpl('eatFood
', [food], {namedArguments: opts, isMethod: true}))); |
| 54 } |
| 55 scratch(furniture, furniture2) { |
| 56 return core.int._check(this.noSuchMethod(new dart.InvocationImpl('scratch'
, [furniture, furniture2], {isMethod: true}))); |
| 57 } |
| 58 }; |
| 59 no_such_method_mock_test.MockCat3[dart.implements] = () => [no_such_method_moc
k_test.Cat]; |
| 60 no_such_method_mock_test.MockWithGenerics = class MockWithGenerics extends cor
e.Object { |
| 61 noSuchMethod(i) { |
| 62 return dart.dsend(i.positionalArguments[dartx.get](0), '+', 100); |
| 63 } |
| 64 doStuff(T) { |
| 65 return t => { |
| 66 return T._check(this.noSuchMethod(new dart.InvocationImpl('doStuff', [t]
, {isMethod: true}))); |
| 67 }; |
| 68 } |
| 69 }; |
| 70 no_such_method_mock_test.main = function() { |
| 71 let mock = new no_such_method_mock_test.MockCat(); |
| 72 expect$.Expect.isTrue(dart.dsend(mock, 'eatFood', "cat food")); |
| 73 expect$.Expect.isFalse(mock.eatFood("")); |
| 74 expect$.Expect.throws(dart.fn(() => dart.notNull(mock.scratch("couch")) + 0,
VoidToint())); |
| 75 let mock2 = new no_such_method_mock_test.MockCat2(); |
| 76 expect$.Expect.isTrue(mock2.eatFood("cat food")); |
| 77 let mock3 = new no_such_method_mock_test.MockCat3(); |
| 78 expect$.Expect.isTrue(mock3.eatFood("cat food", {amount: 0.9})); |
| 79 expect$.Expect.isFalse(mock3.eatFood("cat food", {amount: 0.3})); |
| 80 let g = new no_such_method_mock_test.MockWithGenerics(); |
| 81 expect$.Expect.equals(g.doStuff(core.int)(42), 142); |
| 82 expect$.Expect.throws(dart.fn(() => g.doStuff(dart.dynamic)('hi'), VoidTovoi
d())); |
| 83 }; |
| 84 dart.fn(no_such_method_mock_test.main, VoidTovoid()); |
| 85 // Exports: |
| 86 exports.no_such_method_mock_test = no_such_method_mock_test; |
| 87 }); |
OLD | NEW |