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

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

Issue 261403004: In constant evaluation, properly handle redirecting factory constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 class A { 7 class A {
8 const A(); 8 const A();
9 const factory A.B() = B; 9 const factory A.B() = B;
10 const factory A.C() = C; 10 const factory A.C() = C;
11 const factory A.C2() = D; 11 const factory A.C2() = D;
12 } 12 }
13 13
14 class B implements A { 14 class B implements A {
15 const B(); 15 const B();
16 16
17 operator ==(o) => true; /// 00: compile-time error 17 operator ==(o) => true; /// 00: compile-time error
18 } 18 }
19 19
20 class C implements A { 20 class C implements A {
21 final int x; 21 final int x;
22 const C() : x = 0; 22 const C() : x = 0;
23 const C.fromD() : x = 1; 23 const C.fromD() : x = 1;
24 } 24 }
25 25
26 class D implements C { 26 class D implements C {
27 int get x => 0;
Brian Wilkerson 2014/05/06 21:44:32 I don't know enough about this test to know whethe
27 const factory D() = C.fromD; 28 const factory D() = C.fromD;
28 } 29 }
29 30
30 main() { 31 main() {
31 switch (new B()) { 32 switch (new B()) {
32 case const A.B(): Expect.fail("bad switch"); break; /// 00: continued 33 case const A.B(): Expect.fail("bad switch"); break; /// 00: continued
33 } 34 }
34 35
35 switch (new C()) { 36 switch (new C()) {
36 case const C(): Expect.fail("bad switch"); break; 37 case const C(): Expect.fail("bad switch"); break;
37 case const A.C(): Expect.fail("bad switch"); break; 38 case const A.C(): Expect.fail("bad switch"); break;
38 case const A.C2(): Expect.fail("bad switch"); break; 39 case const A.C2(): Expect.fail("bad switch"); break;
39 case const A(): Expect.fail("bad switch"); break; /// 01: compile-time erro r 40 case const A(): Expect.fail("bad switch"); break; /// 01: compile-time erro r
40 } 41 }
41 42
42 switch (new A()) { 43 switch (new A()) {
43 case const A(): Expect.fail("bad switch"); break; 44 case const A(): Expect.fail("bad switch"); break;
44 case const A.B(): Expect.fail("bad switch"); break; /// 02: compile-time er ror 45 case const A.B(): Expect.fail("bad switch"); break; /// 02: compile-time er ror
45 } 46 }
46 } 47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698