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

Side by Side Diff: tests/language/is_interfaces2_test.dart

Issue 10951026: Fix algorithm to know whether we should emit an is check on a class: all interfaces/implemented cla… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class A { 5 class A {
6 } 6 }
7 7
8 class B extends A { 8 class B extends A {
9 } 9 }
10 10
11 class C implements B { 11 class C extends B {
12 }
13
14 class D implements C {
12 } 15 }
13 16
14 int inscrutable(int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1)); 17 int inscrutable(int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1));
Lasse Reichstein Nielsen 2012/09/19 09:52:10 Please add parentheses!
ngeoffray 2012/09/19 10:14:39 But you should not scrutinize it! :) Done
15 18
16 main() { 19 main() {
17 var things = [new A(), new B(), new C()]; 20 var things = [new A(), new B(), new C(), new D()];
18 21
19 var a = things[inscrutable(0)]; 22 var a = things[inscrutable(0)];
20 Expect.isTrue(a is A); 23 Expect.isTrue(a is A);
21 Expect.isFalse(a is B); 24 Expect.isFalse(a is B);
22 Expect.isFalse(a is C); 25 Expect.isFalse(a is C);
26 Expect.isFalse(a is D);
23 27
24 var b = things[inscrutable(1)]; 28 var b = things[inscrutable(1)];
25 Expect.isTrue(b is A); 29 Expect.isTrue(b is A);
26 Expect.isTrue(b is B); 30 Expect.isTrue(b is B);
27 Expect.isFalse(b is C); 31 Expect.isFalse(b is C);
32 Expect.isFalse(b is D);
28 33
29 var c = things[inscrutable(2)]; 34 var c = things[inscrutable(2)];
30 Expect.isTrue(c is A); 35 Expect.isTrue(c is A);
31 Expect.isTrue(c is B); 36 Expect.isTrue(c is B);
32 Expect.isTrue(c is C); 37 Expect.isTrue(c is C);
38 Expect.isFalse(c is D);
39
40 var d = things[inscrutable(3)];
41 Expect.isTrue(d is A);
42 Expect.isTrue(d is B);
43 Expect.isTrue(d is C);
44 Expect.isTrue(d is D);
33 } 45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698