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

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

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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 "dart:_js_helper"; 5 import "dart:_js_helper";
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8 // Test to see if resolving a hidden native class's method to noSuchMethod 8 // Test to see if resolving a hidden native class's method to noSuchMethod
9 // interferes with subsequent resolving of the method. This might happen if the 9 // interferes with subsequent resolving of the method. This might happen if the
10 // noSuchMethod is cached on Object.prototype. 10 // noSuchMethod is cached on Object.prototype.
11 11
12 @Native("A1") 12 @Native("A1")
13 class A1 { 13 class A1 {}
14 }
15 14
16 @Native("B1") 15 @Native("B1")
17 class B1 extends A1 { 16 class B1 extends A1 {}
18 }
19 17
20 makeA1() native; 18 makeA1() native ;
21 makeB1() native; 19 makeB1() native ;
22
23 20
24 @Native("A2") 21 @Native("A2")
25 class A2 { 22 class A2 {
26 foo([a=99]) native; 23 foo([a = 99]) native ;
27 } 24 }
28 25
29 @Native("B2") 26 @Native("B2")
30 class B2 extends A2 { 27 class B2 extends A2 {}
31 }
32 28
33 makeA2() native; 29 makeA2() native ;
34 makeB2() native; 30 makeB2() native ;
35 31
36 makeObject() native; 32 makeObject() native ;
37 33
38 void setup() native """ 34 void setup() native """
39 // This code is all inside 'setup' and so not accesible from the global scope. 35 // This code is all inside 'setup' and so not accesible from the global scope.
40 function inherits(child, parent) { 36 function inherits(child, parent) {
41 if (child.prototype.__proto__) { 37 if (child.prototype.__proto__) {
42 child.prototype.__proto__ = parent.prototype; 38 child.prototype.__proto__ = parent.prototype;
43 } else { 39 } else {
44 function tmp() {}; 40 function tmp() {};
45 tmp.prototype = parent.prototype; 41 tmp.prototype = parent.prototype;
46 child.prototype = new tmp(); 42 child.prototype = new tmp();
(...skipping 11 matching lines...) Expand all
58 function B2(){} 54 function B2(){}
59 inherits(B2, A2); 55 inherits(B2, A2);
60 A2.prototype.foo = function(a){return 'A2.foo(' + a + ')';} 56 A2.prototype.foo = function(a){return 'A2.foo(' + a + ')';}
61 57
62 makeA2 = function(){return new A2}; 58 makeA2 = function(){return new A2};
63 makeB2 = function(){return new B2}; 59 makeB2 = function(){return new B2};
64 60
65 makeObject = function(){return new Object}; 61 makeObject = function(){return new Object};
66 """; 62 """;
67 63
68
69 main() { 64 main() {
70 setup(); 65 setup();
71 66
72 var a1 = makeA1(); 67 var a1 = makeA1();
73 var b1 = makeB1(); 68 var b1 = makeB1();
74 var ob = makeObject(); 69 var ob = makeObject();
75 70
76 // Does calling missing methods in one tree of inheritance forest affect other 71 // Does calling missing methods in one tree of inheritance forest affect other
77 // trees? 72 // trees?
78 expectNoSuchMethod(() => b1.foo(), 'b1.foo()'); 73 expectNoSuchMethod(() => b1.foo(), 'b1.foo()');
79 expectNoSuchMethod(() => a1.foo(), 'a1.foo()'); 74 expectNoSuchMethod(() => a1.foo(), 'a1.foo()');
80 expectNoSuchMethod(() => ob.foo(), 'ob.foo()'); 75 expectNoSuchMethod(() => ob.foo(), 'ob.foo()');
81 76
82 var a2 = makeA2(); 77 var a2 = makeA2();
83 var b2 = makeB2(); 78 var b2 = makeB2();
84 79
85 Expect.equals('A2.foo(99)', a2.foo()); 80 Expect.equals('A2.foo(99)', a2.foo());
86 Expect.equals('A2.foo(99)', b2.foo()); 81 Expect.equals('A2.foo(99)', b2.foo());
87 Expect.equals('A2.foo(1)', a2.foo(1)); 82 Expect.equals('A2.foo(1)', a2.foo(1));
88 Expect.equals('A2.foo(2)', b2.foo(2)); 83 Expect.equals('A2.foo(2)', b2.foo(2));
89 84
90
91 expectNoSuchMethod(() => b1.foo(3), 'b1.foo(3)'); 85 expectNoSuchMethod(() => b1.foo(3), 'b1.foo(3)');
92 expectNoSuchMethod(() => a1.foo(4), 'a1.foo(4)'); 86 expectNoSuchMethod(() => a1.foo(4), 'a1.foo(4)');
93 } 87 }
94 88
95 expectNoSuchMethod(action, note) { 89 expectNoSuchMethod(action, note) {
96 bool caught = false; 90 bool caught = false;
97 try { 91 try {
98 action(); 92 action();
99 } catch (ex) { 93 } catch (ex) {
100 caught = true; 94 caught = true;
101 Expect.isTrue(ex is NoSuchMethodError, note); 95 Expect.isTrue(ex is NoSuchMethodError, note);
102 } 96 }
103 Expect.isTrue(caught, note); 97 Expect.isTrue(caught, note);
104 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698