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

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

Issue 2379173002: Add native_testing library to mock @Native classes (Closed)
Patch Set: xxx Created 4 years, 1 month 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 "native_testing.dart";
6 import "package:expect/expect.dart";
7 6
8 // 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
9 // 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
10 // noSuchMethod is cached on Object.prototype. 9 // noSuchMethod is cached on Object.prototype.
11 10
12 @Native("A1") 11 @Native("A1")
13 class A1 {} 12 class A1 {}
14 13
15 @Native("B1") 14 @Native("B1")
16 class B1 extends A1 {} 15 class B1 extends A1 {}
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 51
53 function A2(){} 52 function A2(){}
54 function B2(){} 53 function B2(){}
55 inherits(B2, A2); 54 inherits(B2, A2);
56 A2.prototype.foo = function(a){return 'A2.foo(' + a + ')';} 55 A2.prototype.foo = function(a){return 'A2.foo(' + a + ')';}
57 56
58 makeA2 = function(){return new A2}; 57 makeA2 = function(){return new A2};
59 makeB2 = function(){return new B2}; 58 makeB2 = function(){return new B2};
60 59
61 makeObject = function(){return new Object}; 60 makeObject = function(){return new Object};
61
62 self.nativeConstructor(A1);
63 self.nativeConstructor(A2);
64 self.nativeConstructor(B1);
65 self.nativeConstructor(B2);
62 """; 66 """;
63 67
64 main() { 68 main() {
69 nativeTesting();
65 setup(); 70 setup();
66 71
67 var a1 = makeA1(); 72 var a1 = makeA1();
68 var b1 = makeB1(); 73 var b1 = makeB1();
69 var ob = makeObject(); 74 var ob = makeObject();
70 75
71 // Does calling missing methods in one tree of inheritance forest affect other 76 // Does calling missing methods in one tree of inheritance forest affect other
72 // trees? 77 // trees?
73 expectNoSuchMethod(() => b1.foo(), 'b1.foo()'); 78 expectNoSuchMethod(() => b1.foo(), 'b1.foo()');
74 expectNoSuchMethod(() => a1.foo(), 'a1.foo()'); 79 expectNoSuchMethod(() => a1.foo(), 'a1.foo()');
(...skipping 14 matching lines...) Expand all
89 expectNoSuchMethod(action, note) { 94 expectNoSuchMethod(action, note) {
90 bool caught = false; 95 bool caught = false;
91 try { 96 try {
92 action(); 97 action();
93 } catch (ex) { 98 } catch (ex) {
94 caught = true; 99 caught = true;
95 Expect.isTrue(ex is NoSuchMethodError, note); 100 Expect.isTrue(ex is NoSuchMethodError, note);
96 } 101 }
97 Expect.isTrue(caught, note); 102 Expect.isTrue(caught, note);
98 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698