Download src/php/php-src/ext/hash/tests/hash_equals.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/hash/tests/hash_equals.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/ext/hash/tests/hash_equals.phpt
-
curl -L -o hash_equals.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/hash/tests/hash_equals.phpt
1.45 kB
| --TEST-- | |
| Hash: hash_equals() test | |
| --FILE-- | |
| function trycatch_dump(...$tests) { | |
| foreach ($tests as $test) { | |
| try { | |
| var_dump($test()); | |
| } | |
| catch (\Error $e) { | |
| echo '[' . get_class($e) . '] ' . $e->getMessage() . "\n"; | |
| } | |
| } | |
| } | |
| trycatch_dump( | |
| fn() => hash_equals("same", "same"), | |
| fn() => hash_equals("not1same", "not2same"), | |
| fn() => hash_equals("short", "longer"), | |
| fn() => hash_equals("longer", "short"), | |
| fn() => hash_equals("", "notempty"), | |
| fn() => hash_equals("notempty", ""), | |
| fn() => hash_equals("", ""), | |
| fn() => hash_equals(123, "NaN"), | |
| fn() => hash_equals("NaN", 123), | |
| fn() => hash_equals(123, 123), | |
| fn() => hash_equals(null, ""), | |
| fn() => hash_equals(null, 123), | |
| fn() => hash_equals(null, null), | |
| ); | |
| --EXPECT-- | |
| bool(true) | |
| bool(false) | |
| bool(false) | |
| bool(false) | |
| bool(false) | |
| bool(false) | |
| bool(true) | |
| [TypeError] hash_equals(): Argument #1 ($known_string) must be of type string, int given | |
| [TypeError] hash_equals(): Argument #2 ($user_string) must be of type string, int given | |
| [TypeError] hash_equals(): Argument #1 ($known_string) must be of type string, int given | |
| [TypeError] hash_equals(): Argument #1 ($known_string) must be of type string, null given | |
| [TypeError] hash_equals(): Argument #1 ($known_string) must be of type string, null given | |
| [TypeError] hash_equals(): Argument #1 ($known_string) must be of type string, null given | |