mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
LibJS: Fix old object numeric key test now that toString() is correct
This commit is contained in:
parent
d3524f47a0
commit
f603128e55
2 changed files with 4 additions and 7 deletions
|
@ -134,15 +134,13 @@ static String double_to_string(double d)
|
|||
|
||||
auto number_string = number_string_builder.to_string();
|
||||
|
||||
// HACK: (sunverwerth) I'm not sure how the ECMAScript spec deals with numbers that
|
||||
// can not be exactly represented in IEE754 so I'm cutting off after the 15th fractional digit.
|
||||
// Otherwise 3.14.toString() would come out as "3.140000000000000124344978758017532527446746826171875"
|
||||
// Chrome and Firefox output the expected "3.14" here
|
||||
// FIXME: Remove this hack.
|
||||
// FIXME: Instead find the shortest round-trippable representation.
|
||||
// Remove decimals after the 15th position
|
||||
if (end_index > intpart_end + 15) {
|
||||
exponent += end_index - intpart_end - 15;
|
||||
end_index = intpart_end + 15;
|
||||
}
|
||||
// HACK end
|
||||
|
||||
// remove leading zeroes
|
||||
while (start_index < end_index && number_string[start_index] == '0') {
|
||||
|
|
|
@ -87,8 +87,7 @@ describe("correct behavior", () => {
|
|||
test("floating point keys", () => {
|
||||
const math = { 3.14: "pi" };
|
||||
expect(math["3.14"]).toBe("pi");
|
||||
// FIXME: Floating point literals are coerced to i32
|
||||
// expect(math[3.14]).toBe("pi");
|
||||
expect(math[3.14]).toBe("pi");
|
||||
});
|
||||
|
||||
test("keywords as property keys", () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue