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

Side by Side Diff: tests/compiler/dart2js_extra/12320_test.dart

Issue 22279006: Fix for switch type inferrence (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add test Created 7 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/types/inferrer_visitor.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
(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 // Regression test for Issue 12320, Issue 12363.
8
9 String log = '';
10 int x;
11
12 void main() {
13 (run)(run);
14 // The little dance with passing [run] as an argument to confuse the optimizer
15 // so that [run] is not inlined. If [run] is inlined, the bug (Issue 12320)
16 // eliminates the following 'Expect', making the test appear to pass!
17 Expect.equals('[Foo][Foo 1][Bar][Foo][Foo 0]', log);
18 }
19
20 void run(f) {
21 if (f is !int) {
22 f(1);
23 } else {
24 x = f;
25 callFoo();
26 x = 2;
27 callBar();
28 callFoo();
29 }
30 }
31
32 void callFoo() {
33 log += '[Foo]';
34 switch(x) {
35 case 0:
36 log += '[Foo 0]';
37 break;
38 case 1:
39 log += '[Foo 1]';
40 break;
41 default:
42 throw 'invalid x';
43 }
44 }
45
46 void callBar() {
47 log += '[Bar]';
48 x = 0;
49 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/types/inferrer_visitor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698