1 description('This test exercises the source expression offset information that is attached to exception objects for the inspector.');
4 function testException(code
, errorStart
, errorCaret
, errorEnd
, message
) {
7 debug("Testing '"+code
+"'");
11 // begin/caret/end are not presently exposed in a web facing interface, so cannot be directly checked.
12 shouldBeTrue('ex.message == "' + message
+'"');
16 testException("undefined.a++", 0, 9, 11, "'undefined' is not an object (evaluating 'undefined.a')");
17 testException("++undefined.a", 2, 11, 13, "'undefined' is not an object (evaluating 'undefined.a')");
18 testException("undefined[0]++", 0, 9, 12, "'undefined' is not an object (evaluating 'undefined[0]')");
19 testException("++undefined[1]", 2, 11, 14, "'undefined' is not an object (evaluating 'undefined[1]')");
20 testException("undefined.b", 0, 9, 11, "'undefined' is not an object (evaluating 'undefined.b')");
21 testException("undefined[0]", 0, 9, 12, "'undefined' is not an object (evaluating 'undefined[0]')");
22 testException("undefined.b += 1", 0, 9, 11, "'undefined' is not an object (evaluating 'undefined.b')");
23 testException("undefined[0] += 1", 0, 9, 12, "'undefined' is not an object (evaluating 'undefined[0]')");
24 testException("undefined()", 0, 9, 11, "'undefined' is not a function (evaluating 'undefined()')");
25 testException("new undefined()", 0, 13, 15, "'undefined' is not a constructor (evaluating 'new undefined()')");
26 testException("({}).b()", 0, 6, 8, "'undefined' is not a function (evaluating '({}).b()')");
27 testException("new {}.b()", 0, 8, 10, "'undefined' is not a constructor (evaluating 'new {}.b()')");
28 testException("1()", 0, 1, 3, "'1' is not a function (evaluating '1()')");
29 testException("new 1()", 0, 5, 7, "'1' is not a constructor (evaluating 'new 1()')");
30 testException("throw { message : 'thrown object' }", 0, undefined, 35, "thrown object");
31 testException("1 in undefined", 0, 5, 14, "'undefined' is not a valid argument for 'in' (evaluating '1 in undefined')");
32 testException("1 instanceof undefined", 0, 13, 22, "'undefined' is not a valid argument for 'instanceof' (evaluating '1 instanceof undefined')");
33 testException("for (undefined.b in [1]) {}", 5, 14, 16, "'undefined' is not an object (evaluating 'undefined.b')");
34 testException("for (undefined[0] in [1]) {}", 5, 14, 17, "'undefined' is not an object (evaluating 'undefined[0]')");
35 testException("undefined.a = 5", 0, 9, 15, "'undefined' is not an object (evaluating 'undefined.a = 5')");
36 testException("undefined[0] = 5", 0, 9, 16, "'undefined' is not an object (evaluating 'undefined[0] = 5')");
37 testException("({b:undefined}).b.a = 5", 0, 17, 23, "'undefined' is not an object (evaluating '({b:undefined}).b.a = 5')");
38 testException("({b:undefined}).b[0] = 5", 0, 17, 24, "'undefined' is not an object (evaluating '({b:undefined}).b[0] = 5')");
39 testException("undefined.a += 5", 0, 9, 11, "'undefined' is not an object (evaluating 'undefined.a')");
40 testException("undefined[0] += 5", 0, 9, 12, "'undefined' is not an object (evaluating 'undefined[0]')");
41 testException("({b:undefined}).b.a += 5", 0, 17, 19, "'undefined' is not an object (evaluating '({b:undefined}).b.a')");
42 testException("({b:undefined}).b[0] += 5", 0, 17, 20, "'undefined' is not an object (evaluating '({b:undefined}).b[0]')");