diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-01-26 11:55:16 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-01-26 11:58:08 +0100 |
commit | ddc5aa7cd3121300f2ba6e68cb038258a616d4e4 (patch) | |
tree | 63585f32e5334f6e7ea9f4693e94d740744e5482 /tests | |
parent | 58e1da9b7dd69af0f32fb2a70c1808dce8c51733 (diff) |
vm: fix NaN strict equality tests
A performance shortcut in `ucv_is_equal()` incorrectly led to `NaN === NaN`
being true. Fix the issue by only comparing pointers when the involved
types are not doubles.
Due to fixing `NaN !== NaN`, the `uniq()` function now requires a special
case to treat multiple NaNs equal for the sake of generating an array of
unique values.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/custom/04_bugs/30_nan_strict_equality | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/custom/04_bugs/30_nan_strict_equality b/tests/custom/04_bugs/30_nan_strict_equality new file mode 100644 index 0000000..4ec32e2 --- /dev/null +++ b/tests/custom/04_bugs/30_nan_strict_equality @@ -0,0 +1,14 @@ +When comparing `nan` with `nan` for strict equality or inequality, the +VM incorrectly treated the result as `true` or `false` respectively. + +-- Testcase -- +{{ NaN === NaN }} +{{ NaN !== NaN }} +{{ uniq([NaN, NaN]) }} +-- End -- + +-- Expect stdout -- +false +true +[ "NaN" ] +-- End -- |