js/src/tests/ecma/extensions/errorcolumnblame.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial