| OLD | NEW |
| (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 that double literals with no fractional part is not treated as having |
| 6 // static type int. |
| 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 } |
| OLD | NEW |