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

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

Issue 2990083002: dart2js_native tests: Migrate 'native STRING' to JS-calls - part 2/2 (Closed)
Patch Set: remove defunct comments Created 3 years, 4 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 'native_testing.dart';
8 8
9 @Native("Foo") 9 @Native("Foo")
10 class Foo { 10 class Foo {
11 String method(String x) native; 11 String method(String x) native;
12 } 12 }
13 13
14 makeFoo() native; 14 makeFoo() native;
15 15
16 void setup() native r""" 16 void setup() {
17 function Foo() {} 17 JS('', r"""
18 Foo.prototype.method = function(x) { return 'Foo ' + x; } 18 (function(){
19 function Foo() {}
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 23
22 self.nativeConstructor(Foo); 24 self.nativeConstructor(Foo);
23 """; 25 })()""");
26 }
24 27
25 main() { 28 main() {
26 nativeTesting(); 29 nativeTesting();
27 setup(); 30 setup();
28 31
29 // If the dispatchPropertyName is uninitialized, it will be `undefined` or 32 // If the dispatchPropertyName is uninitialized, it will be `undefined` or
30 // `null` instead of the secret string or Symbol. These properties on 33 // `null` instead of the secret string or Symbol. These properties on
31 // `Object.prototype` will be retrieved by the lookup instead of `undefined` 34 // `Object.prototype` will be retrieved by the lookup instead of `undefined`
32 // for the dispatch record. 35 // for the dispatch record.
33 JS('', r'self.Object.prototype["undefined"] = {}'); 36 JS('', r'self.Object.prototype["undefined"] = {}');
34 JS('', r'self.Object.prototype["null"] = {}'); 37 JS('', r'self.Object.prototype["null"] = {}');
35 Expect.equals('Foo A', makeFoo().method('A')); 38 Expect.equals('Foo A', makeFoo().method('A'));
36 39
37 // Slightly different version that has malformed dispatch records. 40 // Slightly different version that has malformed dispatch records.
38 JS('', r'self.Object.prototype["undefined"] = {p: false}'); 41 JS('', r'self.Object.prototype["undefined"] = {p: false}');
39 JS('', r'self.Object.prototype["null"] = {p: false}'); 42 JS('', r'self.Object.prototype["null"] = {p: false}');
40 Expect.equals('Foo B', makeFoo().method('B')); 43 Expect.equals('Foo B', makeFoo().method('B'));
41 } 44 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/browser_compat_2_test.dart ('k') | tests/compiler/dart2js_native/error_safeToString_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698