Commit ccc9aba
fix(node/assert): deepStrictEqual now correctly handles Number objects (denoland#31233)
Fixes denoland#31172
## Description
The `deepStrictEqual` function was using `asserts.equal()` which doesn't
properly handle boxed primitives like Number objects. Changed it to use
`isDeepStrictEqual()` from `comparisons.ts` which correctly handles
Number, String, Boolean, BigInt, and Symbol objects.
## Changes
- Modified `ext/node/polyfills/assert.ts`:
- Added import for `isDeepStrictEqual` from
`ext:deno_node/internal/util/comparisons.ts`
- Updated `deepStrictEqual` function to use `isDeepStrictEqual()`
instead of `asserts.equal()`
- Added test cases in `tests/unit_node/assert_test.ts`:
- Test that `deepStrictEqual` throws `AssertionError` for different
Number objects
- Test that `deepStrictEqual` passes for equal Number objects
## Testing
Added unit tests to verify:
- `deepStrictEqual` throws `AssertionError` for different Number objects
(e.g., `new Number(1)` vs `new Number(2)`)
- `deepStrictEqual` passes for equal Number objects (e.g., `new
Number(1)` vs `new Number(1)`)
## Related Issue
denoland#31172 - `assert.deepStrictEqual` does not throw exception for Number
objects
---------
Co-authored-by: Daniel Rahmanto <[email protected]>1 parent 5421a29 commit ccc9aba
File tree
3 files changed
+39
-11
lines changed- ext/node/polyfills
- internal/util
- tests/unit_node
3 files changed
+39
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
| |||
394 | 397 | | |
395 | 398 | | |
396 | 399 | | |
397 | | - | |
| 400 | + | |
398 | 401 | | |
399 | 402 | | |
400 | 403 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
30 | 36 | | |
31 | 37 | | |
32 | 38 | | |
| |||
265 | 271 | | |
266 | 272 | | |
267 | 273 | | |
268 | | - | |
| 274 | + | |
269 | 275 | | |
270 | 276 | | |
271 | 277 | | |
| |||
276 | 282 | | |
277 | 283 | | |
278 | 284 | | |
279 | | - | |
280 | | - | |
| 285 | + | |
| 286 | + | |
281 | 287 | | |
282 | 288 | | |
283 | 289 | | |
284 | 290 | | |
285 | 291 | | |
286 | | - | |
| 292 | + | |
287 | 293 | | |
288 | 294 | | |
289 | 295 | | |
| |||
436 | 442 | | |
437 | 443 | | |
438 | 444 | | |
439 | | - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
440 | 448 | | |
441 | 449 | | |
442 | 450 | | |
| |||
459 | 467 | | |
460 | 468 | | |
461 | 469 | | |
462 | | - | |
| 470 | + | |
463 | 471 | | |
464 | | - | |
| 472 | + | |
465 | 473 | | |
466 | 474 | | |
467 | 475 | | |
468 | 476 | | |
469 | | - | |
| 477 | + | |
470 | 478 | | |
471 | 479 | | |
472 | 480 | | |
473 | 481 | | |
474 | 482 | | |
475 | 483 | | |
476 | | - | |
| 484 | + | |
477 | 485 | | |
478 | 486 | | |
479 | 487 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
0 commit comments