Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: test/codegen_expected/language/no_such_method_mock_test.js

Issue 2158173003: fix #603, support mock objects (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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.main = function() {
40 let mock = new no_such_method_mock_test.MockCat();
41 expect$.Expect.isTrue(dart.dsend(mock, 'eatFood', "food"));
42 expect$.Expect.isFalse(mock.eatFood(""));
43 expect$.Expect.throws(dart.fn(() => dart.notNull(mock.scratch("couch")) + 0, VoidToint()));
44 };
45 dart.fn(no_such_method_mock_test.main, VoidTovoid());
46 // Exports:
47 exports.no_such_method_mock_test = no_such_method_mock_test;
48 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698