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

Issue 2202673002: Adjust method parameters in noSuchMethod helper stubs (Closed)

Created:
4 years, 4 months ago by srawlins
Modified:
4 years, 4 months ago
Reviewers:
vsm, Leaf, Jennifer Messerly
CC:
dev-compiler+reviews_dartlang.org
Base URL:
git@github.com:dart-lang/dev_compiler.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Adjust method parameters in noSuchMethod helper stubs. If we have code like: class Cat { int eatFood(List<String> foods, [List<String> mixins]) => 0; int walk(List<String> places, {Map<String, String> gaits}) => 0; } class MockCat extends Mock implements Cat {} Then the eatFood stub on MockCat cannot just always pass foods and mixins to the new Invocation; it must only pass mixins if mixins was passed originally. This CL fixes that. Here's a Mockito script that verifies the right behavior (and doesn't work with today's DDC): import 'package:test/test.dart'; import 'lib/mockito.dart'; class Cat { int eatFood(List<String> foods, [List<String> mixins]) => 0; int walk(List<String> places, {Map<String, String> gaits}) => 0; } class MockCat extends Mock implements Cat {} void main() { print('Should print 1 through 5:'); dynamic cat = new MockCat(); when(cat.eatFood(typed/*<List<String>>*/(any))).thenReturn(1); when(cat.eatFood(typed/*<List<String>>*/(any), ['tuna'])).thenReturn(2); when(cat.eatFood(typed/*<List<String>>*/(any), typed/*<List<String>>*/(argThat(hasLength(2))))) .thenReturn(3); print(cat.eatFood(<String>['mouse'])); print(cat.eatFood(<String>['mouse'], ['tuna'])); print(cat.eatFood(<String>['mouse'], ['tuna', 'chicken'])); when(cat.walk(typed/*<List<String>>*/(any))).thenReturn(4); when(cat.walk(typed/*<List<String>>*/(any), gaits: typed/*<Map<String, String>>*/(any, named: 'gaits'))).thenReturn(5); print(cat.walk(<String>['window'])); print(cat.walk(<String>['window'], gaits: {'window': 'quickly'})); } Steps to test this file (its a pain): 1. Clone My typed branch of the mockito repo (https://github.com/srawlins/dart-mockito/tree/typed-api). 2. $ pub get 3. Write this file into the root directory of the mockito repo. 4. $ dart --packages=/Users/srawlins/code/dart-dev_compiler/.packages ../dart-dev_compiler/tool/global_compile.dart cat.dart (adjust for your DDC path) 5. $ node out.js

Patch Set 1 #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+594 lines, -302 lines) Patch
M lib/src/compiler/code_generator.dart View 3 chunks +32 lines, -8 lines 1 comment Download
M test/codegen_expected/language/cyclic_import_test.js View 2 chunks +7 lines, -19 lines 0 comments Download
M test/codegen_expected/language/flatten_test_01_multi.js View 2 chunks +40 lines, -20 lines 0 comments Download
M test/codegen_expected/language/flatten_test_02_multi.js View 2 chunks +40 lines, -20 lines 0 comments Download
M test/codegen_expected/language/flatten_test_03_multi.js View 2 chunks +40 lines, -20 lines 0 comments Download
M test/codegen_expected/language/flatten_test_04_multi.js View 2 chunks +40 lines, -20 lines 0 comments Download
M test/codegen_expected/language/flatten_test_05_multi.js View 2 chunks +40 lines, -20 lines 0 comments Download
M test/codegen_expected/language/flatten_test_06_multi.js View 2 chunks +40 lines, -20 lines 0 comments Download
M test/codegen_expected/language/flatten_test_07_multi.js View 2 chunks +40 lines, -20 lines 0 comments Download
M test/codegen_expected/language/flatten_test_08_multi.js View 2 chunks +40 lines, -20 lines 0 comments Download
M test/codegen_expected/language/flatten_test_09_multi.js View 2 chunks +40 lines, -20 lines 0 comments Download
M test/codegen_expected/language/flatten_test_10_multi.js View 2 chunks +40 lines, -20 lines 0 comments Download
M test/codegen_expected/language/flatten_test_11_multi.js View 2 chunks +40 lines, -20 lines 0 comments Download
M test/codegen_expected/language/flatten_test_12_multi.js View 2 chunks +40 lines, -20 lines 0 comments Download
M test/codegen_expected/language/flatten_test_none_multi.js View 2 chunks +40 lines, -20 lines 0 comments Download
M test/codegen_expected/language/no_such_method_mock_test.js View 3 chunks +19 lines, -7 lines 0 comments Download
M test/codegen_expected/language/no_such_method_subtype_test.js View 1 chunk +2 lines, -1 line 0 comments Download
M test/codegen_expected/language/override_inheritance_no_such_method_test_03_multi.js View 1 chunk +2 lines, -1 line 0 comments Download
M test/codegen_expected/language/override_inheritance_no_such_method_test_04_multi.js View 1 chunk +2 lines, -1 line 0 comments Download
M test/codegen_expected/language/override_inheritance_no_such_method_test_05_multi.js View 1 chunk +2 lines, -1 line 0 comments Download
M test/codegen_expected/language/override_inheritance_no_such_method_test_08_multi.js View 1 chunk +2 lines, -1 line 0 comments Download
M test/codegen_expected/language/override_inheritance_no_such_method_test_11_multi.js View 1 chunk +2 lines, -1 line 0 comments Download
M test/codegen_expected/language/override_inheritance_no_such_method_test_13_multi.js View 1 chunk +4 lines, -2 lines 0 comments Download

Messages

Total messages: 6 (2 generated)
srawlins
https://codereview.chromium.org/2202673002/diff/1/lib/src/compiler/code_generator.dart File lib/src/compiler/code_generator.dart (right): https://codereview.chromium.org/2202673002/diff/1/lib/src/compiler/code_generator.dart#newcode1453 lib/src/compiler/code_generator.dart:1453: 'for (let arg of #) { if (# !== ...
4 years, 4 months ago (2016-08-01 18:30:38 UTC) #3
Jennifer Messerly
Thanks for sending this! Hugely appreciate putting this together along with the epic comment :). ...
4 years, 4 months ago (2016-08-01 19:14:53 UTC) #4
srawlins
On 2016/08/01 19:14:53, John Messerly wrote: > Thanks for sending this! Hugely appreciate putting this ...
4 years, 4 months ago (2016-08-01 21:13:11 UTC) #5
srawlins
4 years, 4 months ago (2016-08-01 21:13:24 UTC) #6

          

Powered by Google App Engine
This is Rietveld 408576698