OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // Test num.clamp. | 4 // Test num.clamp. |
| 5 // VMOptions=--no-use-field-guards |
| 6 // VMOptions= |
5 | 7 |
6 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
7 | 9 |
8 // Pedestrian implementation of sign, following its specification directly. | 10 // Pedestrian implementation of sign, following its specification directly. |
9 num sign(num value) { | 11 num sign(num value) { |
10 if (value is int) { | 12 if (value is int) { |
11 if (value < 0) return -1; | 13 if (value < 0) return -1; |
12 if (value > 0) return 1; | 14 if (value > 0) return 1; |
13 return 0; | 15 return 0; |
14 } | 16 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 Expect.equals(number.isNegative, actualSign.isNegative, "$number:negative"); | 100 Expect.equals(number.isNegative, actualSign.isNegative, "$number:negative"); |
99 var renumber = actualSign * number.abs(); | 101 var renumber = actualSign * number.abs(); |
100 Expect.equals(number, renumber, "$number (sign*abs)"); | 102 Expect.equals(number, renumber, "$number (sign*abs)"); |
101 if (number is int) { | 103 if (number is int) { |
102 Expect.isTrue(renumber is int, "$number (sign*abs) is int"); | 104 Expect.isTrue(renumber is int, "$number (sign*abs) is int"); |
103 } else { | 105 } else { |
104 Expect.isTrue(renumber is double, "$number (sign*abs) is double"); | 106 Expect.isTrue(renumber is double, "$number (sign*abs) is double"); |
105 } | 107 } |
106 } | 108 } |
107 } | 109 } |
OLD | NEW |