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

Side by Side Diff: tests/compiler/dart2js_native/native_class_inheritance3_frog_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 to noSuchMethod 7 // Test to see if resolving a hidden native class's method to noSuchMethod
8 // interferes with subsequent resolving of the method. This might happen if the 8 // interferes with subsequent resolving of the method. This might happen if the
9 // noSuchMethod is cached on Object.prototype. 9 // noSuchMethod is cached on Object.prototype.
10 10
(...skipping 12 matching lines...) Expand all
23 } 23 }
24 24
25 @Native("B2") 25 @Native("B2")
26 class B2 extends A2 {} 26 class B2 extends A2 {}
27 27
28 makeA2() native; 28 makeA2() native;
29 makeB2() native; 29 makeB2() native;
30 30
31 makeObject() native; 31 makeObject() native;
32 32
33 void setup() native """ 33 void setup() {
34 // This code is all inside 'setup' and so not accessible from the global scope. 34 JS('', r"""
35 function inherits(child, parent) { 35 (function(){
36 if (child.prototype.__proto__) { 36 // This code is inside 'setup' and so not accessible from the global scope.
37 child.prototype.__proto__ = parent.prototype; 37 function inherits(child, parent) {
38 } else { 38 if (child.prototype.__proto__) {
39 function tmp() {}; 39 child.prototype.__proto__ = parent.prototype;
40 tmp.prototype = parent.prototype; 40 } else {
41 child.prototype = new tmp(); 41 function tmp() {};
42 child.prototype.constructor = child; 42 tmp.prototype = parent.prototype;
43 child.prototype = new tmp();
44 child.prototype.constructor = child;
45 }
43 } 46 }
47 function A1(){}
48 function B1(){}
49 inherits(B1, A1);
50
51 makeA1 = function(){return new A1()};
52 makeB1 = function(){return new B1()};
53
54 function A2(){}
55 function B2(){}
56 inherits(B2, A2);
57 A2.prototype.foo = function(a){return 'A2.foo(' + a + ')';};
58
59 makeA2 = function(){return new A2()};
60 makeB2 = function(){return new B2()};
61
62 makeObject = function(){return new Object()};
63
64 self.nativeConstructor(A1);
65 self.nativeConstructor(A2);
66 self.nativeConstructor(B1);
67 self.nativeConstructor(B2);
68 })()""");
44 } 69 }
45 function A1(){}
46 function B1(){}
47 inherits(B1, A1);
48
49 makeA1 = function(){return new A1};
50 makeB1 = function(){return new B1};
51
52 function A2(){}
53 function B2(){}
54 inherits(B2, A2);
55 A2.prototype.foo = function(a){return 'A2.foo(' + a + ')';}
56
57 makeA2 = function(){return new A2};
58 makeB2 = function(){return new B2};
59
60 makeObject = function(){return new Object};
61
62 self.nativeConstructor(A1);
63 self.nativeConstructor(A2);
64 self.nativeConstructor(B1);
65 self.nativeConstructor(B2);
66 """;
67 70
68 main() { 71 main() {
69 nativeTesting(); 72 nativeTesting();
70 setup(); 73 setup();
71 74
72 var a1 = makeA1(); 75 var a1 = makeA1();
73 var b1 = makeB1(); 76 var b1 = makeB1();
74 var ob = makeObject(); 77 var ob = makeObject();
75 78
76 // Does calling missing methods in one tree of inheritance forest affect other 79 // Does calling missing methods in one tree of inheritance forest affect other
(...skipping 17 matching lines...) Expand all
94 expectNoSuchMethod(action, note) { 97 expectNoSuchMethod(action, note) {
95 bool caught = false; 98 bool caught = false;
96 try { 99 try {
97 action(); 100 action();
98 } catch (ex) { 101 } catch (ex) {
99 caught = true; 102 caught = true;
100 Expect.isTrue(ex is NoSuchMethodError, note); 103 Expect.isTrue(ex is NoSuchMethodError, note);
101 } 104 }
102 Expect.isTrue(caught, note); 105 Expect.isTrue(caught, note);
103 } 106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698