mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:19:48 +00:00
Fix mocked operator methods
R=jacobr@google.com Review-Url: https://codereview.chromium.org/2949123002 .
This commit is contained in:
parent
ecca1e1c2a
commit
febded6052
|
@ -1530,7 +1530,7 @@ class CodeGenerator extends Object
|
|||
var fnBody =
|
||||
js.call('this.noSuchMethod(new #.InvocationImpl.new(#, #, #))', [
|
||||
_runtimeModule,
|
||||
_declareMemberName(method, useDisplayName: true),
|
||||
_declareMemberName(method, useDisplayName: false),
|
||||
positionalArgs,
|
||||
new JS.ObjectInitializer(invocationProps)
|
||||
]);
|
||||
|
|
|
@ -8,7 +8,11 @@ import 'dart:html';
|
|||
import 'package:expect/minitest.dart';
|
||||
|
||||
class Mock {
|
||||
noSuchMethod(Invocation i) => document;
|
||||
noSuchMethod(Invocation i) {
|
||||
if (this is Window) return document;
|
||||
if (this is FileList) return new MockFile();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@proxy
|
||||
|
@ -39,6 +43,12 @@ class MockLocation extends Mock implements Location {
|
|||
String href = "MOCK_HREF";
|
||||
}
|
||||
|
||||
@proxy
|
||||
class MockFileList extends Mock implements FileList {}
|
||||
|
||||
@proxy
|
||||
class MockFile extends Mock implements File {}
|
||||
|
||||
main() {
|
||||
test('is', () {
|
||||
var win = new MockWindow();
|
||||
|
@ -78,4 +88,9 @@ main() {
|
|||
HtmlDocument doc = new MockHtmlDocument();
|
||||
expect(doc.onBlur is Stream, isTrue, reason: 'onBlur should be a stream');
|
||||
});
|
||||
|
||||
test('operator', () {
|
||||
var fileList = new MockFileList();
|
||||
expect(fileList[1] is File, isTrue);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue