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

Side by Side Diff: tests/compiler/dart2js_native/abstract_class_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
« no previous file with comments | « no previous file | tests/compiler/dart2js_native/core_type_check_native_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Native classes can have subclasses that are not declared to the program. The 7 // Native classes can have subclasses that are not declared to the program. The
8 // subclasses are indistinguishable from the base class. This means that 8 // subclasses are indistinguishable from the base class. This means that
9 // abstract native classes can appear to have instances. 9 // abstract native classes can appear to have instances.
10 10
11 @Native("A") 11 @Native("A")
12 abstract class A {} 12 abstract class A {}
13 13
14 @Native("B") 14 @Native("B")
15 abstract class B { 15 abstract class B {
16 foo() native; 16 foo() native;
17 } 17 }
18 18
19 class C {} 19 class C {}
20 20
21 makeA() native; 21 makeA() native;
22 makeB() native; 22 makeB() native;
23 23
24 void setup() native """ 24 void setup() {
25 // This code is all inside 'setup' and so not accessible from the global scope. 25 JS('', r"""
26 function A(){} 26 (function(){
27 function B(){} 27 function A(){}
28 B.prototype.foo = function() { return 'B.foo'; }; 28 function B(){}
29 makeA = function(){return new A}; 29 B.prototype.foo = function() { return 'B.foo'; };
30 makeB = function(){return new B}; 30 makeA = function(){return new A()};
31 self.nativeConstructor(A); 31 makeB = function(){return new B()};
32 self.nativeConstructor(B); 32 self.nativeConstructor(A);
33 """; 33 self.nativeConstructor(B);
34 })()
35 """);
36 }
34 37
35 main() { 38 main() {
36 nativeTesting(); 39 nativeTesting();
37 setup(); 40 setup();
38 41
39 var a = makeA(); 42 var a = makeA();
40 var b = makeB(); 43 var b = makeB();
41 var c = confuse(new C()); 44 var c = confuse(new C());
42 45
43 Expect.isTrue(a is A); 46 Expect.isTrue(a is A);
44 Expect.isFalse(b is A); 47 Expect.isFalse(b is A);
45 Expect.isFalse(c is A); 48 Expect.isFalse(c is A);
46 49
47 Expect.isFalse(a is B); 50 Expect.isFalse(a is B);
48 Expect.isTrue(b is B); 51 Expect.isTrue(b is B);
49 Expect.isFalse(c is B); 52 Expect.isFalse(c is B);
50 53
51 Expect.isFalse(a is C); 54 Expect.isFalse(a is C);
52 Expect.isFalse(b is C); 55 Expect.isFalse(b is C);
53 Expect.isTrue(c is C); 56 Expect.isTrue(c is C);
54 57
55 Expect.equals('B.foo', b.foo()); 58 Expect.equals('B.foo', b.foo());
56 } 59 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js_native/core_type_check_native_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698