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

Unified Diff: tests/language/switch_bad_case_test.dart

Issue 25561002: Disallow double in case clauses and const map literal keys (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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_dart2js.status ('k') | tests/language/switch_int_double_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/switch_bad_case_test.dart
===================================================================
--- tests/language/switch_bad_case_test.dart (revision 0)
+++ tests/language/switch_bad_case_test.dart (revision 0)
@@ -0,0 +1,36 @@
+// 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 reporting a compile-time error if case expressions do not all have
+// the same type or are of type double.
+
+import "package:expect/expect.dart";
+
+void main() {
+ Expect.equals("IV", caesarSays(4));
+ Expect.equals(null, caesarSays(2));
+ Expect.equals(null, archimedesSays(3.14));
+}
+
+caesarSays(n) {
+ switch (n) {
+ case 1:
+ return "I";
+ case 4:
+ return "IV";
+ case "M": /// 01: compile-time error
+ return 1000; /// 01: continued
+ }
+ return null;
+}
+
+archimedesSays(n) {
+ switch (n) { /// 02: continued
+ case 3.14: /// 02: compile-time error
+ return "Pi"; /// 02: continued
+ case 2.71828: /// 02: continued
+ return "Huh?"; /// 02: continued
+ } /// 02: continued
+ return null;
+}
« no previous file with comments | « tests/language/language_dart2js.status ('k') | tests/language/switch_int_double_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698