/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//----------------------------------------------------------------------------- var BUGNUMBER = "336376"; var summary = "Tests reserved words in contexts in which they are not reserved"; var actual, expect;
printBugNumber(BUGNUMBER);
printStatus(summary);
/************** * TEST SETUP *
**************/
// // New tests go in Tester.prototype._tests. A test is called with a single // argument, the keyword to test in the syntax tested by that test. Tests // should not return anything, and they should signal failure by throwing an // explanatory exception and success by not throwing one. // // If you define a new test, make sure to name it using an informative string // for ease of use if any keywords ever manually define the array of tests they // should pass, and add it as a string to ALL_TESTS. //
function r(keyword, tests)
{ /** * @param keyword * the keyword as a string * @param tests * array of test numbers against it, or leave undefined to run all tests * against it
*/ function Reserved(keyword, tests)
{ this.keyword = keyword; if (tests) this.tests = tests; else this.tests = ALL_TESTS;
}
Reserved.prototype =
{
toString: function()
{ return"'" + this.keyword + "' being run against tests " + this.tests;
}
}; returnnew Reserved(keyword, tests);
}
// like reserved words, but not quite reserved words const PSEUDO_RESERVED =
[
r("true"),
r("false"),
r("null"),
];
// new-in-ES4 reserved words -- fill this as each is implemented const ECMA_262_4_RESERVED_WORDS =
[
r("let")
];
/** * @param keyword * string containing the tested keyword * @param test * the number of the failing test * @param error * the exception thrown when running the test
*/ function Failure(keyword, test, error)
{ this.keyword = keyword; this.test = test; this.error = error;
}
Failure.prototype =
{
toString: function()
{ return"*** FAILURE on '" + this.keyword + "'!\n" + "* test: " + this.test + "\n" + "* error: " + this.error + "\n";
}
};
function Tester()
{ this._failedTests = [];
}
Tester.prototype =
{
testReservedWords: function(reservedArray)
{ var rv; for (var i = 0, sz = reservedArray.length; i < sz; i++)
{ var res = reservedArray[i]; if (!res) continue;
var tests = res.tests; for (var j = 0, sz2 = tests.length; j < sz2; j++)
{ var test = tests[j]; if (!test) continue;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.