(i,v)
| 26 | Array.isArray = function(o) { return o.constructor === Array; } |
| 27 | |
| 28 | function arrayReviver(i,v) { |
| 29 | if (i != "") { |
| 30 | currentHolder = this; |
| 31 | debug(""); |
| 32 | debug("Ensure the holder for our array is indeed an array"); |
| 33 | shouldBeTrue("Array.isArray(currentHolder)"); |
| 34 | shouldBe("currentHolder.length", "" + expectedLength); |
| 35 | if (i > 0) { |
| 36 | debug(""); |
| 37 | debug("Ensure that we always get the same holder"); |
| 38 | shouldBe("currentHolder", "lastHolder"); |
| 39 | } |
| 40 | switch (Number(i)) { |
| 41 | case 0: |
| 42 | v = undefined; |
| 43 | debug(""); |
| 44 | debug("Ensure that the holder already has all the properties present at the start of filtering"); |
| 45 | shouldBe("currentHolder[0]", '"a value"'); |
| 46 | shouldBe("currentHolder[1]", '"another value"'); |
| 47 | shouldBe("currentHolder[2]", '"and another value"'); |
| 48 | shouldBe("currentHolder[3]", '"to delete"'); |
| 49 | shouldBe("currentHolder[4]", '"extra value"'); |
| 50 | break; |
| 51 | |
| 52 | case 1: |
| 53 | debug(""); |
| 54 | debug("Ensure that returning undefined has removed the property 0 from the holder during filtering."); |
| 55 | shouldBeFalse("currentHolder.hasOwnProperty(0)"); |
| 56 | currentHolder[2] = "a replaced value"; |
| 57 | break; |
| 58 | |
| 59 | case 2: |
| 60 | debug(""); |
| 61 | debug("Ensure that changing the value of a property is reflected while filtering.") |
| 62 | shouldBe("currentHolder[2]", '"a replaced value"'); |
| 63 | value = v; |
| 64 | debug(""); |
| 65 | debug("Ensure that the changed value is reflected in the arguments passed to the reviver"); |
| 66 | shouldBe("value", "currentHolder[2]"); |
| 67 | delete this[3]; |
| 68 | break; |
| 69 | |
| 70 | case 3: |
| 71 | debug(""); |
| 72 | debug("Ensure that we visited a value that we have deleted, and that deletion is reflected while filtering."); |
| 73 | shouldBeFalse("currentHolder.hasOwnProperty(3)"); |
| 74 | value = v; |
| 75 | debug(""); |
| 76 | debug("Ensure that when visiting a deleted property value is undefined"); |
| 77 | shouldBeUndefined("value"); |
| 78 | this.length = 3; |
| 79 | v = "undelete the property"; |
| 80 | expectedLength = 4; |
| 81 | break; |
| 82 | |
| 83 | case 4: |
| 84 | if (this.length != 4) { |
| 85 | testFailed("Did not call reviver for deleted property"); |
nothing calls this directly
no test coverage detected