⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181556 in webkit


Ignore:
Timestamp:
Mar 16, 2015, 8:45:54 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Update Map/Set to treat -0 and 0 as the same value
https://bugs.webkit.org/show_bug.cgi?id=142709

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2015-03-16
Reviewed by Csaba Osztrogonác.

Source/JavaScriptCore:

  • runtime/MapData.h:

(JSC::MapDataImpl<Entry>::KeyType::KeyType):
No longer special case -0. It will be treated as the same as 0.

LayoutTests:

  • js/basic-map-expected.txt:
  • js/basic-set-expected.txt:
  • js/script-tests/basic-map.js:
  • js/script-tests/basic-set.js:

Update tests now that -0 and 0 are treated the same.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181553 r181556  
     12015-03-16  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Update Map/Set to treat -0 and 0 as the same value
     4        https://bugs.webkit.org/show_bug.cgi?id=142709
     5
     6        Reviewed by Csaba Osztrogonác.
     7
     8        * js/basic-map-expected.txt:
     9        * js/basic-set-expected.txt:
     10        * js/script-tests/basic-map.js:
     11        * js/script-tests/basic-set.js:
     12        Update tests now that -0 and 0 are treated the same.
     13
    1142015-03-16  Max Stepin  <maxstepin@gmail.com>
    215
  • trunk/LayoutTests/js/basic-map-expected.txt

    r181333 r181556  
    3838PASS map.set(-0, 1) is map
    3939PASS map.set(0, 2) is map
     40PASS map.size is 1
    4041PASS map.set(Infinity, 3) is map
    4142PASS map.set(-Infinity, 4) is map
     
    4344PASS map.set('0', 6) is map
    4445PASS map.set(0.1, 7) is map
    45 PASS map.size is 7
    46 PASS map.get(-0) is 1
     46PASS map.size is 6
     47PASS map.get(-0) is 2
    4748PASS map.get(0) is 2
    4849PASS map.get(Infinity) is 3
     
    5960PASS map.has(0.1) is true
    6061PASS map.delete(-0) is true
    61 PASS map.delete(0) is true
     62PASS map.delete(0) is false
    6263PASS map.delete(Infinity) is true
    6364PASS map.delete(-Infinity) is true
  • trunk/LayoutTests/js/basic-set-expected.txt

    r181333 r181556  
    4747PASS set.add(-0) is set
    4848PASS set.add(0) is set
     49PASS set.size is 1
    4950PASS set.add(Infinity) is set
    5051PASS set.add(-Infinity) is set
     
    5253PASS set.add('0') is set
    5354PASS set.add(0.1) is set
    54 PASS set.size is 7
     55PASS set.size is 6
    5556PASS set.has(-0) is true
    5657PASS set.has(0) is true
     
    6162PASS set.has(0.1) is true
    6263PASS set.delete(-0) is true
    63 PASS set.delete(0) is true
     64PASS set.delete(0) is false
    6465PASS set.delete(Infinity) is true
    6566PASS set.delete(-Infinity) is true
  • trunk/LayoutTests/js/script-tests/basic-map.js

    r181333 r181556  
    4242shouldBe("map.set(-0, 1)", "map")
    4343shouldBe("map.set(0, 2)", "map")
     44shouldBe("map.size", "1")
    4445shouldBe("map.set(Infinity, 3)", "map")
    4546shouldBe("map.set(-Infinity, 4)", "map")
     
    4748shouldBe("map.set('0', 6)", "map")
    4849shouldBe("map.set(0.1, 7)", "map")
    49 shouldBe("map.size", "7")
    50 shouldBe("map.get(-0)", "1")
     50shouldBe("map.size", "6")
     51shouldBe("map.get(-0)", "2")
    5152shouldBe("map.get(0)", "2")
    5253shouldBe("map.get(Infinity)", "3")
     
    6566
    6667shouldBeTrue("map.delete(-0)")
    67 shouldBeTrue("map.delete(0)")
     68shouldBeFalse("map.delete(0)")
    6869shouldBeTrue("map.delete(Infinity)")
    6970shouldBeTrue("map.delete(-Infinity)")
  • trunk/LayoutTests/js/script-tests/basic-set.js

    r181333 r181556  
    4949shouldBe("set.add(-0)", "set")
    5050shouldBe("set.add(0)", "set")
     51shouldBe("set.size", "1")
    5152shouldBe("set.add(Infinity)", "set")
    5253shouldBe("set.add(-Infinity)", "set")
     
    5455shouldBe("set.add('0')", "set")
    5556shouldBe("set.add(0.1)", "set")
    56 shouldBe("set.size", "7")
     57shouldBe("set.size", "6")
    5758
    5859shouldBeTrue("set.has(-0)")
     
    6566
    6667shouldBeTrue("set.delete(-0)")
    67 shouldBeTrue("set.delete(0)")
     68shouldBeFalse("set.delete(0)")
    6869shouldBeTrue("set.delete(Infinity)")
    6970shouldBeTrue("set.delete(-Infinity)")
  • trunk/Source/JavaScriptCore/ChangeLog

    r181516 r181556  
     12015-03-16  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Update Map/Set to treat -0 and 0 as the same value
     4        https://bugs.webkit.org/show_bug.cgi?id=142709
     5
     6        Reviewed by Csaba Osztrogonác.
     7
     8        * runtime/MapData.h:
     9        (JSC::MapDataImpl<Entry>::KeyType::KeyType):
     10        No longer special case -0. It will be treated as the same as 0.
     11
    1122015-03-15  Joseph Pecoraro  <pecoraro@apple.com>
    213
  • trunk/Source/JavaScriptCore/runtime/MapData.h

    r181458 r181556  
    153153    }
    154154    double d = v.asDouble();
    155     if (std::isnan(d) || (std::signbit(d) && d == 0.0)) {
     155    if (std::isnan(d)) {
    156156        value = v;
    157157        return;
Note: See TracChangeset for help on using the changeset viewer.