OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 5 |
6 import "package:expect/expect.dart"; | |
7 | |
8 testIntClamp() { | 6 testIntClamp() { |
9 Expect.equals(2, 2.clamp(1, 3)); | 7 Expect.equals(2, 2.clamp(1, 3)); |
10 Expect.equals(1, 0.clamp(1, 3)); | 8 Expect.equals(1, 0.clamp(1, 3)); |
11 Expect.equals(3, 4.clamp(1, 3)); | 9 Expect.equals(3, 4.clamp(1, 3)); |
12 Expect.equals(-2, (-2).clamp(-3, -1)); | 10 Expect.equals(-2, (-2).clamp(-3, -1)); |
13 Expect.equals(-1, 0.clamp(-3, -1)); | 11 Expect.equals(-1, 0.clamp(-3, -1)); |
14 Expect.equals(-3, (-4).clamp(-3, -1)); | 12 Expect.equals(-3, (-4).clamp(-3, -1)); |
15 Expect.equals(0, 1.clamp(0, 0)); | 13 Expect.equals(0, 1.clamp(0, 0)); |
16 Expect.equals(0, (-1).clamp(0, 0)); | 14 Expect.equals(0, (-1).clamp(0, 0)); |
17 Expect.equals(0, 0.clamp(0, 0)); | 15 Expect.equals(0, 0.clamp(0, 0)); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 Expect.throws(() => 0.0.clamp(double.NAN, double.INFINITY), | 69 Expect.throws(() => 0.0.clamp(double.NAN, double.INFINITY), |
72 (e) => e is ArgumentError); | 70 (e) => e is ArgumentError); |
73 } | 71 } |
74 | 72 |
75 main() { | 73 main() { |
76 testIntClamp(); | 74 testIntClamp(); |
77 testDoubleClamp(); | 75 testDoubleClamp(); |
78 testDoubleClampInt(); | 76 testDoubleClampInt(); |
79 testDoubleClampExtremes(); | 77 testDoubleClampExtremes(); |
80 } | 78 } |
OLD | NEW |