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

Unified Diff: tests/language/switch_int_double_test.dart

Issue 21292003: Handle int/double case expression types correctly. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments 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 | « tests/language/language.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/switch_int_double_test.dart
diff --git a/tests/language/switch_int_double_test.dart b/tests/language/switch_int_double_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d6e02dd34a74c07c42ac90dcf51f9c5802366e8d
--- /dev/null
+++ b/tests/language/switch_int_double_test.dart
@@ -0,0 +1,27 @@
+// 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.
+
+// Test that double literals with no fractional part is not treated as having
+// static type int.
+
+import "package:expect/expect.dart";
+
+void main() {
+ Expect.equals(100, test(1.0));
+ Expect.equals(75, test(0.75));
+ Expect.equals(null, test(0.5));
+}
+
+int test(num ratio) {
+ switch (ratio) {
+ case 0.75:
+ return 75;
+ case 1.0:
+ return 100;
+ case 2: /// 01: compile-time error
+ return 200; /// 01: continued
+ case 'foo': /// 02: compile-time error
+ return 400; /// 02: continued
+ }
+}
« no previous file with comments | « tests/language/language.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698