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

Side by Side Diff: tests/language/switch_int_double_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, 2 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 | « tests/language/switch_bad_case_test.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 // Test reporting a compile-time error if case expressions do not all have
6 // the same type.
7
8 import "package:expect/expect.dart";
9
10 void main() {
11 Expect.equals(100, test(1.0));
12 Expect.equals(75, test(0.75));
13 Expect.equals(null, test(0.5));
14 }
15
16 int test(num ratio) {
17 switch (ratio) {
18 case 0.75:
19 return 75;
20 case 1.0:
21 return 100;
22 case 2: /// 01: compile-time error
23 return 200; /// 01: continued
24 case 'foo': /// 02: compile-time error
25 return 400; /// 02: continued
26 }
27 }
OLDNEW
« no previous file with comments | « tests/language/switch_bad_case_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698