Skip to content

Commit 600439b

Browse files
committed
Add tests for null cases
1 parent b39d140 commit 600439b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ext/standard/tests/math/clamp.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ echo clamp('2025-08-01', '2025-08-15', '2025-09-15'), "\n";
2121
echo clamp('2025-08-20', '2025-08-15', '2025-09-15'), "\n";
2222
echo clamp(new \DateTimeImmutable('2025-08-01'), new \DateTimeImmutable('2025-08-15'), new \DateTimeImmutable('2025-09-15'))->format('Y-m-d'), "\n";
2323
echo clamp(new \DateTimeImmutable('2025-08-20'), new \DateTimeImmutable('2025-08-15'), new \DateTimeImmutable('2025-09-15'))->format('Y-m-d'), "\n";
24+
var_dump(clamp(null, -1, 1));
25+
var_dump(clamp(null, 1, 3));
26+
var_dump(clamp(null, -3, -1));
27+
var_dump(clamp(-9999, null, 10));
28+
var_dump(clamp(12, null, 10));
29+
var_dump(clamp(-9999, 5, null));
30+
var_dump(clamp(12, 5, null));
2431

2532
try {
2633
var_dump(clamp(4, NAN, 6));
@@ -56,6 +63,13 @@ string(1) "d"
5663
2025-08-20
5764
2025-08-15
5865
2025-08-20
66+
int(-1)
67+
int(1)
68+
int(-3)
69+
int(-9999)
70+
int(10)
71+
int(5)
72+
int(12)
5973
clamp(): Argument #2 ($min) cannot be NAN
6074
clamp(): Argument #3 ($max) cannot be NAN
6175
clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max)

0 commit comments

Comments
 (0)