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

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

Issue 2984403002: dart2js_native tests: Migrate 'native STRING' to JS-calls (Closed)
Patch Set: the rest of the files 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 import "native_testing.dart"; 5 import "native_testing.dart";
6 6
7 // Test to see if resolving a hidden native class's method interferes with 7 // Test to see if resolving a hidden native class's method interferes with
8 // subsequent resolving the subclass's method. This might happen if the 8 // subsequent resolving the subclass's method. This might happen if the
9 // superclass caches the method in the prototype, so shadowing the dispatcher 9 // superclass caches the method in the prototype, so shadowing the dispatcher
10 // stored on Object.prototype. 10 // stored on Object.prototype.
(...skipping 18 matching lines...) Expand all
29 @Native("D") 29 @Native("D")
30 class D extends C { 30 class D extends C {
31 bar() => 'D.bar'; 31 bar() => 'D.bar';
32 } 32 }
33 33
34 makeA() native; 34 makeA() native;
35 makeB() native; 35 makeB() native;
36 makeC() native; 36 makeC() native;
37 makeD() native; 37 makeD() native;
38 38
39 void setup() native """ 39 void setup() {
40 // This code is all inside 'setup' and so not accessible from the global scope. 40 JS('', r"""
41 function inherits(child, parent) { 41 (function(){
42 if (child.prototype.__proto__) { 42 // This code is inside 'setup' and so not accessible from the global scope.
43 child.prototype.__proto__ = parent.prototype; 43 function inherits(child, parent) {
44 } else { 44 if (child.prototype.__proto__) {
45 function tmp() {}; 45 child.prototype.__proto__ = parent.prototype;
46 tmp.prototype = parent.prototype; 46 } else {
47 child.prototype = new tmp(); 47 function tmp() {};
48 child.prototype.constructor = child; 48 tmp.prototype = parent.prototype;
49 child.prototype = new tmp();
50 child.prototype.constructor = child;
51 }
49 } 52 }
53
54 function A(){}
55 function B(){}
56 inherits(B, A);
57 function C(){}
58 inherits(C, B);
59 function D(){}
60 inherits(D, C);
61
62 makeA = function(){return new A()};
63 makeB = function(){return new B()};
64 makeC = function(){return new C()};
65 makeD = function(){return new D()};
66
67 self.nativeConstructor(A);
68 self.nativeConstructor(B);
69 self.nativeConstructor(C);
70 self.nativeConstructor(D);
71 })()""");
50 } 72 }
51 73
52 function A(){}
53 function B(){}
54 inherits(B, A);
55 function C(){}
56 inherits(C, B);
57 function D(){}
58 inherits(D, C);
59
60 makeA = function(){return new A};
61 makeB = function(){return new B};
62 makeC = function(){return new C};
63 makeD = function(){return new D};
64
65 self.nativeConstructor(A);
66 self.nativeConstructor(B);
67 self.nativeConstructor(C);
68 self.nativeConstructor(D);
69 """;
70
71 main() { 74 main() {
72 nativeTesting(); 75 nativeTesting();
73 setup(); 76 setup();
74 77
75 var a = makeA(); 78 var a = makeA();
76 var b = makeB(); 79 var b = makeB();
77 var c = makeC(); 80 var c = makeC();
78 var d = makeD(); 81 var d = makeD();
79 82
80 Expect.equals('A.foo A.bar', a.foo()); 83 Expect.equals('A.foo A.bar', a.foo());
81 Expect.equals('A.foo B.bar', b.foo()); 84 Expect.equals('A.foo B.bar', b.foo());
82 Expect.equals('C.foo; super.foo = A.foo C.bar', c.foo()); 85 Expect.equals('C.foo; super.foo = A.foo C.bar', c.foo());
83 Expect.equals('C.foo; super.foo = A.foo D.bar', d.foo()); 86 Expect.equals('C.foo; super.foo = A.foo D.bar', d.foo());
84 } 87 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/runtimetype_test.dart ('k') | tests/compiler/dart2js_native/super_property_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698