1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/extensions/errorcolumnblame.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,73 @@ 1.4 +/* 1.5 + * Any copyright is dedicated to the Public Domain. 1.6 + * http://creativecommons.org/licenses/publicdomain/ 1.7 + */ 1.8 + 1.9 +var BUGNUMBER = 568142; 1.10 +var summary = 'error reporting blames column as well as line'; 1.11 + 1.12 +function test(f, col) { 1.13 + var caught = false; 1.14 + try { 1.15 + f(); 1.16 + } catch (e) { 1.17 + caught = true; 1.18 + assertEq(e.columnNumber, col); 1.19 + } 1.20 + assertEq(caught, true); 1.21 +} 1.22 + 1.23 +/* Note single hard tab before return! */ 1.24 +function foo(o) { 1.25 + return o.p; 1.26 +} 1.27 +test(foo, 1); 1.28 + 1.29 +//234567890123456789 1.30 +test(function(f) { return f.bar; }, 19); 1.31 +test(function(f) { return f(); }, 19); 1.32 +/* Cover negative colspan case using for(;;) loop with error in update part. */ 1.33 +test(function(){ 1.34 + //0 1 2 3 4 1.35 + //012345678901234567890123456789012345678901 1.36 + eval("function baz() { for (var i = 0; i < 10; i += a.b); assertEq(i !== i, true); }"); 1.37 + baz(); 1.38 +}, 41); 1.39 + 1.40 +// 1 2 3 1.41 +//234567890123456789012345678901234 1.42 +test(function() { var tmp = null; tmp(); }, 34) 1.43 +test(function() { var tmp = null; tmp.foo; }, 35) 1.44 + 1.45 +/* Just a generic 'throw'. */ 1.46 +test(function() { 1.47 +//234567890123 1.48 + foo({}); throw new Error('a'); 1.49 +}, 13); 1.50 + 1.51 +/* Be sure to report the right statement */ 1.52 +test(function() { 1.53 + function f() { return true; } 1.54 + function g() { return false; } 1.55 +//234567890123456789012345678 1.56 + f(); g(); f(); if (f()) a += e; 1.57 +}, 28); 1.58 + 1.59 +//2345678901234567890 1.60 +test(function() { e++; }, 18); 1.61 +test(function() {print += e; }, 17); 1.62 +test(function(){e += 1 }, 16); 1.63 +test(function() { print[e]; }, 19); 1.64 +test(function() { e[1]; }, 18); 1.65 +test(function() { e(); }, 18); 1.66 +test(function() { 1(); }, 18); 1.67 +test(function() { Object.defineProperty() }, 18); 1.68 + 1.69 +test(function() { 1.70 +//23456789012345678901 1.71 + function foo() { asdf; } foo() 1.72 +}, 21); 1.73 + 1.74 +reportCompare(0, 0, "ok"); 1.75 + 1.76 +printStatus("All tests passed!");