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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: test/codegen_expected/language/no_such_method_mock_test.js
diff --git a/test/codegen_expected/language/no_such_method_mock_test.js b/test/codegen_expected/language/no_such_method_mock_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..9e23c66ab7343ffdaa54c2d1d40b6ca3b36a176d
--- /dev/null
+++ b/test/codegen_expected/language/no_such_method_mock_test.js
@@ -0,0 +1,48 @@
+dart_library.library('language/no_such_method_mock_test', null, /* Imports */[
+ 'dart_sdk',
+ 'expect'
+], function load__no_such_method_mock_test(exports, dart_sdk, expect) {
+ 'use strict';
+ const core = dart_sdk.core;
+ const dart = dart_sdk.dart;
+ const dartx = dart_sdk.dartx;
+ const expect$ = expect.expect;
+ const no_such_method_mock_test = Object.create(null);
+ let VoidToint = () => (VoidToint = dart.constFn(dart.definiteFunctionType(core.int, [])))();
+ let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(dart.void, [])))();
+ no_such_method_mock_test.Cat = class Cat extends core.Object {
+ eatFood(food) {
+ return true;
+ }
+ scratch(furniture) {
+ return 100;
+ }
+ };
+ dart.setSignature(no_such_method_mock_test.Cat, {
+ methods: () => ({
+ eatFood: dart.definiteFunctionType(core.bool, [core.String]),
+ scratch: dart.definiteFunctionType(core.int, [core.String])
+ })
+ });
+ no_such_method_mock_test.MockCat = class MockCat extends core.Object {
+ noSuchMethod(invocation) {
+ return core.String.as(invocation.positionalArguments[dartx.get](0))[dartx.isNotEmpty];
+ }
+ eatFood(food) {
+ return core.bool._check(this.noSuchMethod(new dart.InvocationImpl('eatFood', [food], {isMethod: true})));
+ }
+ scratch(furniture) {
+ return core.int._check(this.noSuchMethod(new dart.InvocationImpl('scratch', [furniture], {isMethod: true})));
+ }
+ };
+ no_such_method_mock_test.MockCat[dart.implements] = () => [no_such_method_mock_test.Cat];
+ no_such_method_mock_test.main = function() {
+ let mock = new no_such_method_mock_test.MockCat();
+ expect$.Expect.isTrue(dart.dsend(mock, 'eatFood', "food"));
+ expect$.Expect.isFalse(mock.eatFood(""));
+ expect$.Expect.throws(dart.fn(() => dart.notNull(mock.scratch("couch")) + 0, VoidToint()));
+ };
+ dart.fn(no_such_method_mock_test.main, VoidTovoid());
+ // Exports:
+ exports.no_such_method_mock_test = no_such_method_mock_test;
+});

Powered by Google App Engine
This is Rietveld 408576698