<p>
This test verifies that property caching behaves correctly in the face of deleted
properties. If the test passes, you'll see a series of PASS messages below.
</p>

<pre id="console"></pre>

<script>
(function() {
    if (window.testRunner)
        testRunner.dumpAsText();

    function log(s)
    {
        if (this.document)
            document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
        else
            print(s + "\n");
    }
    
    function shouldBe(a, aDescription, b)
    {
        if (a === b) {
            log("PASS: " + aDescription + " should be " + b + " and is.");
        } else {
            log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
        }
    }
    
    Array.equal = function equal(a, b)
    {
        if (a.length != b.length)
            return false;
        for (var i = 0; i < a.length; ++i)
            if (a[i] != b[i])
                return false;
        return true;
    }

    var expectedProperties = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];

    function getProperties(o)
    {
        return [
            o.p1,
            o.p2,
            o.p3,
            o.p4,
            o.p5,
            o.p6,
            o.p7,
            o.p8,
            o.p9,
            o.p10
        ];
    }
    
    function addProperties(o)
    {
        o.p1 = 1;
        o.p2 = 2;
        o.p3 = 3;
        o.p4 = 4;
        o.p5 = 5;
        o.p6 = 6;
        o.p7 = 7;
        o.p8 = 8;
        o.p9 = 9;
        o.p10 = 10;
    }

    function removeProperties(o)
    {
        delete o.p10;
        delete o.p9;
        delete o.p8;
        delete o.p7;
        delete o.p6;
        delete o.p5;
        delete o.p4;
        delete o.p3;
        delete o.p2;
    }
    
    function makeO()
    {
        var o = { };
        addProperties(o);
        removeProperties(o);
        addProperties(o);
        return o;
    }

    var o;
    var properties;

    for (var i = 0; i < 3; ++i) {
        o = makeO();
        properties = getProperties(o);
        shouldBe(Array.equal(properties, expectedProperties), "Array.equal(properties, expectedProperties)", true);
    }

    o = { x: 0, y: 0, z: 0 };
    delete o.z;
    for (var i = 0; i < 3; ++i) {
        o.x = 1;
        shouldBe(o.x, "o.x", 1);
    }
})();
</script>
