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

Side by Side Diff: tests/compiler/dart2js_native/dispatch_property_initialization_test.dart

Issue 2383273002: Revert "Add native_testing library to mock @Native classes" (Closed)
Patch Set: Created 4 years, 2 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
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Test for initialization of dispatchPropertyName. 5 // Test for initialization of dispatchPropertyName.
6 6
7 import 'native_testing.dart'; 7 import "package:expect/expect.dart";
8 import 'dart:_foreign_helper' show JS;
9 import 'dart:_js_helper' show Native;
8 10
9 @Native("Foo") 11 @Native("Foo")
10 class Foo { 12 class Foo {
11 String method(String x) native; 13 String method(String x) native;
12 } 14 }
13 15
14 makeFoo() native; 16 makeFoo() native;
15 17
16 void setup() native r""" 18 void setup() native r"""
17 function Foo() {} 19 function Foo() {}
18 Foo.prototype.method = function(x) { return 'Foo ' + x; } 20 Foo.prototype.method = function(x) { return 'Foo ' + x; }
19 21
20 self.makeFoo = function() { return new Foo(); } 22 self.makeFoo = function() { return new Foo(); }
21
22 self.nativeConstructor(Foo);
23 """; 23 """;
24 24
25 25
26 main() { 26 main() {
27 nativeTesting();
28 setup(); 27 setup();
29 28
30 // If the dispatchPropertyName is uninitialized, it will be `undefined` or 29 // If the dispatchPropertyName is uninitialized, it will be `undefined` or
31 // `null` instead of the secret string or Symbol. These properties on 30 // `null` instead of the secret string or Symbol. These properties on
32 // `Object.prototype` will be retrieved by the lookup instead of `undefined` 31 // `Object.prototype` will be retrieved by the lookup instead of `undefined`
33 // for the dispatch record. 32 // for the dispatch record.
34 JS('', r'self.Object.prototype["undefined"] = {}'); 33 JS('', r'self.Object.prototype["undefined"] = {}');
35 JS('', r'self.Object.prototype["null"] = {}'); 34 JS('', r'self.Object.prototype["null"] = {}');
36 Expect.equals('Foo A', makeFoo().method('A')); 35 Expect.equals('Foo A', makeFoo().method('A'));
37 36
38 // Slightly different version that has malformed dispatch records. 37 // Slightly different version that has malformed dispatch records.
39 JS('', r'self.Object.prototype["undefined"] = {p: false}'); 38 JS('', r'self.Object.prototype["undefined"] = {p: false}');
40 JS('', r'self.Object.prototype["null"] = {p: false}'); 39 JS('', r'self.Object.prototype["null"] = {p: false}');
41 Expect.equals('Foo B', makeFoo().method('B')); 40 Expect.equals('Foo B', makeFoo().method('B'));
42 } 41 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/dart2js_native.status ('k') | tests/compiler/dart2js_native/downcast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698