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

Side by Side Diff: dart/tests/compiler/dart2js_foreign/native_class_is_check3_test.dart

Issue 10823423: Change dart2js_foreign suite to use metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | Annotate | Revision Log
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 correct simple is-checks on hidden native classes. 5 // Test for correct simple is-checks on hidden native classes.
6 6
7 interface J { 7 interface J {
8 } 8 }
9 9
10 interface I extends J { 10 interface I extends J {
11 I read(); 11 I read();
12 write(I x); 12 write(I x);
13 } 13 }
14 14
15 // Native implementation. 15 // Native implementation.
16 16
17 class A implements I native "*A" { 17 @native("*A")
18 class A implements I {
18 // The native class accepts only other native instances. 19 // The native class accepts only other native instances.
19 A read() native; 20 @native A read();
20 write(A x) native; 21 @native write(A x);
21 } 22 }
22 23
23 class B extends A native "*B" { 24 @native("*B")
25 class B extends A {
24 } 26 }
25 27
26 makeA() native; 28 @native makeA();
27 makeB() native; 29 @native makeB();
28 30
29 void setup() native """ 31 @native("""
30 // This code is all inside 'setup' and so not accesible from the global scope. 32 // This code is all inside 'setup' and so not accesible from the global scope.
31 function inherits(child, parent) { 33 function inherits(child, parent) {
32 if (child.prototype.__proto__) { 34 if (child.prototype.__proto__) {
33 child.prototype.__proto__ = parent.prototype; 35 child.prototype.__proto__ = parent.prototype;
34 } else { 36 } else {
35 function tmp() {}; 37 function tmp() {};
36 tmp.prototype = parent.prototype; 38 tmp.prototype = parent.prototype;
37 child.prototype = new tmp(); 39 child.prototype = new tmp();
38 child.prototype.constructor = child; 40 child.prototype.constructor = child;
39 } 41 }
40 } 42 }
41 function A(){} 43 function A(){}
42 function B(){} 44 function B(){}
43 inherits(B, A); 45 inherits(B, A);
44 A.prototype.read = function() { return this._x; }; 46 A.prototype.read = function() { return this._x; };
45 A.prototype.write = function(x) { this._x = x; }; 47 A.prototype.write = function(x) { this._x = x; };
46 makeA = function(){return new A}; 48 makeA = function(){return new A};
47 makeB = function(){return new B}; 49 makeB = function(){return new B};
48 """; 50 """)
51 void setup();
49 52
50 class C {} 53 class C {}
51 54
52 main() { 55 main() {
53 setup(); 56 setup();
54 57
55 var a1 = makeA(); 58 var a1 = makeA();
56 var b1 = makeB(); 59 var b1 = makeB();
57 var ob = new Object(); 60 var ob = new Object();
58 61
59 Expect.isFalse(ob is J); 62 Expect.isFalse(ob is J);
60 Expect.isFalse(ob is I); 63 Expect.isFalse(ob is I);
61 Expect.isFalse(ob is A); 64 Expect.isFalse(ob is A);
62 Expect.isFalse(ob is B); 65 Expect.isFalse(ob is B);
63 Expect.isFalse(ob is C); 66 Expect.isFalse(ob is C);
64 67
65 // Use b1 first to prevent a1 is checks patching the A prototype. 68 // Use b1 first to prevent a1 is checks patching the A prototype.
66 Expect.isTrue(b1 is J); 69 Expect.isTrue(b1 is J);
67 Expect.isTrue(b1 is I); 70 Expect.isTrue(b1 is I);
68 Expect.isTrue(b1 is A); 71 Expect.isTrue(b1 is A);
69 Expect.isTrue(b1 is B); 72 Expect.isTrue(b1 is B);
70 Expect.isTrue(b1 is !C); 73 Expect.isTrue(b1 is !C);
71 74
72 Expect.isTrue(a1 is J); 75 Expect.isTrue(a1 is J);
73 Expect.isTrue(a1 is I); 76 Expect.isTrue(a1 is I);
74 Expect.isTrue(a1 is A); 77 Expect.isTrue(a1 is A);
75 Expect.isTrue(a1 is !B); 78 Expect.isTrue(a1 is !B);
76 Expect.isTrue(a1 is !C); 79 Expect.isTrue(a1 is !C);
77 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698