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

Side by Side Diff: tests/compiler/dart2js_extra/switch_test.dart

Issue 2810093002: Don't duplicate switch case code if we fall through to the default case. (Closed)
Patch Set: Created 3 years, 8 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 | « pkg/compiler/lib/src/ssa/codegen.dart ('k') | no next file » | 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) 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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 switcher(val) { 7 switcher(val) {
8 var x = 0; 8 var x = 0;
9 switch (val) { 9 switch (val) {
10 case 1: 10 case 1:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 break; 51 break;
52 } else { 52 } else {
53 // Enable when continue to switch-case is implemented. 53 // Enable when continue to switch-case is implemented.
54 continue hest; 54 continue hest;
55 } 55 }
56 } 56 }
57 } 57 }
58 return x; 58 return x;
59 } 59 }
60 60
61 var x = 0;
62
63 @NoInline()
64 switcher3(val) {
65 switch(val) {
66 case 1:
67 default:
68 incrementX();
69 }
70 }
71
72 incrementX() {
73 x++;
74 }
75
61 badswitches(val) { 76 badswitches(val) {
62 // Test some badly formed switch bodies. 77 // Test some badly formed switch bodies.
63 // 01 - a label/statement without a following case/default. 78 // 01 - a label/statement without a following case/default.
64 // 02 - a label without a following case/default or statement. 79 // 02 - a label without a following case/default or statement.
65 switch (val) { 80 switch (val) {
66 foo: break; // //# 01: compile-time error 81 foo: break; // //# 01: compile-time error
67 case 2: // //# 02: compile-time error 82 case 2: // //# 02: compile-time error
68 foo: // //# 02: continued 83 foo: // //# 02: continued
69 } 84 }
70 } 85 }
71 86
72 main() { 87 main() {
73 Expect.equals(100, switcher(1)); 88 Expect.equals(100, switcher(1));
74 Expect.equals(200, switcher(2)); 89 Expect.equals(200, switcher(2));
75 Expect.equals(300, switcher(3)); 90 Expect.equals(300, switcher(3));
76 Expect.equals(400, switcher(4)); 91 Expect.equals(400, switcher(4));
77 92
78 Expect.equals(100, switcher2(1)); 93 Expect.equals(100, switcher2(1));
79 Expect.equals(100, switcher2(2)); 94 Expect.equals(100, switcher2(2));
80 Expect.equals(200, switcher2(3)); 95 Expect.equals(200, switcher2(3));
81 Expect.equals(200, switcher2(4)); 96 Expect.equals(200, switcher2(4));
82 Expect.equals(200, switcher2(5)); 97 Expect.equals(200, switcher2(5));
83 98
99 switcher3(1);
100 Expect.equals(1, x);
101
84 badswitches(42); 102 badswitches(42);
85 } 103 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/codegen.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698