PageRenderTime 24ms CodeModel.GetById 15ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/js/src/jit-test/tests/jaeger/testSetElem-Indexed.js

http://github.com/zpao/v8monkey
JavaScript | 36 lines | 21 code | 10 blank | 5 comment | 0 complexity | db2c94f7989d6a1c886f8910b0bb00b7 MD5 | raw file
 1// vim: set ts=4 sw=4 tw=99 et:
 2
 3function f() {
 4    return [[], [], [], []];
 5}
 6
 7function setelem(obj, key, val) {
 8    obj[key] = val;
 9}
10
11// Generate IC
12setelem([], 0, "hi");
13setelem([], 0, "hi");
14
15// Get some arrays pre-indexing.
16var arrays = f();
17
18// Do bad stuff.
19Object.defineProperty(Object.prototype, "1", { set: function (v) { this.kettle = v; } });
20
21var k = arrays[0];
22setelem(k, 1, 13);
23assertEq(k.kettle, 13);
24assertEq(k.hasOwnProperty("1"), false);
25
26Object.defineProperty(Array.prototype, "2", { set: function (v) { this.pot = v; } });
27k = arrays[1];
28setelem(k, 2, "yam");
29assertEq(k.pot, "yam");
30
31gc();
32
33// make sure this reset okay.
34setelem([], 0, "hi");
35setelem([], 0, "hi");
36