|
1 /* |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/licenses/publicdomain/ |
|
4 */ |
|
5 |
|
6 var BUGNUMBER = 568142; |
|
7 var summary = 'error reporting blames column as well as line'; |
|
8 |
|
9 function test(f, col) { |
|
10 var caught = false; |
|
11 try { |
|
12 f(); |
|
13 } catch (e) { |
|
14 caught = true; |
|
15 assertEq(e.columnNumber, col); |
|
16 } |
|
17 assertEq(caught, true); |
|
18 } |
|
19 |
|
20 /* Note single hard tab before return! */ |
|
21 function foo(o) { |
|
22 return o.p; |
|
23 } |
|
24 test(foo, 1); |
|
25 |
|
26 //234567890123456789 |
|
27 test(function(f) { return f.bar; }, 19); |
|
28 test(function(f) { return f(); }, 19); |
|
29 /* Cover negative colspan case using for(;;) loop with error in update part. */ |
|
30 test(function(){ |
|
31 //0 1 2 3 4 |
|
32 //012345678901234567890123456789012345678901 |
|
33 eval("function baz() { for (var i = 0; i < 10; i += a.b); assertEq(i !== i, true); }"); |
|
34 baz(); |
|
35 }, 41); |
|
36 |
|
37 // 1 2 3 |
|
38 //234567890123456789012345678901234 |
|
39 test(function() { var tmp = null; tmp(); }, 34) |
|
40 test(function() { var tmp = null; tmp.foo; }, 35) |
|
41 |
|
42 /* Just a generic 'throw'. */ |
|
43 test(function() { |
|
44 //234567890123 |
|
45 foo({}); throw new Error('a'); |
|
46 }, 13); |
|
47 |
|
48 /* Be sure to report the right statement */ |
|
49 test(function() { |
|
50 function f() { return true; } |
|
51 function g() { return false; } |
|
52 //234567890123456789012345678 |
|
53 f(); g(); f(); if (f()) a += e; |
|
54 }, 28); |
|
55 |
|
56 //2345678901234567890 |
|
57 test(function() { e++; }, 18); |
|
58 test(function() {print += e; }, 17); |
|
59 test(function(){e += 1 }, 16); |
|
60 test(function() { print[e]; }, 19); |
|
61 test(function() { e[1]; }, 18); |
|
62 test(function() { e(); }, 18); |
|
63 test(function() { 1(); }, 18); |
|
64 test(function() { Object.defineProperty() }, 18); |
|
65 |
|
66 test(function() { |
|
67 //23456789012345678901 |
|
68 function foo() { asdf; } foo() |
|
69 }, 21); |
|
70 |
|
71 reportCompare(0, 0, "ok"); |
|
72 |
|
73 printStatus("All tests passed!"); |