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

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

Issue 23600020: Native abstract classes may be 'instantiated' (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6
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
9 // abstract native classes can appear to have instances.
10
11 abstract class A native "A" {
12 }
13
14 abstract class B native "B" {
15 foo() native;
16 }
17
18 class C {}
19
20 makeA() native;
21 makeB() native;
22
23 void setup() native """
24 // This code is all inside 'setup' and so not accesible from the global scope.
25 function A(){}
26 function B(){}
27 B.prototype.foo = function() { return 'B.foo'; };
28 makeA = function(){return new A};
29 makeB = function(){return new B};
30 """;
31
32 var inscrutable;
33 main() {
34 setup();
35 inscrutable = (x) => x;
36 inscrutable = inscrutable(inscrutable);
37
38 var a = makeA();
39 var b = makeB();
40 var c = inscrutable(new C());
41
42 Expect.isTrue(a is A);
43 Expect.isFalse(b is A);
44 Expect.isFalse(c is A);
45
46 Expect.isFalse(a is B);
47 Expect.isTrue(b is B);
48 Expect.isFalse(c is B);
49
50 Expect.isFalse(a is C);
51 Expect.isFalse(b is C);
52 Expect.isTrue(c is C);
53
54 Expect.equals('B.foo', b.foo());
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698