Coverage of for-in

Gareth Smith gds at doc.ic.ac.uk
Thu Apr 25 02:08:18 PDT 2013


Thanks Paul!

Since no-one seems to know about 12.6.4-2.js, I'll file a bug report.

As for the for-in shadowing test, does the following look better? I'll
update the bug report tomorrow unless someone spots another problem.

Thanks again,

Gareth.

--8<---------------cut here---------------start------------->8---
function testcase() {
    var proto = {prop:"inheritedValue"};

    var ConstructFun = function () { };
    ConstructFun.prototype = proto;

    var child = new ConstructFun();
    Object.defineProperty(child, "prop", {
        value: "overriddenValue",
        enumerable: false,
        configurable: true,
        writable: true
    });

    for (var k in child) {
        if(k==="prop") {
            return false; // prop is shadowed by a non-enumerable property.
        }
    }
    return true; // We didn't see the non-enumerable 'prop'.
}
--8<---------------cut here---------------end--------------->8---



Paul Ruizendaal <pnr at planet.nl> writes:
> [1] for-in shadowing test
> I've built a version of my little engine with this bug introduced, and
> it still passes all tests. Hence I can confirm that the current suite
> does not directly or accidentally test for correct implementation of
> non-emurable shadowing. I would write the test about the same, perhaps
> specially testing for "prop" in the for-in loop as to not rely on
> Object.prototype not having any enumerable properties (which would be
> a different bug, or a change in a later version of ES).
>
> [2] 12.6.4-2.js
> Can't think of such a behavior. The test seems to find its origin in
> IE10 development; perhaps somebody on the MS team can look in the IE10
> bug tracker and see if there is a clue.
>
> Paul
>
> On 16 Apr 2013, at 19:18 , Gareth Smith wrote:
>
>>
>> There doesn't seem to be any coverage of the issue described in the
>> following V8 and WebKit bugs:
>>
>> http://code.google.com/p/v8/issues/detail?id=705
>> https://bugs.webkit.org/show_bug.cgi?id=38970
>>
>> The issue is that if a non-enumerable property shadows an enumerable
>> property, for-in should not enumerate it.
>>
>> I've suggested a possible test here:
>>
>> https://bugs.ecmascript.org/show_bug.cgi?id=1445
>>
>> While I was looking for tests which cover the issue above, I noticed
>> test ch12/12.6/12.6.4/12.6.4-2.js (quoted below).
>>
>> It sets up a non-enumerable property in the prototype of an object we
>> wish to loop over. It does not shadow this property. It does not test to
>> see if that property is enumerated. Is this test intended to test a
>> behaviour I haven't thought of, or is there a bug in this test?
>>
>> Thanks,
>>
>> Gareth.
>>
>> function testcase() {
>>       var obj = {};
>>
>>       var proto = {};
>>
>>       Object.defineProperty(proto, "prop", {
>>           value: "inheritedValue",
>>           enumerable: false,
>>           configurable: true,
>>           writable: true
>>       });
>>
>>       var ConstructFun = function () { };
>>       ConstructFun.prototype = proto;
>>
>>       var child = new ConstructFun();
>>
>>       Object.defineProperty(child, "prop1", {
>>           value: "overridedValue1",
>>           enumerable: false
>>       });
>>       Object.defineProperty(child, "prop2", {
>>           value: "overridedValue2",
>>           enumerable: true
>>       });
>>       var accessedProp1 = false;
>>       var accessedProp2 = false;
>>
>>       for (var p in child) {
>>           if (child.hasOwnProperty(p)) {
>>               if (p === "prop1") {
>>                   accessedProp1 = true;
>>               }
>>               if (p === "prop2") {
>>                   accessedProp2 = true;
>>               }
>>           }
>>       }
>>       return !accessedProp1 && accessedProp2 && child.prop1 === "overridedValue1" && child.prop2 === "overridedValue2";
>>   }
>> runTestCase(testcase);
>> _______________________________________________
>> test262-discuss mailing list
>> test262-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/test262-discuss
>
> _______________________________________________
> test262-discuss mailing list
> test262-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/test262-discuss


More information about the test262-discuss mailing list