File: eval.js

package info (click to toggle)
kjs 5.103.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,020 kB
  • sloc: cpp: 36,704; javascript: 5,079; yacc: 790; perl: 191; sh: 52; makefile: 7
file content (32 lines) | stat: -rw-r--r-- 712 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
shouldBe("eval.length", "1");
shouldBe("eval('this')", "this");

function MyObject() {
  this.x = 99;
}

eval("b = new MyObject();");
var bx = b.x   // rule out side effects of eval() in shouldBe() test function
shouldBe("bx", "99");


eval("var c = new MyObject();"); // the 'var' makes a difference
var cx = c.x;
shouldBe("cx", "99");

// KDE bug #45679
if (true.eval) {
  var o = { str:1 };
  shouldBe("o.eval('str')", "1");
  shouldBe("o.eval('this')", "this");
} else {
  testPassed("Skipping test for deprecated Object.prototype.eval()");
}

// problem from within khtml
function lotto() {
  // j must be accessible to eval()
  for (var j = 0; j < 1; j++)
    return eval('j');
}
shouldBe("lotto()", "0");