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

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

Issue 2383273002: Revert "Add native_testing library to mock @Native classes" (Closed)
Patch Set: Created 4 years, 2 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 // Test for downcasts on native classes. 5 // Test for downcasts on native classes.
6 6
7 import "native_testing.dart"; 7 import "dart:_js_helper";
8 import "package:expect/expect.dart";
8 9
9 abstract class J {} 10 abstract class J {}
10 11
11 abstract class I extends J { 12 abstract class I extends J {
12 I read(); 13 I read();
13 write(I x); 14 write(I x);
14 } 15 }
15 16
16 // Native implementation. 17 // Native implementation.
17 18
(...skipping 22 matching lines...) Expand all
40 child.prototype.constructor = child; 41 child.prototype.constructor = child;
41 } 42 }
42 } 43 }
43 function A(){} 44 function A(){}
44 function B(){} 45 function B(){}
45 inherits(B, A); 46 inherits(B, A);
46 A.prototype.read = function() { return this._x; }; 47 A.prototype.read = function() { return this._x; };
47 A.prototype.write = function(x) { this._x = x; }; 48 A.prototype.write = function(x) { this._x = x; };
48 makeA = function(){return new A}; 49 makeA = function(){return new A};
49 makeB = function(){return new B}; 50 makeB = function(){return new B};
50
51 self.nativeConstructor(A);
52 self.nativeConstructor(B);
53 """; 51 """;
54 52
55 class C {} 53 class C {}
56 54
57 bool _check(a, b) => identical(a, b); 55 bool _check(a, b) => identical(a, b);
58 56
59 main() { 57 main() {
60 nativeTesting();
61 setup(); 58 setup();
62 59
63 var a1 = makeA(); 60 var a1 = makeA();
64 var b1 = makeB(); 61 var b1 = makeB();
65 var ob = new Object(); 62 var ob = new Object();
66 63
67 Expect.throws(() => ob as J); 64 Expect.throws(() => ob as J);
68 Expect.throws(() => ob as I); 65 Expect.throws(() => ob as I);
69 Expect.throws(() => ob as A); 66 Expect.throws(() => ob as A);
70 Expect.throws(() => ob as B); 67 Expect.throws(() => ob as B);
71 Expect.throws(() => ob as C); 68 Expect.throws(() => ob as C);
72 69
73 // Use b1 first to prevent a1 is checks patching the A prototype. 70 // Use b1 first to prevent a1 is checks patching the A prototype.
74 Expect.equals(b1, b1 as J); 71 Expect.equals(b1, b1 as J);
75 Expect.equals(b1, b1 as I); 72 Expect.equals(b1, b1 as I);
76 Expect.equals(b1, b1 as A); 73 Expect.equals(b1, b1 as A);
77 Expect.equals(b1, b1 as B); 74 Expect.equals(b1, b1 as B);
78 75
79 Expect.equals(a1, a1 as J); 76 Expect.equals(a1, a1 as J);
80 Expect.equals(a1, a1 as I); 77 Expect.equals(a1, a1 as I);
81 Expect.equals(a1, a1 as A); 78 Expect.equals(a1, a1 as A);
82 Expect.throws(() => a1 as B); 79 Expect.throws(() => a1 as B);
83 Expect.throws(() => a1 as C); 80 Expect.throws(() => a1 as C);
84 } 81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698