-
Notifications
You must be signed in to change notification settings - Fork 651
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix gcStableHashHermesValue() for NaN
Summary: NaNs with different sign bits should get the same hash. Reviewed By: neildhar Differential Revision: D68584614 fbshipit-source-id: aa9fd7f0ee822f5a68241dcd4cbf15772c03d848
- Loading branch information
1 parent
871de01
commit c908a05
Showing
2 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
// RUN: %hermes %s | %FileCheck --match-full-lines %s | ||
// RUN: %shermes -exec %s | %FileCheck --match-full-lines %s | ||
|
||
// Test that different NaN representations get the same hash. | ||
globalThis.zero = 0; | ||
var m = new Map([[NaN, 42]]); | ||
var dynamicNaN = 0 / globalThis.zero; | ||
print(m.get(dynamicNaN)); | ||
// CHECK: 42 | ||
print(m.has(dynamicNaN)); | ||
// CHECK: true | ||
print(m.get(NaN)); | ||
// CHECK: 42 | ||
print(m.has(NaN)); | ||
// CHECK: true | ||
|
||
m = new Map([[dynamicNaN, 24]]); | ||
print(m.get(dynamicNaN)); | ||
// CHECK: 24 | ||
print(m.has(dynamicNaN)); | ||
// CHECK: true | ||
print(m.get(NaN)); | ||
// CHECK: 24 | ||
print(m.has(NaN)); | ||
// CHECK: true |