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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/types/inferrer_visitor.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js_extra/12320_test.dart
diff --git a/tests/compiler/dart2js_extra/12320_test.dart b/tests/compiler/dart2js_extra/12320_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..60317f99a6ccf913550220269df589bae4675ff3
--- /dev/null
+++ b/tests/compiler/dart2js_extra/12320_test.dart
@@ -0,0 +1,49 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+// Regression test for Issue 12320, Issue 12363.
+
+String log = '';
+int x;
+
+void main() {
+ (run)(run);
+ // The little dance with passing [run] as an argument to confuse the optimizer
+ // so that [run] is not inlined. If [run] is inlined, the bug (Issue 12320)
+ // eliminates the following 'Expect', making the test appear to pass!
+ Expect.equals('[Foo][Foo 1][Bar][Foo][Foo 0]', log);
+}
+
+void run(f) {
+ if (f is !int) {
+ f(1);
+ } else {
+ x = f;
+ callFoo();
+ x = 2;
+ callBar();
+ callFoo();
+ }
+}
+
+void callFoo() {
+ log += '[Foo]';
+ switch(x) {
+ case 0:
+ log += '[Foo 0]';
+ break;
+ case 1:
+ log += '[Foo 1]';
+ break;
+ default:
+ throw 'invalid x';
+ }
+}
+
+void callBar() {
+ log += '[Bar]';
+ x = 0;
+}
« 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