diff --git a/.eslintignore b/.eslintignore index 6780d2865700..d00073b3a7bc 100644 --- a/.eslintignore +++ b/.eslintignore @@ -307,7 +307,6 @@ js/xpconnect/** js/src/devtools/** js/src/octane/** js/src/jit-test/** -js/src/jsapi-tests/binast/** js/src/tests/** js/src/Y.js diff --git a/js/moz.configure b/js/moz.configure index 89c640c2bba3..4075cb516d9c 100644 --- a/js/moz.configure +++ b/js/moz.configure @@ -408,18 +408,3 @@ def enable_pipeline_operator(value): set_config('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator) set_define('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator) - - - -# Experimental support for BinAST -# ============================================================== - -@depends(target, milestone) -def enable_build_binast(target, milestone): - # For reasons unknown at this time, BinAST causes timeouts on win32 - # and failures on Android. - if milestone.is_nightly and not (target.kernel == 'WINNT' and target.cpu == 'x86') and not (target.os == 'Android'): - return True - -set_define('JS_BUILD_BINAST', enable_build_binast) -set_config('JS_BUILD_BINAST', enable_build_binast) diff --git a/js/public/RootingAPI.h b/js/public/RootingAPI.h index 9b64ff5ded3e..62d3f0f1cb68 100644 --- a/js/public/RootingAPI.h +++ b/js/public/RootingAPI.h @@ -867,9 +867,6 @@ class JS_PUBLIC_API(AutoGCRooter) enum { VALARRAY = -2, /* js::AutoValueArray */ PARSER = -3, /* js::frontend::Parser */ -#if defined(JS_BUILD_BINAST) - BINPARSER = -4, /* js::frontend::BinSource */ -#endif // defined(JS_BUILD_BINAST) VALVECTOR = -10, /* js::AutoValueVector */ IDVECTOR = -11, /* js::AutoIdVector */ OBJVECTOR = -14, /* js::AutoObjectVector */ diff --git a/js/src/devtools/automation/autospider.py b/js/src/devtools/automation/autospider.py index a50e368f62d5..03081738d2e4 100755 --- a/js/src/devtools/automation/autospider.py +++ b/js/src/devtools/automation/autospider.py @@ -32,7 +32,6 @@ def directories(pathmodule, cwd, fixup=lambda s: s): DIR = directories(os.path, os.getcwd()) PDIR = directories(posixpath, os.environ["PWD"], fixup=lambda s: re.sub(r'^(\w):', r'/\1', s)) -env['CPP_UNIT_TESTS_DIR_JS_SRC'] = DIR.js_src parser = argparse.ArgumentParser( description='Run a spidermonkey shell build job') diff --git a/js/src/frontend/BinSource.cpp b/js/src/frontend/BinSource.cpp deleted file mode 100644 index 7326e911e898..000000000000 --- a/js/src/frontend/BinSource.cpp +++ /dev/null @@ -1,2503 +0,0 @@ -#include "frontend/BinSource.h" - -#include "mozilla/ArrayUtils.h" -#include "mozilla/Casting.h" -#include "mozilla/Maybe.h" -#include "mozilla/Move.h" -#include "mozilla/PodOperations.h" -#include "mozilla/Vector.h" - -#include "frontend/BinTokenReaderTester.h" -#include "frontend/FullParseHandler.h" -#include "frontend/Parser.h" -#include "frontend/SharedContext.h" - -#include "vm/RegExpObject.h" - -#include "frontend/ParseContext-inl.h" -#include "frontend/ParseNode-inl.h" - - -// # About compliance with EcmaScript -// -// For the moment, this parser implements ES5. Future versions will be extended -// to ES6 and further on. -// -// By design, it does NOT implement Annex B.3.3. If possible, we would like -// to avoid going down that rabbit hole. -// -// -// # About the AST -// -// At this stage of experimentation, the AST specifications change often. This -// version of the parser attempts to implement -// https://gist.github.com/Yoric/2390f0367515c079172be2526349b294 -// -// -// # About validating the AST -// -// Normally, this implementation validates all properties of the AST *except* the -// order of fields, which is partially constrained by the AST spec (e.g. in a block, -// field `scope` must appear before field `body`, etc.). -// -// -// # About names and scopes -// -// One of the key objectives of the BinAST syntax is to be able to entirely skip -// parsing inner functions until they are needed. With a purely syntactic AST, -// this is generally impossible, as we would need to walk the AST to find -// lexically-bound/var-bound variables, instances of direct eval, etc. -// -// To achieve this, BinAST files contain scope data, as instances of -// `BinJS:Scope` nodes. Rather than walking the AST to assign bindings -// to scopes, we extract data from the `BinJS:Scope` and check it lazily, -// once we actually need to walk the AST. -// -// WARNING: The current implementation DOES NOT perform the check yet. It -// is therefore unsafe. -// -// # About directives -// -// Currently, directives are ignored and treated as regular strings. -// -// They should be treated lazily (whenever we open a subscope), like bindings. - -// Evaluate an expression, checking that the result is not 0. -// -// Throw `cx->alreadyReportedError()` if it returns 0/nullptr. -#define TRY(EXPR) \ - do { \ - if (!EXPR) \ - return cx_->alreadyReportedError(); \ - } while(false) - - -#define TRY_VAR(VAR, EXPR) \ - do { \ - VAR = EXPR; \ - if (!VAR) \ - return cx_->alreadyReportedError(); \ - } while (false) - -#define TRY_DECL(VAR, EXPR) \ - auto VAR = EXPR; \ - if (!VAR) \ - return cx_->alreadyReportedError(); - -#define TRY_EMPL(VAR, EXPR) \ - do { \ - auto _tryEmplResult = EXPR; \ - if (!_tryEmplResult) \ - return cx_->alreadyReportedError(); \ - VAR.emplace(_tryEmplResult.unwrap()); \ - } while (false) - -#define MOZ_TRY_EMPLACE(VAR, EXPR) \ - do { \ - auto _tryEmplResult = EXPR; \ - if (_tryEmplResult.isErr()) \ - return ::mozilla::Err(_tryEmplResult.unwrapErr()); \ - VAR.emplace(_tryEmplResult.unwrap()); \ - } while (false) - -using namespace mozilla; - -namespace js { -namespace frontend { - -using AutoList = BinTokenReaderTester::AutoList; -using AutoTaggedTuple = BinTokenReaderTester::AutoTaggedTuple; -using AutoTuple = BinTokenReaderTester::AutoTuple; -using BinFields = BinTokenReaderTester::BinFields; -using Chars = BinTokenReaderTester::Chars; -using NameBag = GCHashSet; -using Names = GCVector; -using UsedNamePtr = UsedNameTracker::UsedNameMap::Ptr; - -namespace { - // Compare a bunch of `uint8_t` values (as returned by the tokenizer_) with - // a string literal (and ONLY a string literal). - template - bool operator==(const Chars& left, const char (&right)[N]) { - return BinTokenReaderTester::equals(left, right); - } - - bool isMethod(BinKind kind) { - switch (kind) { - case BinKind::ObjectMethod: - case BinKind::ObjectGetter: - case BinKind::ObjectSetter: - return true; - default: - return false; - } - } - -#if defined(DEBUG) - bool isMethodOrFunction(BinKind kind) { - if (isMethod(kind)) - return true; - if (kind == BinKind::FunctionExpression || kind == BinKind::FunctionDeclaration) - return true; - return false; - } -#endif // defined(DEBUG) -} - -JS::Result -BinASTParser::parse(const Vector& data) -{ - return parse(data.begin(), data.length()); -} - -JS::Result -BinASTParser::parse(const uint8_t* start, const size_t length) -{ - auto result = parseAux(start, length); - poison(); // Make sure that the parser is never used again accidentally. - return result; -} - - -JS::Result -BinASTParser::parseAux(const uint8_t* start, const size_t length) -{ - tokenizer_.emplace(cx_, start, length); - - Directives directives(options().strictOption); - GlobalSharedContext globalsc(cx_, ScopeKind::Global, - directives, options().extraWarningsOption); - BinParseContext globalpc(cx_, this, &globalsc, /* newDirectives = */ nullptr); - if (!globalpc.init()) - return cx_->alreadyReportedError(); - - ParseContext::VarScope varScope(cx_, &globalpc, usedNames_); - if (!varScope.init(&globalpc)) - return cx_->alreadyReportedError(); - - ParseNode* result(nullptr); - MOZ_TRY_VAR(result, parseProgram()); - - Maybe bindings = NewGlobalScopeData(cx_, varScope, alloc_, parseContext_); - if (!bindings) - return cx_->alreadyReportedError(); - globalsc.bindings = *bindings; - - return result; // Magic conversion to Ok. -} - -Result -BinASTParser::parseProgram() -{ - BinKind kind; - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - if (kind != BinKind::Program) - return this->raiseInvalidKind("Program", kind); - - ParseNode* result; - MOZ_TRY_VAR(result, parseBlockStatementAux(kind, fields)); - - TRY(guard.done()); - return result; -} - -JS::Result -BinASTParser::parseBlockStatement() -{ - BinKind kind; - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - ParseNode* result(nullptr); - switch (kind) { - default: - return raiseInvalidKind("BlockStatement", kind); - case BinKind::BlockStatement: - MOZ_TRY_VAR(result, parseBlockStatementAux(kind, fields)); - break; - } - - TRY(guard.done()); - return result; -} - -JS::Result -BinASTParser::parseAndUpdateScopeNames(ParseContext::Scope& scope, DeclarationKind kind) -{ - AutoList guard(*tokenizer_); - uint32_t length = 0; - - TRY(tokenizer_->enterList(length, guard)); - RootedAtom name(cx_); - for (uint32_t i = 0; i < length; ++i) { - name = nullptr; - - MOZ_TRY(readString(&name)); - auto ptr = scope.lookupDeclaredNameForAdd(name); - if (ptr) { - if (kind == DeclarationKind::Let || kind == DeclarationKind::Const) - return raiseError("Variable redeclaration"); - -#if defined(DEBUG) - // FIXME: Fix binjs-ref. - fprintf(stderr, "Weird: `var` redeclaration. Check encoder: "); - name->dump(); - fprintf(stderr, "\n"); -#endif // defined(DEBUG) - continue; - } - - TRY(scope.addDeclaredName(parseContext_, ptr, name.get(), kind, tokenizer_->offset())); - } - TRY(guard.done()); - return Ok(); -} - -JS::Result -BinASTParser::parseAndUpdateCurrentScope() -{ - return parseAndUpdateScope(parseContext_->varScope(), *parseContext_->innermostScope()); -} - -JS::Result -BinASTParser::parseAndUpdateScope(ParseContext::Scope& varScope, ParseContext::Scope& letScope) -{ - BinKind kind; - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - switch (kind) { - default: - return raiseInvalidKind("Scope", kind); - case BinKind::BINJS_Scope: - for (auto field : fields) { - switch (field) { - case BinField::BINJS_HasDirectEval: - MOZ_TRY(readBool()); // Currently ignored. - break; - case BinField::BINJS_LetDeclaredNames: - MOZ_TRY(parseAndUpdateScopeNames(letScope, DeclarationKind::Let)); - break; - case BinField::BINJS_ConstDeclaredNames: - MOZ_TRY(parseAndUpdateScopeNames(letScope, DeclarationKind::Const)); - break; - case BinField::BINJS_VarDeclaredNames: - MOZ_TRY(parseAndUpdateScopeNames(varScope, DeclarationKind::Var)); - break; - case BinField::BINJS_CapturedNames: { - Rooted> names(cx_); //FIXME: Currently ignored. - MOZ_TRY(parseStringList(&names)); - break; - } - default: - return raiseInvalidField("Scope", field); - } - } - break; - } - - TRY(guard.done()); - return Ok(); -} - -JS::Result -BinASTParser::parseBlockStatementAux(const BinKind kind, const BinFields& fields) -{ - ParseContext::Statement stmt(parseContext_, StatementKind::Block); - ParseContext::Scope scope(cx_, parseContext_, usedNames_); - TRY(scope.init(parseContext_)); - - ParseNode* body(nullptr); - ParseNode* directives(nullptr); // FIXME: Largely ignored - - for (auto field : fields) { - switch (field) { - case BinField::BINJS_Scope: - MOZ_TRY(parseAndUpdateCurrentScope()); - break; - case BinField::Body: - MOZ_TRY_VAR(body, parseStatementList()); - break; - case BinField::Directives: - if (kind != BinKind::Program) - return raiseInvalidField("BlockStatement", field); - MOZ_TRY_VAR(directives, parseDirectiveList()); - break; - default: - return raiseInvalidField("BlockStatement", field); - } - } - - // In case of absent optional fields, inject default values. - if (!body) - body = factory_.newStatementList(tokenizer_->pos()); - - MOZ_TRY_VAR(body, appendDirectivesToBody(body, directives)); - - ParseNode* result; - if (kind == BinKind::Program) { - result = body; - } else { - TRY_DECL(bindings, NewLexicalScopeData(cx_, scope, alloc_, parseContext_)); - TRY_VAR(result, factory_.newLexicalScope(*bindings, body)); - } - - return result; -} - -JS::Result -BinASTParser::appendDirectivesToBody(ParseNode* body, ParseNode* directives) -{ - ParseNode* result = body; - if (directives && directives->pn_count >= 1) { - MOZ_ASSERT(directives->isArity(PN_LIST)); - - // Convert directive list to a list of strings. - TRY_DECL(prefix, factory_.newStatementList(directives->pn_head->pn_pos)); - for (ParseNode* iter = directives->pn_head; iter != nullptr; iter = iter->pn_next) { - TRY_DECL(statement, factory_.newExprStatement(iter, iter->pn_pos.end)); - prefix->appendWithoutOrderAssumption(statement); - } - - // Prepend to the body. - ParseNode* iter = body->pn_head; - while (iter) { - ParseNode* next = iter->pn_next; - prefix->appendWithoutOrderAssumption(iter); - iter = next; - } - prefix->setKind(body->getKind()); - prefix->setOp(body->getOp()); - result = prefix; -#if defined(DEBUG) - result->checkListConsistency(); -#endif // defined(DEBUG) - } - - return result; -} - -JS::Result -BinASTParser::parseStringList(MutableHandle> out) -{ - MOZ_ASSERT(out.get().isNothing()); // Sanity check: the node must not have been parsed yet. - - uint32_t length; - AutoList guard(*tokenizer_); - - Names result(cx_); - - TRY(tokenizer_->enterList(length, guard)); - if (!result.reserve(length)) - return raiseOOM(); - - RootedAtom string(cx_); - for (uint32_t i = 0; i < length; ++i) { - string = nullptr; - - MOZ_TRY(readString(&string)); - result.infallibleAppend(Move(string)); // Checked in the call to `reserve`. - } - - TRY(guard.done()); - out.set(Move(Some(Move(result)))); - return Ok(); -} - -JS::Result -BinASTParser::parseStatementList() -{ - uint32_t length; - AutoList guard(*tokenizer_); - - TRY_DECL(result, factory_.newStatementList(tokenizer_->pos())); - - TRY(tokenizer_->enterList(length, guard)); - for (uint32_t i = 0; i < length; ++i) { - BinKind kind; - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - - ParseNode* statement(nullptr); - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - switch (kind) { - case BinKind::FunctionDeclaration: - MOZ_TRY_VAR(statement, parseFunctionAux(kind, fields)); - break; - default: - MOZ_TRY_VAR(statement, parseStatementAux(kind, fields)); - break; - } - - TRY(guard.done()); - result->appendWithoutOrderAssumption(statement); - } - - TRY(guard.done()); - return result; -} - -JS::Result -BinASTParser::parseStatement() -{ - BinKind kind; - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - ParseNode* result; - MOZ_TRY_VAR(result, parseStatementAux(kind, fields)); - - TRY(guard.done()); - return result; -} - -JS::Result -BinASTParser::parseStatementAux(const BinKind kind, const BinFields& fields) -{ - const size_t start = tokenizer_->offset(); - - ParseNode* result(nullptr); - switch (kind) { - case BinKind::EmptyStatement: { - TRY_VAR(result, factory_.newEmptyStatement(tokenizer_->pos(start))); - break; - } - case BinKind::BlockStatement: - MOZ_TRY_VAR(result, parseBlockStatementAux(kind, fields)); - break; - case BinKind::ExpressionStatement: - MOZ_TRY_VAR(result, parseExpressionStatementAux(kind, fields)); - break; - case BinKind::DebuggerStatement: { - TRY_VAR(result, factory_.newDebuggerStatement(tokenizer_->pos(start))); - break; - } - case BinKind::WithStatement: { - ParseNode* body(nullptr); - ParseNode* expr(nullptr); - for (auto field : fields) { - switch (field) { - case BinField::Body: - MOZ_TRY_VAR(body, parseStatement()); - break; - case BinField::Object: - MOZ_TRY_VAR(expr, parseExpression()); - break; - default: - return raiseInvalidField("WithStatement", field); - } - } - - if (!body) - return raiseMissingField("WithStatement", BinField::Body); - if (!expr) - return raiseMissingField("WithStatement", BinField::Object); - - TRY_VAR(result, factory_.newWithStatement(start, expr, body)); - - break; - } - case BinKind::ReturnStatement: { - if (!parseContext_->isFunctionBox()) { - // Return statements are permitted only inside functions. - return raiseInvalidKind("Toplevel Statement", kind); - } - parseContext_->functionBox()->usesReturn = true; - - ParseNode* arg(nullptr); - for (auto field : fields) { - switch (field) { - case BinField::Argument: - MOZ_TRY_VAR(arg, parseExpression()); - break; - default: - return raiseInvalidField("ReturnStatement", field); - } - } - - TRY_VAR(result, factory_.newReturnStatement(arg, tokenizer_->pos(start))); - - break; - } - case BinKind::LabeledStatement: { - // We check for the existence of the jump target when parsing `break label;` or `continue label;`. - ParseContext::Statement stmt(parseContext_, StatementKind::Label); - ParseNode* label(nullptr); - ParseNode* body(nullptr); - - for (auto field : fields) { - switch (field) { - case BinField::Label: - MOZ_TRY_VAR(label, parseIdentifier()); - break; - case BinField::Body: { - if (!label) // By order of fields, `label` MUST always be before `body` in the file. - return raiseMissingField("LabeledStatement", BinField::Label); - MOZ_ASSERT(label->name()); - ParseContext::LabelStatement stmt(parseContext_, label->name()); - MOZ_TRY_VAR(body, parseStatement()); - break; - } - default: - return raiseInvalidField("LabeledStatement", field); - } - } - - if (!label) - return raiseMissingField("LabeledStatement", BinField::Label); - if (!body) - return raiseMissingField("LabeledStatement", BinField::Body); - - TRY_VAR(result, factory_.newLabeledStatement(label->name(), body, start)); - - break; - } - - case BinKind::BreakStatement: - case BinKind::ContinueStatement: - MOZ_TRY_VAR(result, parseBreakOrContinueStatementAux(kind, fields)); - break; - - case BinKind::IfStatement: { - ParseContext::Statement stmt(parseContext_, StatementKind::If); - - ParseNode* test(nullptr); - ParseNode* consequent(nullptr); - ParseNode* alternate(nullptr); // Optional - - for (auto field : fields) { - switch (field) { - case BinField::Test: - MOZ_TRY_VAR(test, parseExpression()); - break; - case BinField::Consequent: - MOZ_TRY_VAR(consequent, parseStatement()); - break; - case BinField::Alternate: - MOZ_TRY_VAR(alternate, parseStatement()); - break; - default: - return raiseInvalidField("IfStatement", field); - } - } - - if (!test) - return raiseMissingField("IfStatement", BinField::Test); - if (!consequent) - return raiseMissingField("IfStatement", BinField::Consequent); - - TRY_VAR(result, factory_.newIfStatement(start, test, consequent, alternate)); - - break; - } - case BinKind::SwitchStatement: { - ParseContext::Statement stmt(parseContext_, StatementKind::Switch); - ParseNode* discriminant(nullptr); - ParseNode* cases(nullptr); - - for (auto field : fields) { - switch (field) { - case BinField::Discriminant: { - MOZ_TRY_VAR(discriminant, parseExpression()); - break; - } - case BinField::Cases: { - MOZ_TRY_VAR(cases, parseSwitchCaseList()); - break; - } - default: - return raiseInvalidField("SwitchStatement", field); - } - } - - if (!discriminant) - return raiseMissingField("SwitchStatement", BinField::Discriminant); - if (!cases) { - TRY_VAR(cases, factory_.newStatementList(tokenizer_->pos())); - - TRY_VAR(cases, factory_.newLexicalScope(nullptr, cases)); - } - - TRY_VAR(result, factory_.newSwitchStatement(start, discriminant, cases)); - - break; - } - - case BinKind::ThrowStatement: { - ParseNode* arg(nullptr); - for (auto field : fields) { - if (field != BinField::Argument) - return raiseInvalidField("ThrowStatement", field); - - MOZ_TRY_VAR(arg, parseExpression()); - } - - if (!arg) - return raiseMissingField("ThrowStatement", BinField::Argument); - - TRY_VAR(result, factory_.newThrowStatement(arg, tokenizer_->pos(start))); - - break; - } - - case BinKind::TryStatement: { - ParseNode* block(nullptr); - ParseNode* handler(nullptr); - ParseNode* finalizer(nullptr); - - for (auto field : fields) { - switch (field) { - case BinField::Block: { - ParseContext::Statement stmt(parseContext_, StatementKind::Try); - ParseContext::Scope scope(cx_, parseContext_, usedNames_); - TRY(scope.init(parseContext_)); - MOZ_TRY_VAR(block, parseBlockStatement()); - break; - } - case BinField::Handler: - MOZ_TRY_VAR(handler, parseCatchClause()); - break; - - case BinField::Finalizer: { - ParseContext::Statement stmt(parseContext_, StatementKind::Finally); - ParseContext::Scope scope(cx_, parseContext_, usedNames_); - TRY(scope.init(parseContext_)); - MOZ_TRY_VAR(finalizer, parseBlockStatement()); - break; - } - - default: - return raiseInvalidField("TryStatement", field); - } - } - - if (!block) - return raiseMissingField("TryStatement", BinField::Handler); - if (!handler && !finalizer) - return raiseMissingField("TryStatement (without catch)", BinField::Finalizer); - - TRY_VAR(result, factory_.newTryStatement(start, block, handler, finalizer)); - break; - } - - case BinKind::WhileStatement: - case BinKind::DoWhileStatement: { - ParseContext::Statement stmt(parseContext_, kind == BinKind::WhileStatement ? StatementKind::WhileLoop : StatementKind::DoLoop); - ParseNode* test(nullptr); - ParseNode* body(nullptr); - - for (auto field : fields) { - switch (field) { - case BinField::Test: - MOZ_TRY_VAR(test, parseExpression()); - break; - case BinField::Body: - MOZ_TRY_VAR(body, parseStatement()); - break; - default: - return raiseInvalidField("WhileStatement | DoWhileStatement", field); - } - } - - if (!test) - return raiseMissingField("WhileStatement | DoWhileStatement", BinField::Test); - if (!body) - return raiseMissingField("WhileStatement | DoWhileStatement", BinField::Body); - - if (kind == BinKind::WhileStatement) - TRY_VAR(result, factory_.newWhileStatement(start, test, body)); - else - TRY_VAR(result, factory_.newDoWhileStatement(body, test, tokenizer_->pos(start))); - - break; - } - case BinKind::ForStatement: { - ParseContext::Statement stmt(parseContext_, StatementKind::ForLoop); - - // Implicit scope around the `for`, used to store `for (let x; ...; ...)` - // or `for (const x; ...; ...)`-style declarations. Detail on the - // declaration is stored as part of `BINJS_Scope`. - ParseContext::Scope scope(cx_, parseContext_, usedNames_); - TRY(scope.init(parseContext_)); - ParseNode* init(nullptr); // Optional - ParseNode* test(nullptr); // Optional - ParseNode* update(nullptr); // Optional - ParseNode* body(nullptr); // Required - - for (auto field : fields) { - switch (field) { - case BinField::Init: - MOZ_TRY_VAR(init, parseForInit()); - break; - case BinField::Test: - MOZ_TRY_VAR(test, parseExpression()); - break; - case BinField::Update: - MOZ_TRY_VAR(update, parseExpression()); - break; - case BinField::BINJS_Scope: // The scope always appears before the body. - MOZ_TRY(parseAndUpdateCurrentScope()); - break; - case BinField::Body: - MOZ_TRY_VAR(body, parseStatement()); - break; - default: - return raiseInvalidField("ForStatement", field); - } - } - - if (!body) - return raiseMissingField("ForStatement", BinField::Body); - - TRY_DECL(forHead, factory_.newForHead(init, test, update, tokenizer_->pos(start))); - TRY_VAR(result, factory_.newForStatement(start, forHead, body, /* iflags = */ 0)); - - if (!scope.isEmpty()) { - TRY_DECL(bindings, NewLexicalScopeData(cx_, scope, alloc_, parseContext_)); - TRY_VAR(result, factory_.newLexicalScope(*bindings, result)); - } - - break; - } - case BinKind::ForInStatement: { - ParseContext::Statement stmt(parseContext_, StatementKind::ForInLoop); - - // Implicit scope around the `for`, used to store `for (let x in ...)` - // or `for (const x in ...)`-style declarations. Detail on the - // declaration is stored as part of `BINJS_Scope`. - ParseContext::Scope scope(cx_, parseContext_, usedNames_); - TRY(scope.init(parseContext_)); - ParseNode* left(nullptr); - ParseNode* right(nullptr); - ParseNode* body(nullptr); - - for (auto field : fields) { - switch (field) { - case BinField::Left: - MOZ_TRY_VAR(left, parseForInInit()); - break; - case BinField::Right: - MOZ_TRY_VAR(right, parseExpression()); - break; - case BinField::Body: - MOZ_TRY_VAR(body, parseStatement()); - break; - case BinField::BINJS_Scope: - MOZ_TRY(parseAndUpdateCurrentScope()); - break; - default: - return raiseInvalidField("ForInStatement", field); - } - } - - if (!left) - return raiseMissingField("ForInStatement", BinField::Left); - if (!right) - return raiseMissingField("ForInStatement", BinField::Right); - if (!body) - return raiseMissingField("ForInStatement", BinField::Body); - - TRY_DECL(forHead, factory_.newForInOrOfHead(PNK_FORIN, left, right, tokenizer_->pos(start))); - TRY_VAR(result, factory_.newForStatement(start, forHead, body, /*flags*/ 0)); - - if (!scope.isEmpty()) { - TRY_DECL(bindings, NewLexicalScopeData(cx_, scope, alloc_, parseContext_)); - TRY_VAR(result, factory_.newLexicalScope(*bindings, result)); - } - break; - } - - case BinKind::VariableDeclaration: - MOZ_TRY_VAR(result, parseVariableDeclarationAux(kind, fields)); - break; - - default: - return raiseInvalidKind("Statement", kind); - } - - return result; -} - -JS::Result -BinASTParser::parseBreakOrContinueStatementAux(const BinKind kind, const BinFields& fields) -{ - const auto start = tokenizer_->offset(); - ParseNode* label(nullptr); - - for (auto field : fields) { - switch (field) { - case BinField::Label: - MOZ_TRY_VAR(label, parsePattern()); - - if (label && !label->isKind(PNK_NAME)) - return raiseError("ContinueStatement | BreakStatement - Label MUST be an identifier"); // FIXME: This should be changed in the grammar. - - break; - default: - return raiseInvalidField("ContinueStatement", field); - } - } - - TokenPos pos = tokenizer_->pos(start); - ParseNode* result; - if (kind == BinKind::ContinueStatement) { -#if 0 // FIXME: We probably need to fix the AST before making this check. - auto validity = parseContext_->checkContinueStatement(label ? label->name() : nullptr); - if (validity.isErr()) { - switch (validity.unwrapErr()) { - case ParseContext::ContinueStatementError::NotInALoop: - return raiseError(kind, "Not in a loop"); - case ParseContext::ContinueStatementError::LabelNotFound: - return raiseError(kind, "Label not found"); - } - } -#endif // 0 - // Ok, this is a valid continue statement. - TRY_VAR(result, factory_.newContinueStatement(label ? label->name() : nullptr, pos)); - } else { -#if 0 // FIXME: We probably need to fix the AST before making this check. - auto validity = parseContext_->checkBreakStatement(label ? label->name() : nullptr); - if (validity.isErr()) { - switch (validity.unwrapErr()) { - case ParseContext::BreakStatementError::ToughBreak: - return raiseError(kind, "Not in a loop"); - case ParseContext::BreakStatementError::LabelNotFound: - return raiseError(kind, "Label not found"); - } - } -#endif // 0 - // Ok, this is a valid break statement. - TRY_VAR(result, factory_.newBreakStatement(label ? label->name() : nullptr, pos)); - } - - MOZ_ASSERT(result); - - return result; -} - -JS::Result -BinASTParser::parseForInit() -{ - // This can be either a VarDecl or an Expression. - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - BinKind kind; - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - ParseNode* result(nullptr); - - switch (kind) { - case BinKind::VariableDeclaration: - MOZ_TRY_VAR(result, parseVariableDeclarationAux(kind, fields)); - break; - default: - // Parse as expression - MOZ_TRY_VAR(result, parseExpressionAux(kind, fields)); - break; - } - - TRY(guard.done()); - return result; -} - -JS::Result -BinASTParser::parseForInInit() -{ - // This can be either a VarDecl or a Pattern. - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - BinKind kind; - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - ParseNode* result(nullptr); - - switch (kind) { - case BinKind::VariableDeclaration: - MOZ_TRY_VAR(result, parseVariableDeclarationAux(kind, fields)); - break; - default: - // Parse as expression. Not a joke: http://www.ecma-international.org/ecma-262/5.1/index.html#sec-12.6.4 . - MOZ_TRY_VAR(result, parseExpressionAux(kind, fields)); - break; - } - - TRY(guard.done()); - return result; -} - -JS::Result -BinASTParser::parseFunctionAux(const BinKind kind, const BinFields& fields) -{ - MOZ_ASSERT(isMethodOrFunction(kind)); - - const size_t start = tokenizer_->offset(); - - ParseNode* id(nullptr); - ParseNode* params(nullptr); - ParseNode* body(nullptr); - ParseNode* directives(nullptr); // Largely ignored for the moment. - ParseNode* key(nullptr); // Methods only - - // Allocate the function before walking down the tree. - RootedFunction fun(cx_); - TRY_VAR(fun, NewFunctionWithProto(cx_, - /*native*/nullptr, - /*nargs ?*/0, - /*flags */ JSFunction::INTERPRETED_NORMAL, - /*enclosing env*/nullptr, - /*name*/ nullptr, // Will be known later - /*proto*/ nullptr, - /*alloc*/gc::AllocKind::FUNCTION, - TenuredObject - )); - TRY_DECL(funbox, alloc_.new_(cx_, - traceListHead_, - fun, - /* toStringStart = */0, - /* directives = */Directives(parseContext_), - /* extraWarning = */false, - GeneratorKind::NotGenerator, - FunctionAsyncKind::SyncFunction - )); - - traceListHead_ = funbox; - - FunctionSyntaxKind syntax; - switch (kind) { - case BinKind::FunctionDeclaration: - syntax = Statement; - break; - case BinKind::FunctionExpression: - syntax = PrimaryExpression; // FIXME: Probably doesn't work. - break; - case BinKind::ObjectMethod: - syntax = Method; - break; - case BinKind::ObjectGetter: - syntax = Getter; - break; - case BinKind::ObjectSetter: - syntax = Setter; - break; - default: - MOZ_CRASH("Invalid FunctionSyntaxKind"); // Checked above. - } - funbox->initWithEnclosingParseContext(parseContext_, syntax); - - // Container scopes. - ParseContext::Scope& varScope = parseContext_->varScope(); - ParseContext::Scope* letScope = parseContext_->innermostScope(); - - // Push a new ParseContext. - BinParseContext funpc(cx_, this, funbox, /* newDirectives = */ nullptr); - TRY(funpc.init()); - parseContext_->functionScope().useAsVarScope(parseContext_); - MOZ_ASSERT(parseContext_->isFunctionBox()); - - for (auto field : fields) { - switch (field) { - case BinField::Id: - MOZ_TRY_VAR(id, parseIdentifier()); - break; - case BinField::Params: - MOZ_TRY_VAR(params, parseArgumentList()); - break; - case BinField::BINJS_Scope: - // This scope information affects the scopes contained in the function body. MUST appear before the `body`. - MOZ_TRY(parseAndUpdateScope(varScope, *letScope)); - break; - case BinField::Directives: - MOZ_TRY_VAR(directives, parseDirectiveList()); - break; - case BinField::Body: - MOZ_TRY_VAR(body, parseBlockStatement()); - break; - case BinField::Key: - if (!isMethod(kind)) - return raiseInvalidField("Functions (unless defined as methods)", field); - - MOZ_TRY_VAR(key, parseObjectPropertyName()); - break; - default: - return raiseInvalidField("Function", field); - } - } - - // Inject default values for absent fields. - if (!params) - TRY_VAR(params, new_(PNK_PARAMSBODY, tokenizer_->pos())); - - if (!body) - TRY_VAR(body, factory_.newStatementList(tokenizer_->pos())); - - if (kind == BinKind::FunctionDeclaration && !id) { - // The name is compulsory only for function declarations. - return raiseMissingField("FunctionDeclaration", BinField::Id); - } - - // Reject if required values are missing. - if (isMethod(kind) && !key) - return raiseMissingField("method", BinField::Key); - - if (id) - fun->initAtom(id->pn_atom); - - MOZ_ASSERT(params->isArity(PN_LIST)); - - if (!(body->isKind(PNK_LEXICALSCOPE) && body->pn_u.scope.body->isKind(PNK_STATEMENTLIST))) { - // Promote to lexical scope + statement list. - if (!body->isKind(PNK_STATEMENTLIST)) { - TRY_DECL(list, factory_.newStatementList(tokenizer_->pos(start))); - - list->initList(body); - body = list; - } - - // Promote to lexical scope. - TRY_VAR(body, factory_.newLexicalScope(nullptr, body)); - } - MOZ_ASSERT(body->isKind(PNK_LEXICALSCOPE)); - - MOZ_TRY_VAR(body, appendDirectivesToBody(body, directives)); - - params->appendWithoutOrderAssumption(body); - - TokenPos pos = tokenizer_->pos(start); - TRY_DECL(function, kind == BinKind::FunctionDeclaration - ? factory_.newFunctionStatement(pos) - : factory_.newFunctionExpression(pos)); - - factory_.setFunctionBox(function, funbox); - factory_.setFunctionFormalParametersAndBody(function, params); - - ParseNode* result; - if (kind == BinKind::ObjectMethod) - TRY_VAR(result, factory_.newObjectMethodOrPropertyDefinition(key, function, AccessorType::None)); - else if (kind == BinKind::ObjectGetter) - TRY_VAR(result, factory_.newObjectMethodOrPropertyDefinition(key, function, AccessorType::Getter)); - else if (kind == BinKind::ObjectSetter) - TRY_VAR(result, factory_.newObjectMethodOrPropertyDefinition(key, function, AccessorType::Setter)); - else - result = function; - - // Now handle bindings. - HandlePropertyName dotThis = cx_->names().dotThis; - const bool declareThis = hasUsedName(dotThis) || funbox->bindingsAccessedDynamically() || funbox->isDerivedClassConstructor(); - - if (declareThis) { - ParseContext::Scope& funScope = parseContext_->functionScope(); - ParseContext::Scope::AddDeclaredNamePtr p = funScope.lookupDeclaredNameForAdd(dotThis); - MOZ_ASSERT(!p); - TRY(funScope.addDeclaredName(parseContext_, p, dotThis, DeclarationKind::Var, - DeclaredNameInfo::npos)); - funbox->setHasThisBinding(); - } - - TRY_DECL(bindings, - NewFunctionScopeData(cx_, parseContext_->functionScope(), - /* hasParameterExprs = */false, alloc_, parseContext_)); - - funbox->functionScopeBindings().set(*bindings); - return result; -} - -JS::Result -BinASTParser::parseObjectPropertyName() -{ - auto start = tokenizer_->offset(); - - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - BinKind kind; - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - ParseNode* result; - switch (kind) { - case BinKind::StringLiteral: { - ParseNode* string; - MOZ_TRY_VAR(string, parseStringLiteralAux(kind, fields)); - uint32_t index; - if (string->pn_atom->isIndex(&index)) - TRY_VAR(result, factory_.newNumber(index, NoDecimal, TokenPos(start, tokenizer_->offset()))); - else - result = string; - - break; - } - case BinKind::NumericLiteral: - MOZ_TRY_VAR(result, parseNumericLiteralAux(kind, fields)); - break; - case BinKind::Identifier: - MOZ_TRY_VAR(result, parseIdentifierAux(kind, fields, /* expectObjectPropertyName = */ true)); - break; - case BinKind::ComputedPropertyName: { - ParseNode* expr; - MOZ_TRY_VAR(expr, parseExpressionAux(kind, fields)); - TRY_VAR(result, factory_.newComputedName(expr, start, tokenizer_->offset())); - break; - } - default: - return raiseInvalidKind("ObjectLiteralPropertyName", kind); - } - - TRY(guard.done()); - return result; -} - -JS::Result -BinASTParser::parseVariableDeclarationAux(const BinKind kind, const BinFields& fields) -{ - const size_t start = tokenizer_->offset(); - - ParseNode* result(nullptr); - switch (kind) { - default: - return raiseInvalidKind("VariableDeclaration", kind); - case BinKind::VariableDeclaration: - ParseNodeKind pnk = PNK_LIMIT; - - for (auto field : fields) { - switch (field) { - case BinField::Kind: { - Maybe kindName; - MOZ_TRY(readString(kindName)); - - if (*kindName == "let") - pnk = PNK_LET; - else if (*kindName == "var") - pnk = PNK_VAR; - else if (*kindName == "const") - pnk = PNK_CONST; - else - return raiseInvalidEnum("VariableDeclaration", *kindName); - - break; - } - case BinField::Declarations: { - uint32_t length; - AutoList guard(*tokenizer_); - - TRY(tokenizer_->enterList(length, guard)); - TRY_VAR(result, factory_.newDeclarationList(PNK_CONST /*Placeholder*/, tokenizer_->pos(start))); - - for (uint32_t i = 0; i < length; ++i) { - ParseNode* current; - MOZ_TRY_VAR(current, parseVariableDeclarator()); - MOZ_ASSERT(current); - - result->appendWithoutOrderAssumption(current); - } - - TRY(guard.done()); - break; - } - default: - return raiseInvalidField("VariableDeclaration", field); - } - } - - if (!result || pnk == PNK_LIMIT) - return raiseMissingField("VariableDeclaration", BinField::Declarations); - - result->setKind(pnk); - - MOZ_ASSERT(!result->isKind(PNK_NOP)); - } - - return result; -} - - -JS::Result -BinASTParser::parseExpressionStatementAux(const BinKind kind, const BinFields& fields) -{ - MOZ_ASSERT(kind == BinKind::ExpressionStatement); - - ParseNode* expr(nullptr); - for (auto field : fields) { - switch (field) { - case BinField::Expression: - MOZ_TRY_VAR(expr, parseExpression()); - - break; - default: - return raiseInvalidField("ExpressionStatement", field); - } - } - - if (!expr) - return raiseMissingField("ExpressionStatement", BinField::Expression); - - TRY_DECL(result, factory_.newExprStatement(expr, tokenizer_->offset())); - return result; -} - -JS::Result -BinASTParser::parseVariableDeclarator() -{ - const size_t start = tokenizer_->offset(); - - BinKind kind; - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - if (kind != BinKind::VariableDeclarator) - return raiseInvalidKind("VariableDeclarator", kind); - - ParseNode* id(nullptr); - ParseNode* init(nullptr); // Optional. - for (auto field : fields) { - switch (field) { - case BinField::Id: - MOZ_TRY_VAR(id, parsePattern()); - - break; - case BinField::Init: - MOZ_TRY_VAR(init, parseExpression()); - - break; - default: - return raiseInvalidField("VariableDeclarator", field); - } - } - - TRY(guard.done()); - if (!id) - return raiseMissingField("VariableDeclarator", BinField::Id); - - ParseNode* result(nullptr); - - // FIXME: Documentation in ParseNode is clearly obsolete. - if (id->isKind(PNK_NAME)) { - // `var foo [= bar]`` - TRY_VAR(result, factory_.newName(id->pn_atom->asPropertyName(), tokenizer_->pos(start), cx_)); - - if (init) - result->pn_expr = init; - - } else { - // `var pattern = bar` - if (!init) { - // Here, `init` is required. - return raiseMissingField("VariableDeclarator (with non-trivial pattern)", BinField::Init); - } - - TRY_VAR(result, factory_.newAssignment(PNK_ASSIGN, id, init)); - } - - return result; -} - -JS::Result -BinASTParser::parseExpressionList(bool acceptElisions) -{ - const size_t start = tokenizer_->offset(); - - uint32_t length; - AutoList guard(*tokenizer_); - - TRY(tokenizer_->enterList(length, guard)); - TRY_DECL(result, factory_.newArrayLiteral(start)); - - for (uint32_t i = 0; i < length; ++i) { - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - BinKind kind; - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - switch (kind) { - case BinKind::Elision: { - if (!acceptElisions) - return raiseInvalidKind("[Expression]", kind); - - MOZ_TRY(parseElisionAux(kind, fields)); - TRY(!factory_.addElision(result, tokenizer_->pos(start))); - break; - } - default: { - ParseNode* expr(nullptr); - MOZ_TRY_VAR(expr, parseExpressionAux(kind, fields)); - - MOZ_ASSERT(expr); - factory_.addArrayElement(result, expr); - } - } - - TRY(guard.done()); - } - - TRY(guard.done()); - return result; -} - -JS::Result -BinASTParser::parseElisionAux(const BinKind kind, const BinFields& fields) -{ - MOZ_ASSERT(kind == BinKind::Elision); - MOZ_TRY(checkEmptyTuple(kind, fields)); - - return Ok(); -} - -JS::Result -BinASTParser::parseSwitchCaseList() -{ - uint32_t length; - AutoList guard(*tokenizer_); - - TRY(tokenizer_->enterList(length, guard)); - TRY_DECL(list, factory_.newStatementList(tokenizer_->pos())); - - // Set to `true` once we have encountered a `default:` case. - // Two `default:` cases is an error. - bool haveDefault = false; - - for (uint32_t i = 0; i < length; ++i) { - ParseNode* caseNode(nullptr); - MOZ_TRY_VAR(caseNode, parseSwitchCase()); - MOZ_ASSERT(caseNode); - - if (caseNode->pn_left == nullptr) { - // Ah, seems that we have encountered a default case. - if (haveDefault) { - // Oh, wait, two defaults? That's an error. - return raiseError("This switch() has more than one `default:` case"); - } - haveDefault = true; - } - factory_.addCaseStatementToList(list, caseNode); - } - - TRY(guard.done()); - TRY_DECL(result, factory_.newLexicalScope(nullptr, list)); - - return result; -} - -JS::Result -BinASTParser::parseExpression() -{ - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - BinKind kind; - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - ParseNode* result(nullptr); - MOZ_TRY_VAR(result, parseExpressionAux(kind, fields)); - - TRY(guard.done()); - return result; -} - -JS::Result -BinASTParser::parseExpressionAux(const BinKind kind, const BinFields& fields) -{ - const size_t start = tokenizer_->offset(); - - ParseNode* result(nullptr); - - switch (kind) { - case BinKind::Identifier: { - MOZ_TRY_VAR(result, parseIdentifierAux(kind, fields)); - break; - } - case BinKind::BooleanLiteral: { - Maybe value; - for (auto field : fields) { - switch (field) { - case BinField::Value: - MOZ_TRY_EMPLACE(value, readBool()); - break; - default: - return raiseInvalidField("BooleanLiteral", field); - } - } - - // In case of absent optional fields, inject default values. - if (!value) - value.emplace(false); - - TRY_VAR(result, factory_.newBooleanLiteral(*value, tokenizer_->pos(start))); - - break; - } - case BinKind::NullLiteral: { - MOZ_TRY(checkEmptyTuple(kind, fields)); - TRY_VAR(result, factory_.newNullLiteral(tokenizer_->pos(start))); - break; - } - case BinKind::NumericLiteral: - MOZ_TRY_VAR(result, parseNumericLiteralAux(kind, fields)); - break; - - case BinKind::RegExpLiteral: { - RootedAtom pattern(cx_); - Maybe flags; - for (auto field : fields) { - switch (field) { - case BinField::Pattern: - MOZ_TRY(readString(&pattern)); - break; - case BinField::Flags: - MOZ_TRY(readString(flags)); - break; - default: - return raiseInvalidField("RegExpLiteral", field); - } - } - - if (!pattern) - return raiseMissingField("RegExpLiteral", BinField::Pattern); - if (!flags) - return raiseMissingField("RegExpLiteral", BinField::Flags); - - RegExpFlag reflags = NoFlags; - for (auto c : *flags) { - if (c == 'g' && !(reflags & GlobalFlag)) - reflags = RegExpFlag(reflags | GlobalFlag); - else if (c == 'i' && !(reflags & IgnoreCaseFlag)) - reflags = RegExpFlag(reflags | IgnoreCaseFlag); - else if (c == 'm' && !(reflags & MultilineFlag)) - reflags = RegExpFlag(reflags | MultilineFlag); - else if (c == 'y' && !(reflags & StickyFlag)) - reflags = RegExpFlag(reflags | StickyFlag); - else if (c == 'u' && !(reflags & UnicodeFlag)) - reflags = RegExpFlag(reflags | UnicodeFlag); - else - return raiseInvalidEnum("RegExpLiteral", *flags); - } - - - Rooted reobj(cx_); - TRY_VAR(reobj, RegExpObject::create(cx_, - pattern, - reflags, - alloc_, - TenuredObject)); - - TRY_VAR(result, factory_.newRegExp(reobj, tokenizer_->pos(start), *this)); - - break; - } - case BinKind::StringLiteral: - MOZ_TRY_VAR(result, parseStringLiteralAux(kind, fields)); - break; - - case BinKind::ThisExpression: { - MOZ_TRY(checkEmptyTuple(kind, fields)); - - if (parseContext_->isFunctionBox()) - parseContext_->functionBox()->usesThis = true; - - TokenPos pos = tokenizer_->pos(start); - ParseNode* thisName(nullptr); - if (parseContext_->sc()->thisBinding() == ThisBinding::Function) - TRY_VAR(thisName, factory_.newName(cx_->names().dotThis, pos, cx_)); - - TRY_VAR(result, factory_.newThisLiteral(pos, thisName)); - break; - } - case BinKind::ArrayExpression: - MOZ_TRY_VAR(result, parseArrayExpressionAux(kind, fields)); - break; - - case BinKind::ObjectExpression: - MOZ_TRY_VAR(result, parseObjectExpressionAux(kind, fields)); - break; - - case BinKind::FunctionExpression: - MOZ_TRY_VAR(result, parseFunctionAux(kind, fields)); - result->setOp(JSOP_LAMBDA); - break; - - case BinKind::UnaryExpression: - case BinKind::UpdateExpression: { - ParseNode* expr(nullptr); - Maybe operation; - Maybe prefix; // FIXME: Ignored for unary_expression? - - for (auto field : fields) { - switch (field) { - case BinField::Operator: - MOZ_TRY(readString(operation)); - break; - case BinField::Prefix: - MOZ_TRY_EMPLACE(prefix, readBool()); - break; - case BinField::Argument: - // arguments are always parsed *after* operator. - if (operation.isNothing()) - return raiseMissingField("UpdateExpression", BinField::Operator); - MOZ_TRY_VAR(expr, parseExpression()); - break; - default: - return raiseInvalidField("UpdateExpression", field); - } - } - - if (!expr) - return raiseMissingField("UpdateExpression", BinField::Argument); - if (operation.isNothing()) - return raiseMissingField("UpdateExpression", BinField::Operator); - - // In case of absent optional fields, inject default values. - if (prefix.isNothing()) - prefix.emplace(false); - - ParseNodeKind pnk = PNK_LIMIT; - if (kind == BinKind::UnaryExpression) { - if (*operation == "-") { - pnk = PNK_NEG; - } else if (*operation == "+") { - pnk = PNK_POS; - } else if (*operation == "!") { - pnk = PNK_NOT; - } else if (*operation == "~") { - pnk = PNK_BITNOT; - } else if (*operation == "typeof") { - if (expr->isKind(PNK_NAME)) - pnk = PNK_TYPEOFNAME; - else - pnk = PNK_TYPEOFEXPR; - } else if (*operation == "void") { - pnk = PNK_VOID; - } else if (*operation == "delete") { - switch (expr->getKind()) { - case PNK_NAME: - expr->setOp(JSOP_DELNAME); - pnk = PNK_DELETENAME; - break; - case PNK_DOT: - pnk = PNK_DELETEPROP; - break; - case PNK_ELEM: - pnk = PNK_DELETEELEM; - break; - default: - pnk = PNK_DELETEEXPR; - } - } else { - return raiseInvalidEnum("UnaryOperator", *operation); - } - } else if (kind == BinKind::UpdateExpression) { - if (!expr->isKind(PNK_NAME) && !factory_.isPropertyAccess(expr)) - return raiseError("Invalid increment/decrement operand"); // FIXME: Shouldn't this be part of the syntax? - - if (*operation == "++") { - if (*prefix) - pnk = PNK_PREINCREMENT; - else - pnk = PNK_POSTINCREMENT; - } else if (*operation == "--") { - if (*prefix) - pnk = PNK_PREDECREMENT; - else - pnk = PNK_POSTDECREMENT; - } else { - return raiseInvalidEnum("UpdateOperator", *operation); - } - } - - TRY_VAR(result, factory_.newUnary(pnk, start, expr)); - - break; - } - case BinKind::BinaryExpression: - case BinKind::LogicalExpression: { - ParseNode* left(nullptr); - ParseNode* right(nullptr); - Maybe operation; - for (auto field : fields) { - switch (field) { - case BinField::Left: - MOZ_TRY_VAR(left, parseExpression()); - break; - case BinField::Right: - MOZ_TRY_VAR(right, parseExpression()); - break; - case BinField::Operator: - MOZ_TRY(readString(operation)); - break; - default: - return raiseInvalidField("LogicalExpression | BinaryExpression", field); - } - } - - if (!left) - return raiseMissingField("LogicalExpression | BinaryExpression", BinField::Left); - if (!right) - return raiseMissingField("LogicalExpression | BinaryExpression", BinField::Right); - if (operation.isNothing()) - return raiseMissingField("LogicalExpression | BinaryExpression", BinField::Operator); - - // FIXME: Instead of Chars, we should use atoms and comparison - // between atom ptr. - ParseNodeKind pnk = PNK_LIMIT; - if (*operation == "==") - pnk = PNK_EQ; - else if (*operation == "!=") - pnk = PNK_NE; - else if (*operation == "===") - pnk = PNK_STRICTEQ; - else if (*operation == "!==") - pnk = PNK_STRICTNE; - else if (*operation == "<") - pnk = PNK_LT; - else if (*operation == "<=") - pnk = PNK_LE; - else if (*operation == ">") - pnk = PNK_GT; - else if (*operation == ">=") - pnk = PNK_GE; - else if (*operation == "<<") - pnk = PNK_LSH; - else if (*operation == ">>") - pnk = PNK_RSH; - else if (*operation == ">>>") - pnk = PNK_URSH; - else if (*operation == "+") - pnk = PNK_ADD; - else if (*operation == "-") - pnk = PNK_SUB; - else if (*operation == "*") - pnk = PNK_STAR; - else if (*operation == "/") - pnk = PNK_DIV; - else if (*operation == "%") - pnk = PNK_MOD; - else if (*operation == "|") - pnk = PNK_BITOR; - else if (*operation == "^") - pnk = PNK_BITXOR; - else if (*operation == "&") - pnk = PNK_BITAND; - else if (*operation == "in") - pnk = PNK_IN; - else if (*operation == "instanceof") - pnk = PNK_INSTANCEOF; - else if (*operation == "||") - pnk = PNK_OR; - else if (*operation == "&&") - pnk = PNK_AND; - else if (*operation == "**") - pnk = PNK_POW; - else - return raiseInvalidEnum("BinaryOperator | LogicalOperator", *operation); - - if (left->isKind(pnk) && pnk != PNK_POW /* PNK_POW is not left-associative */) { - // Regroup left-associative operations into lists. - left->appendWithoutOrderAssumption(right); - result = left; - } else { - TRY_DECL(list, factory_.newList(pnk, tokenizer_->pos(start))); - - list->appendWithoutOrderAssumption(left); - list->appendWithoutOrderAssumption(right); - result = list; - } - - break; - } - case BinKind::AssignmentExpression: { - ParseNode* left(nullptr); - ParseNode* right(nullptr); - Maybe operation; - for (auto field : fields) { - switch (field) { - case BinField::Left: - MOZ_TRY_VAR(left, parseExpression()); - break; - case BinField::Right: - MOZ_TRY_VAR(right, parseExpression()); - break; - case BinField::Operator: - MOZ_TRY(readString(operation)); - break; - default: - return raiseInvalidField("AssignmentExpression", field); - } - } - - if (!left) - return raiseMissingField("AssignmentExpression", BinField::Left); - if (!right) - return raiseMissingField("AssignmentExpression", BinField::Right); - if (operation.isNothing()) - return raiseMissingField("AssignmentExpression", BinField::Operator); - - // FIXME: Instead of Chars, we should use atoms and comparison - // between atom ptr. - // FIXME: We should probably turn associative operations into lists. - ParseNodeKind pnk = PNK_LIMIT; - if (*operation == "=") - pnk = PNK_ASSIGN; - else if (*operation == "+=") - pnk = PNK_ADDASSIGN; - else if (*operation == "-=") - pnk = PNK_SUBASSIGN; - else if (*operation == "*=") - pnk = PNK_MULASSIGN; - else if (*operation == "/=") - pnk = PNK_DIVASSIGN; - else if (*operation == "%=") - pnk = PNK_MODASSIGN; - else if (*operation == "<<=") - pnk = PNK_LSHASSIGN; - else if (*operation == ">>=") - pnk = PNK_RSHASSIGN; - else if (*operation == ">>>=") - pnk = PNK_URSHASSIGN; - else if (*operation == "|=") - pnk = PNK_BITORASSIGN; - else if (*operation == "^=") - pnk = PNK_BITXORASSIGN; - else if (*operation == "&=") - pnk = PNK_BITANDASSIGN; - else - return raiseInvalidEnum("AssignmentOperator", *operation); - - TRY_VAR(result, factory_.newAssignment(pnk, left, right)); - - break; - } - case BinKind::BracketExpression: - case BinKind::DotExpression: - MOZ_TRY_VAR(result, parseMemberExpressionAux(kind, fields)); - - break; - case BinKind::ConditionalExpression: { - ParseNode* test(nullptr); - ParseNode* alternate(nullptr); - ParseNode* consequent(nullptr); - - for (auto field : fields) { - switch (field) { - case BinField::Test: - MOZ_TRY_VAR(test, parseExpression()); - break; - case BinField::Consequent: - MOZ_TRY_VAR(consequent, parseExpression()); - break; - case BinField::Alternate: - MOZ_TRY_VAR(alternate, parseExpression()); - break; - default: - return raiseInvalidField("ConditionalExpression", field); - } - } - - if (!test) - return raiseMissingField("ConditionalExpression", BinField::Test); - if (!consequent) - return raiseMissingField("ConditionalExpression", BinField::Consequent); - if (!alternate) - return raiseMissingField("ConditionalExpression", BinField::Alternate); - - TRY_VAR(result, factory_.newConditional(test, consequent, alternate)); - - break; - } - case BinKind::CallExpression: - case BinKind::NewExpression: { - ParseNode* callee(nullptr); - - for (auto field : fields) { - switch (field) { - case BinField::Callee: - MOZ_TRY_VAR(callee, parseExpression()); - break; - case BinField::Arguments: - MOZ_TRY_VAR(result, parseExpressionList(/* acceptElisions = */ false)); - break; - default: - return raiseInvalidField("NewExpression", field); - } - } - - // In case of absent required fields, fail. - if (!callee) - return raiseMissingField("NewExpression", BinField::Callee); - - // In case of absent optional fields, inject default values. - if (!result) - TRY_VAR(result, factory_.newArrayLiteral(start)); - - ParseNodeKind pnk = - kind == BinKind::CallExpression - ? PNK_CALL - : PNK_NEW; - result->setKind(pnk); - result->prepend(callee); - - break; - } - case BinKind::SequenceExpression: { - for (auto field : fields) { - switch (field) { - case BinField::Expressions: - MOZ_TRY_VAR(result, parseExpressionList(/* acceptElisions = */ false)); - break; - default: - return raiseInvalidField("SequenceExpression", field); - } - } - - if (!result) - return raiseMissingField("SequenceExpression", BinField::Expression); - - result->setKind(PNK_COMMA); - break; - } - default: - return raiseInvalidKind("Expression", kind); - } - - return result; -} - -JS::Result -BinASTParser::parseNumericLiteralAux(const BinKind kind, const BinFields& fields) -{ - auto start = tokenizer_->offset(); - - Maybe value; - for (auto field : fields) { - switch (field) { - case BinField::Value: - MOZ_TRY_EMPLACE(value, readNumber()); - break; - default: - return raiseInvalidField("NumericLiteral", field); - } - } - - // In case of absent optional fields, inject default values. - if (!value) - value.emplace(0); - - TRY_DECL(result, factory_.newNumber(*value, DecimalPoint::HasDecimal, tokenizer_->pos(start))); - return result; -} - -JS::Result -BinASTParser::parseStringLiteralAux(const BinKind kind, const BinFields& fields) -{ - auto start = tokenizer_->offset(); - - RootedAtom value(cx_); - for (auto field : fields) { - switch (field) { - case BinField::Value: - MOZ_TRY(readString(&value)); - break; - default: - return raiseInvalidField("StringLiteral", field); - } - } - - if (!value) - return raiseMissingField("StringLiteral", BinField::Value); - - TRY_DECL(result, factory_.newStringLiteral(value, tokenizer_->pos(start))); - return result; -} - -JS::Result -BinASTParser::parseArrayExpressionAux(const BinKind kind, const BinFields& fields) -{ - MOZ_ASSERT(kind == BinKind::ArrayExpression); - - ParseNode* result(nullptr); - for (auto field : fields) { - switch (field) { - case BinField::Elements: { - MOZ_TRY_VAR(result, parseExpressionList(/* acceptElisions = */ true)); - break; - } - default: - return raiseInvalidField("ArrayExpression", field); - } - } - - // Inject default values for absent fields. - if (!result) - TRY_VAR(result, factory_.newArrayLiteral(tokenizer_->offset())); - - MOZ_ASSERT(result->isKind(PNK_ARRAY)); - return result; -} - -JS::Result -BinASTParser::parseObjectExpressionAux(const BinKind kind, const BinFields& fields) -{ - MOZ_ASSERT(kind == BinKind::ObjectExpression); - - ParseNode* result(nullptr); - for (auto field : fields) { - switch (field) { - case BinField::Properties: { - MOZ_TRY_VAR(result, parseObjectMemberList()); - break; - } - default: - return raiseInvalidField("Property | Method", field); - } - } - - if (!result) - TRY_VAR(result, factory_.newObjectLiteral(tokenizer_->offset())); - - MOZ_ASSERT(result->isArity(PN_LIST)); - MOZ_ASSERT(result->isKind(PNK_OBJECT)); - -#if defined(DEBUG) - // Sanity check. - for (ParseNode* iter = result->pn_head; iter != nullptr; iter = iter->pn_next) { - MOZ_ASSERT(iter->isKind(PNK_COLON)); - MOZ_ASSERT(iter->pn_left != nullptr); - MOZ_ASSERT(iter->pn_right != nullptr); - } -#endif // defined(DEBUG) - - return result; -} - -JS::Result -BinASTParser::parseMemberExpressionAux(const BinKind kind, const BinFields& fields) -{ - MOZ_ASSERT(kind == BinKind::DotExpression || kind == BinKind::BracketExpression); - - ParseNode* object(nullptr); - ParseNode* property(nullptr); - - for (auto field : fields) { - switch (field) { - case BinField::Object: - MOZ_TRY_VAR(object, parseExpression()); - break; - case BinField::Property: - if (kind == BinKind::BracketExpression) - MOZ_TRY_VAR(property, parseExpression()); - else - MOZ_TRY_VAR(property, parseIdentifier()); - break; - default: - return raiseInvalidField("MemberExpression", field); - } - } - - // In case of absent required fields, fail. - if (!object) - return raiseMissingField("MemberExpression", BinField::Object); - if (!property) - return raiseMissingField("MemberExpression", BinField::Property); - - ParseNode* result(nullptr); - if (kind == BinKind::DotExpression) { - MOZ_ASSERT(property->isKind(PNK_NAME)); - PropertyName* name = property->pn_atom->asPropertyName(); - TRY_VAR(result, factory_.newPropertyAccess(object, name, tokenizer_->offset())); - } else { - TRY_VAR(result, factory_.newPropertyByValue(object, property, tokenizer_->offset())); - } - - return result; -} - -JS::Result -BinASTParser::parseDirectiveList() -{ - uint32_t length; - AutoList guard(*tokenizer_); - TRY(tokenizer_->enterList(length, guard)); - - TokenPos pos = tokenizer_->pos(); - TRY_DECL(result, factory_.newStatementList(pos)); - - RootedAtom value(cx_); - for (uint32_t i = 0; i < length; ++i) { - value = nullptr; - MOZ_TRY(readString(&value)); - - TRY_DECL(directive, factory_.newStringLiteral(value, pos)); - factory_.addStatementToList(result, directive); - } - - TRY(guard.done()); - return result; -} - -JS::Result -BinASTParser::parseSwitchCase() -{ - const size_t start = tokenizer_->offset(); - - BinKind kind; - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - if (kind != BinKind::SwitchCase) - return raiseInvalidKind("SwitchCase", kind); - - ParseNode* test(nullptr); // Optional. - ParseNode* statements(nullptr); // Required. - - for (auto field : fields) { - switch (field) { - case BinField::Test: - MOZ_TRY_VAR(test, parseExpression()); - break; - case BinField::Consequent: - MOZ_TRY_VAR(statements, parseStatementList()); - break; - default: - return raiseInvalidField("SwitchCase", field); - } - } - - TRY(guard.done()); - if (!statements) - return raiseMissingField("SwitchCase", BinField::Consequent); - - MOZ_ASSERT(statements->isKind(PNK_STATEMENTLIST)); - - TRY_DECL(result, factory_.newCaseOrDefault(start, test, statements)); - - return result; -} - -JS::Result -BinASTParser::parseCatchClause() -{ - ParseContext::Statement stmt(parseContext_, StatementKind::Catch); - ParseContext::Scope scope(cx_, parseContext_, usedNames_); - TRY(scope.init(parseContext_)); - - BinKind kind; - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - ParseNode* result(nullptr); - - switch (kind) { - default: - return raiseInvalidKind("CatchClause", kind); - case BinKind::CatchClause: { - ParseNode* param(nullptr); - ParseNode* body(nullptr); - - for (auto field : fields) { - switch (field) { - case BinField::Param: - MOZ_TRY_VAR(param, parsePattern()); - break; - case BinField::Body: - MOZ_TRY_VAR(body, parseBlockStatement()); - break; - case BinField::BINJS_Scope: - MOZ_TRY(parseAndUpdateCurrentScope()); - break; - default: - return raiseInvalidField("CatchClause", field); - } - } - - if (!param) - return raiseMissingField("CatchClause", BinField::Param); - if (!body) - return raiseMissingField("CatchClause", BinField::Body); - - TRY_DECL(bindings, NewLexicalScopeData(cx_, scope, alloc_, parseContext_)); - TRY_VAR(result, factory_.newLexicalScope(*bindings, body)); - TRY(factory_.setupCatchScope(result, param, body)); - } - } - - TRY(guard.done()); - return result; -} - -JS::Result -BinASTParser::parseArgumentList() -{ - uint32_t length; - AutoList guard(*tokenizer_); - - TRY(tokenizer_->enterList(length, guard)); - ParseNode* result = new_(PNK_PARAMSBODY, tokenizer_->pos()); - - for (uint32_t i = 0; i < length; ++i) { - ParseNode* pattern; - MOZ_TRY_VAR(pattern, parsePattern()); - - result->appendWithoutOrderAssumption(pattern); - } - - TRY(guard.done()); - return result; -} - -JS::Result -BinASTParser::parseIdentifier() -{ - BinKind kind; - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - ParseNode* result; - MOZ_TRY_VAR(result, parseIdentifierAux(kind, fields)); - - TRY(guard.done()); - return result; -} - -JS::Result -BinASTParser::parseIdentifierAux(const BinKind, const BinFields& fields, const bool expectObjectPropertyName /* = false */) -{ - const size_t start = tokenizer_->offset(); - - RootedAtom id(cx_); - for (auto field : fields) { - switch (field) { - case BinField::Name: - MOZ_TRY(readString(&id)); - break; - default: - return raiseInvalidField("Identifier", field); - } - } - - if (!id) - return raiseMissingField("Identifier", BinField::Name); - - if (!IsIdentifier(id)) - return raiseError("Invalid identifier"); - if (!expectObjectPropertyName && IsKeyword(id)) - return raiseError("Invalid identifier (keyword)"); - - // Once `IsIdentifier` has returned true, we may call `asPropertyName()` without fear. - TokenPos pos = tokenizer_->pos(start); - - ParseNode* result; - if (expectObjectPropertyName) - TRY_VAR(result, factory_.newObjectLiteralPropertyName(id->asPropertyName(), pos)); - else - TRY_VAR(result, factory_.newName(id->asPropertyName(), pos, cx_)); - - return result; -} - - -JS::Result -BinASTParser::parsePattern() -{ - BinKind kind; - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - ParseNode* result; - MOZ_TRY_VAR(result, parsePatternAux(kind, fields)); - - TRY(guard.done()); - return result; -} - -JS::Result -BinASTParser::parsePatternAux(const BinKind kind, const BinFields& fields) -{ - ParseNode* result; - switch (kind) { - case BinKind::Identifier: - MOZ_TRY_VAR(result, parseIdentifierAux(kind ,fields)); - break; - default: - return raiseInvalidKind("Pattern", kind); - } - - return result; -} - -JS::Result -BinASTParser::parseObjectMember() -{ - BinKind kind; - BinFields fields(cx_); - AutoTaggedTuple guard(*tokenizer_); - - TRY(tokenizer_->enterTaggedTuple(kind, fields, guard)); - ParseNode* result(nullptr); - - switch (kind) { - case BinKind::ObjectProperty: { - ParseNode* key(nullptr); - ParseNode* value(nullptr); - for (auto field : fields) { - switch (field) { - case BinField::Key: - MOZ_TRY_VAR(key, parseObjectPropertyName()); - break; - case BinField::Value: - MOZ_TRY_VAR(value, parseExpression()); - break; - default: - return raiseInvalidField("ObjectMember", field); - } - } - - if (!key) - return raiseMissingField("ObjectMember", BinField::Key); - if (!value) - return raiseMissingField("ObjectMember", BinField::Value); - - if (!factory_.isUsableAsObjectPropertyName(key)) - return raiseError("ObjectMember key kind"); - - TRY_VAR(result, factory_.newObjectMethodOrPropertyDefinition(key, value, AccessorType::None)); - - break; - } - case BinKind::ObjectMethod: - case BinKind::ObjectGetter: - case BinKind::ObjectSetter: - MOZ_TRY_VAR(result, parseFunctionAux(kind, fields)); - - if (!result) - return raiseEmpty("ObjectMethod"); - - MOZ_ASSERT(result->isKind(PNK_COLON)); - break; - default: - return raiseInvalidKind("ObjectMember", kind); - } - - TRY(guard.done()); - MOZ_ASSERT(result); - return result; -} - -JS::Result -BinASTParser::parseObjectMemberList() -{ - uint32_t length; - AutoList guard(*tokenizer_); - - auto start = tokenizer_->offset(); - TRY(tokenizer_->enterList(length, guard)); - - TRY_DECL(result, factory_.newObjectLiteral(start)); - - for (uint32_t i = 0; i < length; ++i) { - ParseNode* keyValue; - MOZ_TRY_VAR(keyValue, parseObjectMember()); - MOZ_ASSERT(keyValue); - - result->appendWithoutOrderAssumption(keyValue); - } - - TRY(guard.done()); - return result; -} - - -JS::Result -BinASTParser::checkEmptyTuple(const BinKind kind, const BinFields& fields) -{ - if (fields.length() != 0) - return raiseInvalidField(describeBinKind(kind), fields[0]); - - return Ok(); -} - - -JS::Result -BinASTParser::readString(MutableHandleAtom out) -{ - MOZ_ASSERT(!out); - - Maybe string; - MOZ_TRY(readString(string)); - MOZ_ASSERT(string); - - RootedAtom atom(cx_); - TRY_VAR(atom, Atomize(cx_, (const char*)string->begin(), string->length())); - - out.set(Move(atom)); - return Ok(); -} - -JS::Result -BinASTParser::parsePropertyName() -{ - RootedAtom atom(cx_); - MOZ_TRY(readString(&atom)); - - TokenPos pos = tokenizer_->pos(); - - ParseNode* result; - - // If the atom matches an index (e.g. "3"), we need to normalize the - // propertyName to ensure that it has the same representation as - // the numeric index (e.g. 3). - uint32_t index; - if (atom->isIndex(&index)) - TRY_VAR(result, factory_.newNumber(index, NoDecimal, pos)); - else - TRY_VAR(result, factory_.newStringLiteral(atom, pos)); - - return result; -} - -JS::Result -BinASTParser::readString(Maybe& out) -{ - MOZ_ASSERT(out.isNothing()); - Chars result(cx_); - TRY(tokenizer_->readChars(result)); - - out.emplace(Move(result)); - return Ok(); -} - -JS::Result -BinASTParser::readNumber() -{ - double result; - TRY(tokenizer_->readDouble(result)); - - return result; -} - -JS::Result -BinASTParser::readBool() -{ - bool result; - TRY(tokenizer_->readBool(result)); - - return result; -} - -mozilla::GenericErrorResult -BinASTParser::raiseInvalidKind(const char* superKind, const BinKind kind) -{ - Sprinter out(cx_); - TRY(out.init()); - TRY(out.printf("In %s, invalid kind %s", superKind, describeBinKind(kind))); - return raiseError(out.string()); -} - -mozilla::GenericErrorResult -BinASTParser::raiseInvalidField(const char* kind, const BinField field) -{ - Sprinter out(cx_); - TRY(out.init()); - TRY(out.printf("In %s, invalid field '%s'", kind, describeBinField(field))); - return raiseError(out.string()); -} - -mozilla::GenericErrorResult -BinASTParser::raiseInvalidEnum(const char* kind, const Chars& value) -{ - // We don't trust the actual chars of `value` to be properly formatted anything, so let's not use - // them anywhere. - return raiseError("Invalid enum"); -} - -mozilla::GenericErrorResult -BinASTParser::raiseMissingField(const char* kind, const BinField field) -{ - Sprinter out(cx_); - TRY(out.init()); - TRY(out.printf("In %s, missing field '%s'", kind, describeBinField(field))); - - return raiseError(out.string()); -} - -mozilla::GenericErrorResult -BinASTParser::raiseEmpty(const char* description) -{ - Sprinter out(cx_); - TRY(out.init()); - TRY(out.printf("Empty %s", description)); - - return raiseError(out.string()); -} - -mozilla::GenericErrorResult -BinASTParser::raiseOOM() -{ - ReportOutOfMemory(cx_); - return cx_->alreadyReportedError(); -} - -mozilla::GenericErrorResult -BinASTParser::raiseError(BinKind kind, const char* description) -{ - Sprinter out(cx_); - TRY(out.init()); - TRY(out.printf("In %s, ", description)); - MOZ_ALWAYS_FALSE(tokenizer_->raiseError(out.string())); - - return cx_->alreadyReportedError(); -} - -mozilla::GenericErrorResult -BinASTParser::raiseError(const char* description) -{ - MOZ_ALWAYS_FALSE(tokenizer_->raiseError(description)); - return cx_->alreadyReportedError(); -} - -void -BinASTParser::poison() -{ - tokenizer_.reset(); -} - -void -BinASTParser::reportErrorNoOffsetVA(unsigned errorNumber, va_list args) -{ - ErrorMetadata metadata; - metadata.filename = getFilename(); - metadata.lineNumber = 0; - metadata.columnNumber = offset(); - ReportCompileError(cx_, Move(metadata), nullptr, JSREPORT_ERROR, errorNumber, args); -} - -bool -BinASTParser::hasUsedName(HandlePropertyName name) -{ - if (UsedNamePtr p = usedNames_.lookup(name)) - return p->value().isUsedInScript(parseContext_->scriptId()); - - return false; -} - -void -TraceBinParser(JSTracer* trc, AutoGCRooter* parser) -{ - static_cast(parser)->trace(trc); -} - -} // namespace frontend -} // namespace js - - -// #undef everything, to avoid collisions with unified builds. - -#undef TRY -#undef TRY_VAR -#undef TRY_DECL -#undef TRY_EMPL -#undef MOZ_TRY_EMPLACE diff --git a/js/src/frontend/BinSource.h b/js/src/frontend/BinSource.h deleted file mode 100644 index 2995eb895e2c..000000000000 --- a/js/src/frontend/BinSource.h +++ /dev/null @@ -1,278 +0,0 @@ -#ifndef frontend_BinSource_h -#define frontend_BinSource_h - -/** - * A Binary AST parser. - * - * At the time of this writing, this parser implements the grammar of ES5 - * and trusts its input (in particular, variable declarations). - */ - -#include "mozilla/Maybe.h" - -#include "frontend/BinTokenReaderTester.h" -#include "frontend/FullParseHandler.h" -#include "frontend/ParseContext.h" -#include "frontend/ParseNode.h" -#include "frontend/SharedContext.h" - -#include "js/GCHashTable.h" -#include "js/GCVector.h" -#include "js/Result.h" - -namespace js { -namespace frontend { - -class BinASTParser; - -/** - * The parser for a Binary AST. - * - * By design, this parser never needs to backtrack or look ahead. Errors are not - * recoverable. - */ -class BinASTParser : private JS::AutoGCRooter, public ErrorReporter -{ - using Names = JS::GCVector; - using Tokenizer = BinTokenReaderTester; - using Chars = Tokenizer::Chars; - - public: - BinASTParser(JSContext* cx, LifoAlloc& alloc, UsedNameTracker& usedNames, const JS::ReadOnlyCompileOptions& options) - : AutoGCRooter(cx, BINPARSER) - , traceListHead_(nullptr) - , options_(options) - , cx_(cx) - , alloc_(alloc) - , nodeAlloc_(cx, alloc) - , keepAtoms_(cx) - , parseContext_(nullptr) - , usedNames_(usedNames) - , factory_(cx, alloc, nullptr, SourceKind::Binary) - { - cx_->frontendCollectionPool().addActiveCompilation(); - tempPoolMark_ = alloc.mark(); - } - ~BinASTParser() - { - alloc_.release(tempPoolMark_); - - /* - * The parser can allocate enormous amounts of memory for large functions. - * Eagerly free the memory now (which otherwise won't be freed until the - * next GC) to avoid unnecessary OOMs. - */ - alloc_.freeAllIfHugeAndUnused(); - - cx_->frontendCollectionPool().removeActiveCompilation(); - } - - /** - * Parse a buffer, returning a node (which may be nullptr) in case of success - * or Nothing() in case of error. - * - * The instance of `ParseNode` MAY NOT survive the `BinASTParser`. Indeed, - * destruction of the `BinASTParser` will also destroy the `ParseNode`. - * - * In case of error, the parser reports the JS error. - */ - JS::Result parse(const uint8_t* start, const size_t length); - JS::Result parse(const Vector& data); - - private: - MOZ_MUST_USE JS::Result parseAux(const uint8_t* start, const size_t length); - - // --- Raise errors. - // - // These methods return a (failed) JS::Result for convenience. - - MOZ_MUST_USE mozilla::GenericErrorResult raiseInvalidKind(const char* superKind, const BinKind kind); - MOZ_MUST_USE mozilla::GenericErrorResult raiseInvalidField(const char* kind, const BinField field); - MOZ_MUST_USE mozilla::GenericErrorResult raiseInvalidEnum(const char* kind, const Chars& value); - MOZ_MUST_USE mozilla::GenericErrorResult raiseMissingField(const char* kind, const BinField field); - MOZ_MUST_USE mozilla::GenericErrorResult raiseEmpty(const char* description); - MOZ_MUST_USE mozilla::GenericErrorResult raiseOOM(); - MOZ_MUST_USE mozilla::GenericErrorResult raiseError(const char* description); - MOZ_MUST_USE mozilla::GenericErrorResult raiseError(BinKind kind, const char* description); - - // Ensure that this parser will never be used again. - void poison(); - - // --- Parse full nodes (methods are sorted by alphabetical order) - // - // These method may NEVER return `nullptr`. // FIXME: We can probably optimize Result<> based on this. - - MOZ_MUST_USE JS::Result parseBlockStatement(); - MOZ_MUST_USE JS::Result parseCatchClause(); - MOZ_MUST_USE JS::Result parseExpression(); - MOZ_MUST_USE JS::Result parseForInit(); - MOZ_MUST_USE JS::Result parseForInInit(); - MOZ_MUST_USE JS::Result parseIdentifier(); - MOZ_MUST_USE JS::Result parseObjectPropertyName(); - MOZ_MUST_USE JS::Result parseObjectMember(); - MOZ_MUST_USE JS::Result parsePattern(); // Parse a *binding* pattern. - MOZ_MUST_USE JS::Result parsePropertyName(); - MOZ_MUST_USE JS::Result parseProgram(); - MOZ_MUST_USE JS::Result parseStatement(); - MOZ_MUST_USE JS::Result parseSwitchCase(); - MOZ_MUST_USE JS::Result parseVariableDeclarator(); - - - // --- Parse lists of nodes (methods are sorted by alphabetical order) - - MOZ_MUST_USE JS::Result parseArgumentList(); - MOZ_MUST_USE JS::Result parseDirectiveList(); - MOZ_MUST_USE JS::Result parseExpressionList(bool acceptElisions); - - // Returns a list of PNK_COLON. - MOZ_MUST_USE JS::Result parseObjectMemberList(); - - MOZ_MUST_USE JS::Result parseStatementList(); - MOZ_MUST_USE JS::Result parseSwitchCaseList(); - - // --- Parse the contents of a node whose kind has already been determined. - - MOZ_MUST_USE JS::Result parseArrayExpressionAux(const BinKind kind, const Tokenizer::BinFields& fields); - MOZ_MUST_USE JS::Result parseBreakOrContinueStatementAux(const BinKind kind, const Tokenizer::BinFields& fields); - MOZ_MUST_USE JS::Result parseBlockStatementAux(const BinKind kind, const Tokenizer::BinFields& fields); - MOZ_MUST_USE JS::Result parseExpressionStatementAux(const BinKind kind, const Tokenizer::BinFields& fields); - MOZ_MUST_USE JS::Result parseExpressionAux(const BinKind kind, const Tokenizer::BinFields& fields); - MOZ_MUST_USE JS::Result parseFunctionAux(const BinKind kind, const Tokenizer::BinFields& fields); - MOZ_MUST_USE JS::Result parseIdentifierAux(const BinKind, const Tokenizer::BinFields& fields, const bool expectObjectPropertyName = false); - MOZ_MUST_USE JS::Result parseMemberExpressionAux(const BinKind kind, const Tokenizer::BinFields& fields); - MOZ_MUST_USE JS::Result parseNumericLiteralAux(const BinKind kind, const Tokenizer::BinFields& fields); - MOZ_MUST_USE JS::Result parseObjectExpressionAux(const BinKind kind, const Tokenizer::BinFields& fields); - MOZ_MUST_USE JS::Result parsePatternAux(const BinKind kind, const Tokenizer::BinFields& fields); - MOZ_MUST_USE JS::Result parseStringLiteralAux(const BinKind kind, const Tokenizer::BinFields& fields); - MOZ_MUST_USE JS::Result parseStatementAux(const BinKind kind, const Tokenizer::BinFields& fields); - MOZ_MUST_USE JS::Result parseVariableDeclarationAux(const BinKind kind, const Tokenizer::BinFields& fields); - - // --- Auxiliary parsing functions that may have a side-effect on the parser but do not return a node. - - MOZ_MUST_USE JS::Result checkEmptyTuple(const BinKind kind, const Tokenizer::BinFields& fields); - MOZ_MUST_USE JS::Result parseElisionAux(const BinKind kind, const Tokenizer::BinFields& fields); - - // Parse full scope information to the current innermost scope. - MOZ_MUST_USE JS::Result parseAndUpdateCurrentScope(); - // Parse full scope information to a specific var scope / let scope combination. - MOZ_MUST_USE JS::Result parseAndUpdateScope(ParseContext::Scope& varScope, ParseContext::Scope& letScope); - // Parse a list of names and add it to a given scope. - MOZ_MUST_USE JS::Result parseAndUpdateScopeNames(ParseContext::Scope& scope, DeclarationKind kind); - MOZ_MUST_USE JS::Result parseStringList(MutableHandle> out); - - // --- Utilities. - - MOZ_MUST_USE JS::Result appendDirectivesToBody(ParseNode* body, ParseNode* directives); - - // Read a string as a `Chars`. - MOZ_MUST_USE JS::Result readString(Maybe& out); - MOZ_MUST_USE JS::Result readString(MutableHandleAtom out); - MOZ_MUST_USE JS::Result readBool(); - MOZ_MUST_USE JS::Result readNumber(); - - const ReadOnlyCompileOptions& options() const override { - return this->options_; - } - - // Names - - - bool hasUsedName(HandlePropertyName name); - - // --- GC. - - void trace(JSTracer* trc) { - ObjectBox::TraceList(trc, traceListHead_); - } - - - public: - ObjectBox* newObjectBox(JSObject* obj) { - MOZ_ASSERT(obj); - - /* - * We use JSContext.tempLifoAlloc to allocate parsed objects and place them - * on a list in this Parser to ensure GC safety. Thus the tempLifoAlloc - * arenas containing the entries must be alive until we are done with - * scanning, parsing and code generation for the whole script or top-level - * function. - */ - - ObjectBox* objbox = alloc_.new_(obj, traceListHead_); - if (!objbox) { - ReportOutOfMemory(cx_); - return nullptr; - } - - traceListHead_ = objbox; - - return objbox; - } - - ParseNode* allocParseNode(size_t size) { - MOZ_ASSERT(size == sizeof(ParseNode)); - return static_cast(nodeAlloc_.allocNode()); - } - - JS_DECLARE_NEW_METHODS(new_, allocParseNode, inline) - - private: // Implement ErrorReporter - - virtual void lineAndColumnAt(size_t offset, uint32_t* line, uint32_t* column) const override { - *line = 0; - *column = offset; - } - virtual void currentLineAndColumn(uint32_t* line, uint32_t* column) const override { - *line = 0; - *column = offset(); - } - size_t offset() const { - if (tokenizer_.isSome()) - return tokenizer_->offset(); - - return 0; - } - virtual bool hasTokenizationStarted() const override { - return tokenizer_.isSome(); - } - virtual void reportErrorNoOffsetVA(unsigned errorNumber, va_list args) override; - virtual const char* getFilename() const override { - return this->options_.filename(); - } - - ObjectBox* traceListHead_; - const ReadOnlyCompileOptions& options_; - JSContext* cx_; - LifoAlloc& alloc_; - LifoAlloc::Mark tempPoolMark_; - ParseNodeAllocator nodeAlloc_; - - // Root atoms and objects allocated for the parse tree. - AutoKeepAtoms keepAtoms_; - - // The current ParseContext, holding directives, etc. - ParseContext* parseContext_; - UsedNameTracker& usedNames_; - Maybe tokenizer_; - FullParseHandler factory_; - - friend class BinParseContext; - - // Needs access to AutoGCRooter. - friend void TraceBinParser(JSTracer* trc, AutoGCRooter* parser); -}; - -class BinParseContext : public ParseContext -{ - public: - BinParseContext(JSContext* cx, BinASTParser* parser, SharedContext* sc, Directives* newDirectives) - : ParseContext(cx, parser->parseContext_, sc, *parser, - parser->usedNames_, newDirectives, /* isFull = */ true) - { } -}; - - -} // namespace frontend -} // namespace js - -#endif // frontend_BinSource_h \ No newline at end of file diff --git a/js/src/frontend/BinToken.cpp b/js/src/frontend/BinToken.cpp deleted file mode 100644 index 75b0754b3fae..000000000000 --- a/js/src/frontend/BinToken.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "frontend/BinToken.h" - -#include - -namespace js { -namespace frontend { - -const char* BINKIND_DESCRIPTIONS[] = { -#define WITH_KIND(_, SPEC_NAME) #SPEC_NAME, - FOR_EACH_BIN_KIND(WITH_KIND) -#undef WITH_KIND -}; - -const char* BINFIELD_DESCRIPTIONS[] = { - #define WITH_FIELD(_, SPEC_NAME) #SPEC_NAME, - FOR_EACH_BIN_FIELD(WITH_FIELD) - #undef WITH_FIELD -}; - -const char* describeBinKind(const BinKind& kind) { - return BINKIND_DESCRIPTIONS[static_cast(kind)]; -} - -const char* describeBinField(const BinField& field) { - return BINFIELD_DESCRIPTIONS[static_cast(field)]; -} - -} // namespace frontend -} // namespace js \ No newline at end of file diff --git a/js/src/frontend/BinToken.h b/js/src/frontend/BinToken.h deleted file mode 100644 index 3f2cff616c72..000000000000 --- a/js/src/frontend/BinToken.h +++ /dev/null @@ -1,201 +0,0 @@ -#ifndef frontend_BinToken_h -#define frontend_BinToken_h - -/** - * Definition of Binary AST tokens. - * - * In the Binary AST world, an AST is composed of nodes, where a node is - * defined by: - * - a Kind (see `BinKind`); - * - a list of fields, where each field is: - * - a Name (see `BinField`); - * - a Value, which may be either a node or a primitive value. - * - * The mapping between Kind and list of fields is determined entirely by - * the grammar of Binary AST. The mapping between (Kind, Name) and the structure - * of Value is also determined entirely by the grammar of Binary AST. - * - * As per the specifications of Binary AST, kinds may be added as the language - * grows, but never removed. The mapping between Kind and list of fields may - * also change to add new fields or make some fields optional, but may never - * remove a field. Finally, the mapping between (Kind, Name) and the structure - * of Value may be modified to add new possible values, but never to remove a - * value. - * - * A Binary AST parser must be able to fail gracefully when confronted with - * unknown Kinds or Names. - * - * At the time of this writing, the Binary AST defined from the Babylon AST - * (see https://github.com/babel/babylon/blob/master/ast/spec.md) restricted - * to ES5, with a few amendments to store additional scoping data and to - * represent the empty AST. - * - * Future versions of the Binary AST will progressively grow to encompass ES6 - * and beyond. - */ - -namespace js { -namespace frontend { - - /** - * The different kinds of Binary AST nodes, as per the specifications of - * Binary AST. - * - * These kinds match roughly with the `ParseNodeKind` used internally. - * - * Usage: - * - * ```c++ - * #define WITH_KIND(CPP_NAME, SPEC_NAME) ... - * FOR_EACH_BIN_KIND(WITH_KIND) - * ``` - * - * - * (sorted by alphabetical order) - */ -#define FOR_EACH_BIN_KIND(F) \ - F(ArrayExpression, ArrayExpression) \ - F(AssignmentExpression, AssignmentExpression) \ - F(AssignmentOperator, AssignmentOperator) \ - F(BinaryExpression, BinaryExpression) \ - F(BinaryOperator, BinaryOperator) \ - F(BINJS_Scope, BINJS:Scope) \ - F(BlockStatement, BlockStatement) \ - F(BooleanLiteral, BooleanLiteral) \ - F(BracketExpression, BracketExpression) \ - F(BreakStatement, BreakStatement) \ - F(CallExpression, CallExpression) \ - F(CatchClause, CatchClause) \ - F(ComputedPropertyName, ComputedPropertyName) \ - F(ConditionalExpression, ConditionalExpression) \ - F(ContinueStatement, ContinueStatement) \ - F(DebuggerStatement, DebuggerStatement) \ - F(Declaration, Declaration) \ - F(Directive, Directive) \ - F(DirectiveLiteral, DirectiveLiteral) \ - F(DotExpression, DotExpression) \ - F(DoWhileStatement, DoWhileStatement) \ - F(Elision, Elision) \ - F(EmptyStatement, EmptyStatement) \ - F(Expression, Expression) \ - F(ExpressionStatement, ExpressionStatement) \ - F(ForStatement, ForStatement) \ - F(ForInStatement, ForInStatement) \ - F(FunctionExpression, FunctionExpression) \ - F(FunctionDeclaration, FunctionDeclaration) \ - F(Identifier, Identifier) \ - F(IfStatement, IfStatement) \ - F(LabeledStatement, LabeledStatement) \ - F(Literal, Literal) \ - F(LogicalExpression, LogicalExpression) \ - F(LogicalOperator, LogicalOperator) \ - F(NewExpression, NewExpression) \ - F(NullLiteral, NullLiteral) \ - F(NumericLiteral, NumericLiteral) \ - F(ObjectExpression, ObjectExpression) \ - F(ObjectGetter, ObjectGetter) \ - F(ObjectMethod, ObjectMethod) \ - F(ObjectSetter, ObjectSetter) \ - F(ObjectProperty, ObjectProperty) \ - F(Pattern, Pattern) \ - F(Program, Program) \ - F(PropertyKind, PropertyKind) \ - F(RegExpLiteral, RegExpLiteral) \ - F(ReturnStatement, ReturnStatement) \ - F(SequenceExpression, SequenceExpression) \ - F(StringLiteral, StringLiteral) \ - F(Statement, Statement) \ - F(SwitchCase, SwitchCase) \ - F(SwitchStatement, SwitchStatement) \ - F(ThisExpression, ThisExpression) \ - F(ThrowStatement, ThrowStatement) \ - F(TryStatement, TryStatement) \ - F(UnaryExpression, UnaryExpression) \ - F(UnaryOperator, UnaryOperator) \ - F(UpdateExpression, UpdateExpression) \ - F(UpdateOperator, UpdateOperator) \ - F(VariableDeclaration, VariableDeclaration) \ - F(VariableDeclarator, VariableDeclarator) \ - F(VariableKind, VariableKind) \ - F(WhileStatement, WhileStatement) \ - F(WithStatement, WithStatement) - -enum class BinKind { -#define EMIT_ENUM(name, _) name, - FOR_EACH_BIN_KIND(EMIT_ENUM) -#undef EMIT_ENUM - BINKIND_LIMIT /* domain size */ -}; - -const char* describeBinKind(const BinKind& kind); - -/** - * The different fields of Binary AST nodes, as per the specifications of - * Binary AST. - * - * Usage: - * - * ```c++ - * #define WITH_FIELD(CPP_NAME, SPEC_NAME) ... - * FOR_EACH_BIN_FIELD(WITH_FIELD) - * ``` - * - * (sorted by alphabetical order) - */ - #define FOR_EACH_BIN_FIELD(F) \ - F(Alternate, alternate) \ - F(Argument, argument) \ - F(Arguments, arguments) \ - F(BINJS_CapturedNames, BINJS:CapturedNames) \ - F(BINJS_ConstDeclaredNames, BINJS:ConstDeclaredNames) \ - F(BINJS_HasDirectEval, BINJS:HasDirectEval) \ - F(BINJS_LetDeclaredNames, BINJS:LetDeclaredNames) \ - F(BINJS_VarDeclaredNames, BINJS:VarDeclaredNames) \ - F(BINJS_Scope, BINJS:Scope) \ - F(Block, block) \ - F(Callee, callee) \ - F(Cases, cases) \ - F(Consequent, consequent) \ - F(Body, body) \ - F(Declarations, declarations) \ - F(Directives, directives) \ - F(Discriminant, discriminant) \ - F(Elements, elements) \ - F(Expression, expression) \ - F(Expressions, expressions) \ - F(Finalizer, finalizer) \ - F(Flags, flags) \ - F(Handler, handler) \ - F(Id, id) \ - F(Init, init) \ - F(Key, key) \ - F(Kind, kind) \ - F(Label, label) \ - F(Left, left) \ - F(Name, name) \ - F(Object, object) \ - F(Operator, operator) \ - F(Param, param) \ - F(Params, params) \ - F(Pattern, pattern) \ - F(Prefix, prefix) \ - F(Properties, properties) \ - F(Property, property) \ - F(Right, right) \ - F(Test, test) \ - F(Update, update) \ - F(Value, value) - -enum class BinField { -#define EMIT_ENUM(name, _) name, - FOR_EACH_BIN_FIELD(EMIT_ENUM) -#undef EMIT_ENUM - BINFIELD_LIMIT /* domain size */ -}; - -const char* describeBinField(const BinField& kind); - -} // namespace frontend -} // namespace js - -#endif // frontend_BinToken_h diff --git a/js/src/frontend/BinTokenReaderTester.cpp b/js/src/frontend/BinTokenReaderTester.cpp deleted file mode 100644 index 177909efbcbd..000000000000 --- a/js/src/frontend/BinTokenReaderTester.cpp +++ /dev/null @@ -1,536 +0,0 @@ -#include "frontend/BinTokenReaderTester.h" - -#include "mozilla/EndianUtils.h" -#include "gc/Zone.h" - -namespace js { -namespace frontend { - -using BinFields = BinTokenReaderTester::BinFields; -using AutoList = BinTokenReaderTester::AutoList; -using AutoTaggedTuple = BinTokenReaderTester::AutoTaggedTuple; -using AutoTuple = BinTokenReaderTester::AutoTuple; - -BinTokenReaderTester::BinTokenReaderTester(JSContext* cx, const uint8_t* start, const size_t length) - : cx_(cx) - , start_(start) - , current_(start) - , stop_(start + length) - , latestKnownGoodPos_(0) -{ } - -BinTokenReaderTester::BinTokenReaderTester(JSContext* cx, const Vector& chars) - : cx_(cx) - , start_(chars.begin()) - , current_(chars.begin()) - , stop_(chars.end()) - , latestKnownGoodPos_(0) -{ } - -bool -BinTokenReaderTester::raiseError(const char* description) -{ - MOZ_ASSERT(!cx_->isExceptionPending()); - TokenPos pos = this->pos(); - JS_ReportErrorASCII(cx_, "BinAST parsing error: %s at offsets %u => %u", - description, pos.begin, pos.end); - return false; -} - -bool -BinTokenReaderTester::readBuf(uint8_t* bytes, uint32_t len) -{ - MOZ_ASSERT(!cx_->isExceptionPending()); - MOZ_ASSERT(len > 0); - - if (stop_ < current_ + len) - return raiseError("Buffer exceeds length"); - - for (uint32_t i = 0; i < len; ++i) - *bytes++ = *current_++; - - return true; -} - -bool -BinTokenReaderTester::readByte(uint8_t* byte) -{ - return readBuf(byte, 1); -} - - -// Nullable booleans: -// -// 0 => false -// 1 => true -// 2 => null -bool -BinTokenReaderTester::readMaybeBool(Maybe& result) -{ - updateLatestKnownGood(); - uint8_t byte; - if (!readByte(&byte)) - return false; - - switch (byte) { - case 0: - result = Some(false); - break; - case 1: - result = Some(true); - break; - case 2: - result = Nothing(); - break; - default: - return raiseError("Invalid boolean value"); - } - return true; -} - -bool -BinTokenReaderTester::readBool(bool& out) -{ - Maybe result; - - if (!readMaybeBool(result)) - return false; - - if (result.isNothing()) - return raiseError("Empty boolean value"); - - out = *result; - return true; -} - -// Nullable doubles (little-endian) -// -// 0x7FF0000000000001 (signaling NaN) => null -// anything other 64 bit sequence => IEEE-764 64-bit floating point number -bool -BinTokenReaderTester::readMaybeDouble(Maybe& result) -{ - updateLatestKnownGood(); - - uint8_t bytes[8]; - MOZ_ASSERT(sizeof(bytes) == sizeof(double)); - if (!readBuf(reinterpret_cast(bytes), ArrayLength(bytes))) - return false; - - // Decode little-endian. - const uint64_t asInt = LittleEndian::readUint64(bytes); - - if (asInt == 0x7FF0000000000001) { - result = Nothing(); - } else { - // Canonicalize NaN, just to make sure another form of signalling NaN - // doesn't slip past us. - const double asDouble = CanonicalizeNaN(BitwiseCast(asInt)); - result = Some(asDouble); - } - - return true; -} - -bool -BinTokenReaderTester::readDouble(double& out) -{ - Maybe result; - - if (!readMaybeDouble(result)) - return false; - - if (result.isNothing()) - return raiseError("Empty double value"); - - out = *result; - return true; -} - -// Internal uint32_t -// -// Encoded as 4 bytes, little-endian. -bool -BinTokenReaderTester::readInternalUint32(uint32_t* result) -{ - uint8_t bytes[4]; - MOZ_ASSERT(sizeof(bytes) == sizeof(uint32_t)); - if (!readBuf(bytes, 4)) - return false; - - // Decode little-endian. - *result = LittleEndian::readUint32(bytes); - - return true; -} - - - -// Nullable strings: -// - "" (not counted in byte length) -// - byte length (not counted in byte length) -// - bytes (UTF-8) -// - "" (not counted in byte length) -// -// The special sequence of bytes `[255, 0]` (which is an invalid UTF-8 sequence) -// is reserved to `null`. -bool -BinTokenReaderTester::readMaybeChars(Maybe& out) -{ - updateLatestKnownGood(); - - if (!readConst("")) - return false; - - // 1. Read byteLength - uint32_t byteLen; - if (!readInternalUint32(&byteLen)) - return false; - - // 2. Reject if we can't read - if (current_ + byteLen < current_) // Check for overflows - return raiseError("Arithmetics overflow: string is too long"); - - if (current_ + byteLen > stop_) - return raiseError("Not enough bytes to read chars"); - - // 3. Check null string (no allocation) - if (byteLen == 2 && *current_ == 255 && *(current_ + 1) == 0) { - // Special case: null string. - out = Nothing(); - current_ += byteLen; - return true; - } - - // 4. Other strings (bytes are copied) - out.emplace(cx_); - if (!out->resize(byteLen)) { - ReportOutOfMemory(cx_); - return false; - } - PodCopy(out->begin(), current_, byteLen); - current_ += byteLen; - - if (!readConst("")) - return false; - - return true; -} - -bool -BinTokenReaderTester::readChars(Chars& out) -{ - Maybe result; - - if (!readMaybeChars(result)) - return false; - - if (result.isNothing()) - return raiseError("Empty string"); - - out = Move(*result); - return true; -} - -template -bool -BinTokenReaderTester::matchConst(const char (&value)[N]) -{ - MOZ_ASSERT(N > 0); - MOZ_ASSERT(value[N - 1] == 0); - MOZ_ASSERT(!cx_->isExceptionPending()); - - if (current_ + N - 1 > stop_) - return false; - - // Perform lookup, without side-effects. - if (!std::equal(current_, current_ + N - 1 /*implicit NUL*/, value)) - return false; - - // Looks like we have a match. Now perform side-effects - current_ += N - 1; - updateLatestKnownGood(); - return true; -} - - -// Untagged tuple: -// - ""; -// - contents (specified by the higher-level grammar); -// - "" -bool -BinTokenReaderTester::enterUntaggedTuple(AutoTuple& guard) -{ - if (!readConst("")) - return false; - - guard.init(); - return true; -} - -template -bool -BinTokenReaderTester::readConst(const char (&value)[N]) -{ - updateLatestKnownGood(); - if (!matchConst(value)) - return raiseError("Could not find expected literal"); - - return true; -} - -// Tagged tuples: -// - "" -// - "" -// - non-null string `name`, followed by \0 (see `readString()`); -// - uint32_t number of fields; -// - array of `number of fields` non-null strings followed each by \0 (see `readString()`); -// - "" -// - content (specified by the higher-level grammar); -// - "" -bool -BinTokenReaderTester::enterTaggedTuple(BinKind& tag, BinFields& fields, AutoTaggedTuple& guard) -{ - // Header - if (!readConst("")) - return false; - - if (!readConst("")) - return false; - - // This would probably be much faster with a HashTable, but we don't - // really care about the speed of BinTokenReaderTester. - do { - -#define FIND_MATCH(CONSTRUCTOR, NAME) \ - if (matchConst(#NAME "\0")) { \ - tag = BinKind::CONSTRUCTOR; \ - break; \ - } // else - - FOR_EACH_BIN_KIND(FIND_MATCH) -#undef FIND_MATCH - - // else - return raiseError("Invalid tag"); - } while(false); - - // Now fields. - uint32_t fieldNum; - if (!readInternalUint32(&fieldNum)) - return false; - - fields.clear(); - if (!fields.reserve(fieldNum)) - return raiseError("Out of memory"); - - for (uint32_t i = 0; i < fieldNum; ++i) { - // This would probably be much faster with a HashTable, but we don't - // really care about the speed of BinTokenReaderTester. - BinField field; - do { - -#define FIND_MATCH(CONSTRUCTOR, NAME) \ - if (matchConst(#NAME "\0")) { \ - field = BinField::CONSTRUCTOR; \ - break; \ - } // else - - FOR_EACH_BIN_FIELD(FIND_MATCH) -#undef FIND_MATCH - - // else - return raiseError("Invalid field"); - } while (false); - - // Make sure that we do not have duplicate fields. - // Search is linear, but again, we don't really care - // in this implementation. - for (uint32_t j = 0; j < i; ++j) { - if (fields[j] == field) { - return raiseError("Duplicate field"); - } - } - - fields.infallibleAppend(field); // Already checked. - } - - // End of header - - if (!readConst("")) - return false; - - // Enter the body. - guard.init(); - return true; -} - -// List: -// -// - "" (not counted in byte length); -// - uint32_t byte length (not counted in byte length); -// - uint32_t number of items; -// - contents (specified by higher-level grammar); -// - "" (not counted in byte length) -// -// The total byte length of `number of items` + `contents` must be `byte length`. -bool -BinTokenReaderTester::enterList(uint32_t& items, AutoList& guard) -{ - if (!readConst("")) - return false; - - uint32_t byteLen; - if (!readInternalUint32(&byteLen)) - return false; - - const uint8_t* stop = current_ + byteLen; - - if (stop < current_) // Check for overflows - return raiseError("Arithmetics overflow: list is too long"); - - if (stop > this->stop_) - return raiseError("Incorrect list length"); - - guard.init(stop); - - if (!readInternalUint32(&items)) - return false; - - return true; -} - -void -BinTokenReaderTester::updateLatestKnownGood() -{ - MOZ_ASSERT(current_ >= start_); - const size_t update = current_ - start_; - MOZ_ASSERT(update >= latestKnownGoodPos_); - latestKnownGoodPos_ = update; -} - -size_t -BinTokenReaderTester::offset() const -{ - return latestKnownGoodPos_; -} - -TokenPos -BinTokenReaderTester::pos() -{ - return pos(latestKnownGoodPos_); -} - -TokenPos -BinTokenReaderTester::pos(size_t start) -{ - TokenPos pos; - pos.begin = start; - pos.end = current_ - start_; - MOZ_ASSERT(pos.end >= pos.begin); - return pos; -} - -void -BinTokenReaderTester::AutoBase::init() -{ - initialized_ = true; -} - -BinTokenReaderTester::AutoBase::AutoBase(BinTokenReaderTester& reader) - : reader_(reader) -{ } - -BinTokenReaderTester::AutoBase::~AutoBase() -{ - // By now, the `AutoBase` must have been deinitialized by calling `done()`. - // The only case in which we can accept not calling `done()` is if we have - // bailed out because of an error. - MOZ_ASSERT_IF(initialized_, reader_.cx_->isExceptionPending()); -} - -bool -BinTokenReaderTester::AutoBase::checkPosition(const uint8_t* expectedEnd) -{ - if (reader_.current_ != expectedEnd) - return reader_.raiseError("Caller did not consume the expected set of bytes"); - - return true; -} - -BinTokenReaderTester::AutoList::AutoList(BinTokenReaderTester& reader) - : AutoBase(reader) -{ } - -void -BinTokenReaderTester::AutoList::init(const uint8_t* expectedEnd) -{ - AutoBase::init(); - this->expectedEnd_ = expectedEnd; -} - -bool -BinTokenReaderTester::AutoList::done() -{ - MOZ_ASSERT(initialized_); - initialized_ = false; - if (reader_.cx_->isExceptionPending()) { - // Already errored, no need to check further. - return false; - } - - // Check that we have consumed the exact number of bytes. - if (!checkPosition(expectedEnd_)) - return false; - - // Check suffix. - if (!reader_.readConst("")) - return false; - - return true; -} - -BinTokenReaderTester::AutoTaggedTuple::AutoTaggedTuple(BinTokenReaderTester& reader) - : AutoBase(reader) -{ } - -bool -BinTokenReaderTester::AutoTaggedTuple::done() -{ - MOZ_ASSERT(initialized_); - initialized_ = false; - if (reader_.cx_->isExceptionPending()) { - // Already errored, no need to check further. - return false; - } - - // Check suffix. - if (!reader_.readConst("")) - return false; - - return true; -} - -BinTokenReaderTester::AutoTuple::AutoTuple(BinTokenReaderTester& reader) - : AutoBase(reader) -{ } - -bool -BinTokenReaderTester::AutoTuple::done() -{ - MOZ_ASSERT(initialized_); - initialized_ = false; - if (reader_.cx_->isExceptionPending()) { - // Already errored, no need to check further. - return false; - } - - // Check suffix. - if (!reader_.readConst("")) - return false; - - return true; -} - -} // namespace frontend -} // namespace js diff --git a/js/src/frontend/BinTokenReaderTester.h b/js/src/frontend/BinTokenReaderTester.h deleted file mode 100644 index 7fa8ffe03b3b..000000000000 --- a/js/src/frontend/BinTokenReaderTester.h +++ /dev/null @@ -1,357 +0,0 @@ -#ifndef frontend_BinTokenReaderTester_h -#define frontend_BinTokenReaderTester_h - -#include "mozilla/Maybe.h" - -#include "frontend/BinToken.h" -#include "frontend/TokenStream.h" - -#include "js/TypeDecls.h" - -#if !defined(NIGHTLY_BUILD) -#error "BinTokenReaderTester.* is designed to help test implementations of successive versions of JS BinaryAST. It is available only on Nightly." -#endif // !defined(NIGHTLY_BUILD) - -namespace js { -namespace frontend { - -using namespace mozilla; -using namespace JS; - -/** - * A token reader for a simple, alternative serialization format for BinAST. - * - * This serialization format, which is also supported by the reference - * implementation of the BinAST compression suite, is designed to be - * mostly human-readable and easy to check for all sorts of deserialization - * errors. While this format is NOT designed to be shipped to end-users, it - * is nevertheless a very useful tool for implementing and testing parsers. - * - * Both the format and the implementation are ridiculously inefficient: - * - * - the underlying format tags almost all its data with e.g. ``, `` - * to aid with detecting offset errors or format error; - * - the underlying format copies list of fields into every single node, instead - * of keeping them once in the header; - * - every kind/field extraction requires memory allocation and plenty of string - * comparisons; - * - ... - * - * This token reader is designed to be API-compatible with the standard, shipped, - * token reader. For these reasons: - * - * - it does not support any form of look ahead, push back; - * - it does not support any form of error recovery. - */ -class MOZ_STACK_CLASS BinTokenReaderTester -{ - public: - // A list of fields, in the order in which they appear in the stream. - using BinFields = Vector; - - // A bunch of characters. At this stage, there is no guarantee on whether - // they are valid UTF-8. Future versions may replace this by slice into - // the buffer. - using Chars = Vector; - - class AutoList; - class AutoTuple; - class AutoTaggedTuple; - - public: - /** - * Construct a token reader. - * - * Does NOT copy the buffer. - */ - BinTokenReaderTester(JSContext* cx, const uint8_t* start, const size_t length); - - /** - * Construct a token reader. - * - * Does NOT copy the buffer. - */ - BinTokenReaderTester(JSContext* cx, const Vector& chars); - - // --- Primitive values. - // - // Note that the underlying format allows for a `null` value for primitive - // values. - // - // Reading will return an error either in case of I/O error or in case of - // a format problem. Reading if an exception in pending is an error and - // will cause assertion failures. Do NOT attempt to read once an exception - // has been cleared: the token reader does NOT support recovery, by design. - - /** - * Read a single `true | false | null` value. - * - * @param out Set to `Nothing` if the data specifies that the value is `null`. - * Otherwise, `Some(true)` or `Some(false)`. - * - * @return false If a boolean could not be read. In this case, an error - * has been raised. - */ - MOZ_MUST_USE bool readMaybeBool(Maybe& out); - MOZ_MUST_USE bool readBool(bool& out); - - /** - * Read a single `number | null` value. - * - * @param out Set to `Nothing` if the data specifies that the value is `null`. - * Otherwise, `Some(x)`, where `x` is a valid `double` (i.e. either a non-NaN - * or a canonical NaN). - * - * @return false If a double could not be read. In this case, an error - * has been raised. - */ - MOZ_MUST_USE bool readMaybeDouble(Maybe& out); - MOZ_MUST_USE bool readDouble(double& out); - - /** - * Read a single `string | null` value. - * - * @param out Set to `Nothing` if the data specifies that the value is `null`. - * Otherwise, `Some(x)`, where `x` is a `string`. - * - * WARNING: At this stage, the `string` encoding has NOT been validated. - * - * @return false If a string could not be read. In this case, an error - * has been raised. - */ - MOZ_MUST_USE bool readMaybeChars(Maybe& out); - MOZ_MUST_USE bool readChars(Chars& out); - - // --- Composite values. - // - // The underlying format does NOT allows for a `null` composite value. - // - // Reading will return an error either in case of I/O error or in case of - // a format problem. Reading from a poisoned tokenizer is an error and - // will cause assertion failures. - - /** - * Start reading a list. - * - * @param length (OUT) The number of elements in the list. - * @param guard (OUT) A guard, ensuring that we read the list correctly. - * - * The `guard` is dedicated to ensuring that reading the list has consumed - * exactly all the bytes from that list. The `guard` MUST therefore be - * destroyed at the point where the caller has reached the end of the list. - * If the caller has consumed too few/too many bytes, this will be reported - * in the call go `guard.done()`. - * - * @return out If the header of the list is invalid. - */ - MOZ_MUST_USE bool enterList(uint32_t& length, AutoList& guard); - - /** - * Start reading a tagged tuple. - * - * @param tag (OUT) The tag of the tuple. - * @param fields (OUT) The ORDERED list of fields encoded in this tuple. - * @param guard (OUT) A guard, ensuring that we read the tagged tuple correctly. - * - * The `guard` is dedicated to ensuring that reading the list has consumed - * exactly all the bytes from that tuple. The `guard` MUST therefore be - * destroyed at the point where the caller has reached the end of the tuple. - * If the caller has consumed too few/too many bytes, this will be reported - * in the call go `guard.done()`. - * - * @return out If the header of the tuple is invalid. - */ - MOZ_MUST_USE bool enterTaggedTuple(BinKind& tag, BinTokenReaderTester::BinFields& fields, AutoTaggedTuple& guard); - - /** - * Start reading an untagged tuple. - * - * @param guard (OUT) A guard, ensuring that we read the tuple correctly. - * - * The `guard` is dedicated to ensuring that reading the list has consumed - * exactly all the bytes from that tuple. The `guard` MUST therefore be - * destroyed at the point where the caller has reached the end of the tuple. - * If the caller has consumed too few/too many bytes, this will be reported - * in the call go `guard.done()`. - * - * @return out If the header of the tuple is invalid. - */ - MOZ_MUST_USE bool enterUntaggedTuple(AutoTuple& guard); - - /** - * Return the position of the latest token. - */ - TokenPos pos(); - TokenPos pos(size_t startOffset); - size_t offset() const; - - /** - * Raise an error. - * - * Once `raiseError` has been called, the tokenizer is poisoned. - */ - MOZ_MUST_USE bool raiseError(const char* description); - - /** - * Poison this tokenizer. - */ - void poison(); - - private: - /** - * Read a single byte. - */ - MOZ_MUST_USE bool readByte(uint8_t* byte); - - /** - * Read several bytes. - * - * If there is not enough data, or if the tokenizer has previously been - * poisoned, return `false` and report an exception. - */ - MOZ_MUST_USE bool readBuf(uint8_t* bytes, uint32_t len); - - /** - * Read a single uint32_t. - */ - MOZ_MUST_USE bool readInternalUint32(uint32_t*); - - /** - * Read a sequence of chars, ensuring that they match an expected - * sequence of chars. - * - * @param value The sequence of chars to expect, NUL-terminated. The NUL - * is not expected in the stream. - */ - template - MOZ_MUST_USE bool readConst(const char (&value)[N]); - - /** - * Read a sequence of chars, consuming the bytes only if they match an expected - * sequence of chars. - * - * @param value The sequence of chars to expect, NUL-terminated. The NUL - * is not expected in the stream. - * @return true if `value` (minus NUL) represents the next few chars in the - * internal buffer, false otherwise. If `true`, the chars are consumed, - * otherwise there is no side-effect. - */ - template - MOZ_MUST_USE bool matchConst(const char (&value)[N]); - - /** - * Update the "latest known good" position, which is used during error - * reporting. - */ - void updateLatestKnownGood(); - - private: - JSContext* cx_; - - // `true` if we have encountered an error. Errors are non recoverable. - // Attempting to read from a poisoned tokenizer will cause assertion errors. - bool poisoned_; - - // The first byte of the buffer. Not owned. - const uint8_t* start_; - - // The current position. - const uint8_t* current_; - - // The last+1 byte of the buffer. - const uint8_t* stop_; - - - // Latest known good position. Used for error reporting. - size_t latestKnownGoodPos_; - - BinTokenReaderTester(const BinTokenReaderTester&) = delete; - BinTokenReaderTester(BinTokenReaderTester&&) = delete; - BinTokenReaderTester& operator=(BinTokenReaderTester&) = delete; - - public: - // The following classes are used whenever we encounter a tuple/tagged tuple/list - // to make sure that: - // - // - if the construct "knows" its byte length, we have exactly consumed all - // the bytes (otherwise, this means that the file is corrupted, perhaps on - // purpose, so we need to reject the stream); - // - if the construct has a footer, once we are done reading it, we have - // reached the footer (this is to aid with debugging). - // - // In either case, the caller MUST call method `done()` of the guard once - // it is done reading the tuple/tagged tuple/list, to report any pending error. - - // Base class used by other Auto* classes. - class MOZ_STACK_CLASS AutoBase - { - protected: - explicit AutoBase(BinTokenReaderTester& reader); - ~AutoBase(); - - // Raise an error if we are not in the expected position. - MOZ_MUST_USE bool checkPosition(const uint8_t* expectedPosition); - - friend BinTokenReaderTester; - void init(); - - // Set to `true` if `init()` has been called. Reset to `false` once - // all conditions have been checked. - bool initialized_; - BinTokenReaderTester& reader_; - }; - - // Guard class used to ensure that `enterList` is used properly. - class MOZ_STACK_CLASS AutoList : public AutoBase - { - public: - explicit AutoList(BinTokenReaderTester& reader); - - // Check that we have properly read to the end of the list. - MOZ_MUST_USE bool done(); - protected: - friend BinTokenReaderTester; - void init(const uint8_t* expectedEnd); - private: - const uint8_t* expectedEnd_; - }; - - // Guard class used to ensure that `enterTaggedTuple` is used properly. - class MOZ_STACK_CLASS AutoTaggedTuple : public AutoBase - { - public: - explicit AutoTaggedTuple(BinTokenReaderTester& reader); - - // Check that we have properly read to the end of the tuple. - MOZ_MUST_USE bool done(); - }; - - // Guard class used to ensure that `readTuple` is used properly. - class MOZ_STACK_CLASS AutoTuple : public AutoBase - { - public: - explicit AutoTuple(BinTokenReaderTester& reader); - - // Check that we have properly read to the end of the tuple. - MOZ_MUST_USE bool done(); - }; - - // Compare a `Chars` and a string literal (ONLY a string literal). - template - static bool equals(const Chars& left, const char (&right)[N]) { - MOZ_ASSERT(N > 0); - MOZ_ASSERT(right[N - 1] == 0); - if (left.length() + 1 /* implicit NUL */ != N) - return false; - - if (!std::equal(left.begin(), left.end(), right)) - return false; - - return true; - } -}; - -} // namespace frontend -} // namespace js - -#endif // frontend_BinTokenReaderTester_h diff --git a/js/src/frontend/BytecodeCompiler.h b/js/src/frontend/BytecodeCompiler.h index 44142cb2c0df..82ea548279cc 100644 --- a/js/src/frontend/BytecodeCompiler.h +++ b/js/src/frontend/BytecodeCompiler.h @@ -124,14 +124,6 @@ IsKeyword(JSLinearString* str); void TraceParser(JSTracer* trc, JS::AutoGCRooter* parser); -#if defined(JS_BUILD_BINAST) - -/* Trace all GC things reachable from binjs parser. Defined in BinSource.cpp. */ -void -TraceBinParser(JSTracer* trc, JS::AutoGCRooter* parser); - -#endif // defined(JS_BUILD_BINAST) - class MOZ_STACK_CLASS AutoFrontendTraceLog { #ifdef JS_TRACE_LOGGING diff --git a/js/src/frontend/FullParseHandler.h b/js/src/frontend/FullParseHandler.h index fa16f43ff5de..9824d6c5e101 100644 --- a/js/src/frontend/FullParseHandler.h +++ b/js/src/frontend/FullParseHandler.h @@ -21,13 +21,6 @@ class RegExpObject; namespace frontend { -enum class SourceKind { - // We are parsing from a text source (Parser.h) - Text, - // We are parsing from a binary source (BinSource.h) - Binary, -}; - // Parse handler used when generating a full parse tree for all code which the // parser encounters. class FullParseHandler @@ -48,8 +41,6 @@ class FullParseHandler size_t lazyInnerFunctionIndex; size_t lazyClosedOverBindingIndex; - const SourceKind sourceKind_; - public: /* new_ methods for creating parse nodes. These report OOM on context. */ JS_DECLARE_NEW_METHODS(new_, allocParseNode, inline) @@ -77,24 +68,15 @@ class FullParseHandler return node->isInParens() && (node->isKind(PNK_OBJECT) || node->isKind(PNK_ARRAY)); } - FullParseHandler(JSContext* cx, LifoAlloc& alloc, LazyScript* lazyOuterFunction, - SourceKind kind = SourceKind::Text) + FullParseHandler(JSContext* cx, LifoAlloc& alloc, LazyScript* lazyOuterFunction) : allocator(cx, alloc), lazyOuterFunction_(cx, lazyOuterFunction), lazyInnerFunctionIndex(0), - lazyClosedOverBindingIndex(0), - sourceKind_(SourceKind::Text) + lazyClosedOverBindingIndex(0) {} static ParseNode* null() { return nullptr; } - // The FullParseHandler may be used to create nodes for text sources - // (from Parser.h) or for binary sources (from BinSource.h). In the latter - // case, some common assumptions on offsets are incorrect, e.g. in `a + b`, - // `a`, `b` and `+` may be stored in any order. We use `sourceKind()` - // to determine whether we need to check these assumptions. - SourceKind sourceKind() const { return sourceKind_; } - ParseNode* freeTree(ParseNode* pn) { return allocator.freeTree(pn); } void prepareNodeForMutation(ParseNode* pn) { return allocator.prepareNodeForMutation(pn); } @@ -248,7 +230,8 @@ class FullParseHandler ParseNode* elision = new_(PNK_ELISION, pos); if (!elision) return false; - addList(/* list = */ literal, /* child = */ elision); + + literal->append(elision); literal->pn_xflags |= PNX_ARRAYHOLESPREAD | PNX_NONCONST; return true; } @@ -260,7 +243,8 @@ class FullParseHandler ParseNode* spread = newSpread(begin, inner); if (!spread) return false; - addList(/* list = */ literal, /* child = */ spread); + + literal->append(spread); literal->pn_xflags |= PNX_ARRAYHOLESPREAD | PNX_NONCONST; return true; } @@ -270,7 +254,8 @@ class FullParseHandler if (!element->isConstant()) literal->pn_xflags |= PNX_NONCONST; - addList(/* list = */ literal, /* child = */ element); + + literal->append(element); } ParseNode* newCall(const TokenPos& pos) { @@ -309,9 +294,7 @@ class FullParseHandler ParseNode* newSuperBase(ParseNode* thisName, const TokenPos& pos) { return new_(PNK_SUPERBASE, pos, thisName); } - ParseNode* newCatchBlock(ParseNode* catchName, ParseNode* catchGuard, ParseNode* catchBody) { - return new_(PNK_CATCH, catchName, catchGuard, catchBody); - } + MOZ_MUST_USE bool addPrototypeMutation(ParseNode* literal, uint32_t begin, ParseNode* expr) { MOZ_ASSERT(literal->isKind(PNK_OBJECT)); MOZ_ASSERT(literal->isArity(PN_LIST)); @@ -323,19 +306,22 @@ class FullParseHandler ParseNode* mutation = newUnary(PNK_MUTATEPROTO, begin, expr); if (!mutation) return false; - addList(/* list = */ literal, /* child = */ mutation); + literal->append(mutation); return true; } MOZ_MUST_USE bool addPropertyDefinition(ParseNode* literal, ParseNode* key, ParseNode* val) { MOZ_ASSERT(literal->isKind(PNK_OBJECT)); MOZ_ASSERT(literal->isArity(PN_LIST)); - MOZ_ASSERT(isUsableAsObjectPropertyName(key)); + MOZ_ASSERT(key->isKind(PNK_NUMBER) || + key->isKind(PNK_OBJECT_PROPERTY_NAME) || + key->isKind(PNK_STRING) || + key->isKind(PNK_COMPUTED_NAME)); ParseNode* propdef = newBinary(PNK_COLON, key, val, JSOP_INITPROP); if (!propdef) return false; - addList(/* list = */ literal, /* child = */ propdef); + literal->append(propdef); return true; } @@ -350,7 +336,7 @@ class FullParseHandler ParseNode* propdef = newBinary(PNK_SHORTHAND, name, expr, JSOP_INITPROP); if (!propdef) return false; - addList(/* list = */ literal, /* child = */ propdef); + literal->append(propdef); return true; } @@ -362,21 +348,26 @@ class FullParseHandler ParseNode* spread = newSpread(begin, inner); if (!spread) return false; - addList(/* list = */ literal, /* child = */ spread); + literal->append(spread); return true; } MOZ_MUST_USE bool addObjectMethodDefinition(ParseNode* literal, ParseNode* key, ParseNode* fn, AccessorType atype) { + MOZ_ASSERT(literal->isKind(PNK_OBJECT)); MOZ_ASSERT(literal->isArity(PN_LIST)); - literal->pn_xflags |= PNX_NONCONST; + MOZ_ASSERT(key->isKind(PNK_NUMBER) || + key->isKind(PNK_OBJECT_PROPERTY_NAME) || + key->isKind(PNK_STRING) || + key->isKind(PNK_COMPUTED_NAME)); - ParseNode* propdef = newObjectMethodOrPropertyDefinition(key, fn, atype); + ParseNode* propdef = newBinary(PNK_COLON, key, fn, AccessorTypeToJSOp(atype)); if (!propdef) return false; - addList(/* list = */ literal, /* child = */ propdef); + literal->append(propdef); + literal->pn_xflags |= PNX_NONCONST; return true; } @@ -384,12 +375,15 @@ class FullParseHandler AccessorType atype, bool isStatic) { MOZ_ASSERT(methodList->isKind(PNK_CLASSMETHODLIST)); - MOZ_ASSERT(isUsableAsObjectPropertyName(key)); + MOZ_ASSERT(key->isKind(PNK_NUMBER) || + key->isKind(PNK_OBJECT_PROPERTY_NAME) || + key->isKind(PNK_STRING) || + key->isKind(PNK_COMPUTED_NAME)); ParseNode* classMethod = new_(key, fn, AccessorTypeToJSOp(atype), isStatic); if (!classMethod) return false; - addList(/* list = */ methodList, /* child = */ classMethod); + methodList->append(classMethod); return true; } @@ -428,7 +422,7 @@ class FullParseHandler void addStatementToList(ParseNode* list, ParseNode* stmt) { MOZ_ASSERT(list->isKind(PNK_STATEMENTLIST)); - addList(/* list = */ list, /* child = */ stmt); + list->append(stmt); if (isFunctionStmt(stmt)) { // PNX_FUNCDEFS notifies the emitter that the block contains @@ -448,16 +442,12 @@ class FullParseHandler MOZ_ASSERT(casepn->isKind(PNK_CASE)); MOZ_ASSERT(casepn->pn_right->isKind(PNK_STATEMENTLIST)); - addList(/* list = */ list, /* child = */ casepn); + list->append(casepn); if (casepn->pn_right->pn_xflags & PNX_FUNCDEFS) list->pn_xflags |= PNX_FUNCDEFS; } - MOZ_MUST_USE inline bool addCatchBlock(ParseNode* catchList, ParseNode* lexicalScope, - ParseNode* catchName, ParseNode* catchGuard, - ParseNode* catchBody); - MOZ_MUST_USE bool prependInitialYield(ParseNode* stmtList, ParseNode* genName) { MOZ_ASSERT(stmtList->isKind(PNK_STATEMENTLIST)); MOZ_ASSERT(stmtList->isArity(PN_LIST)); @@ -469,7 +459,8 @@ class FullParseHandler MOZ_ASSERT(genName->getOp() == JSOP_GETNAME); genName->setOp(JSOP_SETNAME); - ParseNode* genInit = newAssignment(PNK_ASSIGN, /* lhs = */ genName, /* rhs = */ makeGen); + + ParseNode* genInit = newBinary(PNK_ASSIGN, genName, makeGen); if (!genInit) return false; @@ -680,20 +671,6 @@ class FullParseHandler !node->pn_funbox->isArrow(); } - ParseNode* newObjectMethodOrPropertyDefinition(ParseNode* key, ParseNode* fn, AccessorType atype) { - MOZ_ASSERT(isUsableAsObjectPropertyName(key)); - - return newBinary(PNK_COLON, key, fn, AccessorTypeToJSOp(atype)); - } - - bool setComprehensionLambdaBody(ParseNode* pn, ParseNode* body) { - MOZ_ASSERT(body->isKind(PNK_STATEMENTLIST)); - ParseNode* paramsBody = newList(PNK_PARAMSBODY, body); - if (!paramsBody) - return false; - setFunctionFormalParametersAndBody(pn, paramsBody); - return true; - } void setFunctionFormalParametersAndBody(ParseNode* funcNode, ParseNode* kid) { MOZ_ASSERT_IF(kid, kid->isKind(PNK_PARAMSBODY)); funcNode->pn_body = kid; @@ -704,11 +681,11 @@ class FullParseHandler funbox->functionNode = pn; } void addFunctionFormalParameter(ParseNode* pn, ParseNode* argpn) { - addList(/* list = */ pn->pn_body, /* child = */ argpn); + pn->pn_body->append(argpn); } void setFunctionBody(ParseNode* fn, ParseNode* body) { MOZ_ASSERT(fn->pn_body->isKind(PNK_PARAMSBODY)); - addList(/* list = */ fn->pn_body, /* child = */ body); + fn->pn_body->append(body); } ParseNode* newModule(const TokenPos& pos) { @@ -724,7 +701,7 @@ class FullParseHandler if (!newExpr) return nullptr; - addList(/* list = */ newExpr, /* child = */ ctor); + addList(newExpr, ctor); return newExpr; } @@ -767,13 +744,6 @@ class FullParseHandler return node->isKind(PNK_SUPERBASE); } - bool isUsableAsObjectPropertyName(ParseNode* node) { - return node->isKind(PNK_NUMBER) - || node->isKind(PNK_OBJECT_PROPERTY_NAME) - || node->isKind(PNK_STRING) - || node->isKind(PNK_COMPUTED_NAME); - } - inline MOZ_MUST_USE bool finishInitializerAssignment(ParseNode* pn, ParseNode* init); void setBeginPosition(ParseNode* pn, ParseNode* oth) { @@ -835,10 +805,7 @@ class FullParseHandler } void addList(ParseNode* list, ParseNode* kid) { - if (sourceKind_ == SourceKind::Text) - list->append(kid); - else - list->appendWithoutOrderAssumption(kid); + list->append(kid); } void setOp(ParseNode* pn, JSOp op) { @@ -912,19 +879,6 @@ class FullParseHandler } }; -inline bool -FullParseHandler::addCatchBlock(ParseNode* catchList, ParseNode* lexicalScope, - ParseNode* catchName, ParseNode* catchGuard, - ParseNode* catchBody) -{ - ParseNode* catchpn = newCatchBlock(catchName, catchGuard, catchBody); - if (!catchpn) - return false; - addList(/* list = */ catchList, /* child = */ lexicalScope); - lexicalScope->setScopeBody(catchpn); - return true; -} - inline bool FullParseHandler::setLastFunctionFormalParameterDefault(ParseNode* funcpn, ParseNode* defaultValue) diff --git a/js/src/frontend/ParseContext-inl.h b/js/src/frontend/ParseContext-inl.h deleted file mode 100644 index be2d22b53b47..000000000000 --- a/js/src/frontend/ParseContext-inl.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef frontend_ParseContext_inl_h -#define frontend_ParseContext_inl_h - -#include "frontend/ParseContext.h" - -namespace js { -namespace frontend { - -template <> -inline bool -ParseContext::Statement::is() const -{ - return kind_ == StatementKind::Label; -} - -template <> -inline bool -ParseContext::Statement::is() const -{ - return kind_ == StatementKind::Class; -} - - -inline JS::Result -ParseContext::checkBreakStatement(PropertyName* label) -{ - // Labeled 'break' statements target the nearest labeled statements (could - // be any kind) with the same label. Unlabeled 'break' statements target - // the innermost loop or switch statement. - if (label) { - auto hasSameLabel = [&label](ParseContext::LabelStatement* stmt) { - MOZ_ASSERT(stmt); - return stmt->label() == label; - }; - - if (!findInnermostStatement(hasSameLabel)) - return mozilla::Err(ParseContext::BreakStatementError::LabelNotFound); - - } else { - auto isBreakTarget = [](ParseContext::Statement* stmt) { - return StatementKindIsUnlabeledBreakTarget(stmt->kind()); - }; - - if (!findInnermostStatement(isBreakTarget)) - return mozilla::Err(ParseContext::BreakStatementError::ToughBreak); - } - - return Ok(); -} - -inline JS::Result -ParseContext::checkContinueStatement(PropertyName* label) -{ - // Labeled 'continue' statements target the nearest labeled loop - // statements with the same label. Unlabeled 'continue' statements target - // the innermost loop statement. - auto isLoop = [](ParseContext::Statement* stmt) { - MOZ_ASSERT(stmt); - return StatementKindIsLoop(stmt->kind()); - }; - - if (!label) { - // Unlabeled statement: we target the innermost loop, so make sure that - // there is an innermost loop. - if (!findInnermostStatement(isLoop)) - return mozilla::Err(ParseContext::ContinueStatementError::NotInALoop); - return Ok(); - } - - // Labeled statement: targest the nearest labeled loop with the same label. - ParseContext::Statement* stmt = innermostStatement(); - bool foundLoop = false; // True if we have encountered at least one loop. - - for (;;) { - stmt = ParseContext::Statement::findNearest(stmt, isLoop); - if (!stmt) - return foundLoop ? mozilla::Err(ParseContext::ContinueStatementError::LabelNotFound) - : mozilla::Err(ParseContext::ContinueStatementError::NotInALoop); - - foundLoop = true; - - // Is it labeled by our label? - stmt = stmt->enclosing(); - while (stmt && stmt->is()) { - if (stmt->as().label() == label) - return Ok(); - - stmt = stmt->enclosing(); - } - } -} - -} -} - -#endif // frontend_ParseContext_inl_h diff --git a/js/src/frontend/ParseContext.h b/js/src/frontend/ParseContext.h index 04e457f0f8fa..53dee523b115 100644 --- a/js/src/frontend/ParseContext.h +++ b/js/src/frontend/ParseContext.h @@ -7,11 +7,7 @@ #ifndef frontend_ParseContext_h #define frontend_ParseContext_h -#include "ds/Nestable.h" - -#include "frontend/BytecodeCompiler.h" #include "frontend/ErrorReporter.h" -#include "frontend/SharedContext.h" namespace js { @@ -293,10 +289,6 @@ class ParseContext : public Nestable return declared_.acquire(pc->sc()->context); } - bool isEmpty() const { - return declared_->all().empty(); - } - DeclaredNamePtr lookupDeclaredName(JSAtom* name) { return declared_->lookup(name); } @@ -410,7 +402,6 @@ class ParseContext : public Nestable { public: explicit inline VarScope(ParserBase* parser); - explicit inline VarScope(JSContext* cx, ParseContext* pc, UsedNameTracker& usedNames); }; private: @@ -526,7 +517,6 @@ class ParseContext : public Nestable return sc_; } - // `true` if we are in the body of a function definition. bool isFunctionBox() const { return sc_->isFunctionBox(); } @@ -588,22 +578,6 @@ class ParseContext : public Nestable return *closedOverBindingsForLazy_; } - enum class BreakStatementError { - // Unlabeled break must be inside loop or switch. - ToughBreak, - LabelNotFound, - }; - - // Return Err(true) if we have encountered at least one loop, - // Err(false) otherwise. - MOZ_MUST_USE inline JS::Result checkBreakStatement(PropertyName* label); - - enum class ContinueStatementError { - NotInALoop, - LabelNotFound, - }; - MOZ_MUST_USE inline JS::Result checkContinueStatement(PropertyName* label); - // True if we are at the topmost level of a entire script or function body. // For example, while parsing this code we would encounter f1 and f2 at // body level, but we would not encounter f3 or f4 at body level: diff --git a/js/src/frontend/ParseNode.h b/js/src/frontend/ParseNode.h index f5e0e5fe30d7..d068f5580f4d 100644 --- a/js/src/frontend/ParseNode.h +++ b/js/src/frontend/ParseNode.h @@ -13,27 +13,6 @@ #include "frontend/TokenStream.h" #include "vm/Printer.h" -// A few notes on lifetime of ParseNode trees: -// -// - All the `ParseNode` instances MUST BE explicitly allocated in the context's `LifoAlloc`. -// This is typically implemented by the `FullParseHandler` or it can be reimplemented with -// a custom `new_`. -// -// - The tree is bulk-deallocated when the parser is deallocated. Consequently, references -// to a subtree MUST NOT exist once the parser has been deallocated. -// -// - This bulk-deallocation DOES NOT run destructors. -// -// - Instances of `LexicalScope::Data` MUST BE allocated as instances of `ParseNode`, in the same -// `LifoAlloc`. They are bulk-deallocated alongside the rest of the tree. -// -// - Instances of `JSAtom` used throughout the tree (including instances of `PropertyName`) MUST -// be kept alive by the parser. This is done through an instance of `AutoKeepAtoms` held by -// the parser. -// -// - Once the parser is deallocated, the `JSAtom` instances MAY be garbage-collected. - - namespace js { namespace frontend { @@ -619,7 +598,6 @@ class ParseNode appendOrCreateList(ParseNodeKind kind, ParseNode* left, ParseNode* right, FullParseHandler* handler, ParseContext* pc); - // include "ParseNode-inl.h" for these methods. inline PropertyName* name() const; inline JSAtom* atom() const; @@ -753,12 +731,8 @@ class ParseNode } void append(ParseNode* pn) { - MOZ_ASSERT(pn->pn_pos.begin >= pn_pos.begin); - appendWithoutOrderAssumption(pn); - } - - void appendWithoutOrderAssumption(ParseNode* pn) { MOZ_ASSERT(pn_arity == PN_LIST); + MOZ_ASSERT(pn->pn_pos.begin >= pn_pos.begin); pn_pos.end = pn->pn_pos.end; *pn_tail = pn; pn_tail = &pn->pn_next; diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index c89639b50ff9..1bca2fb6524e 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -43,7 +43,6 @@ #include "jsatominlines.h" #include "jsscriptinlines.h" -#include "frontend/ParseContext-inl.h" #include "frontend/ParseNode-inl.h" #include "vm/EnvironmentObject-inl.h" @@ -1720,7 +1719,7 @@ Parser::checkStatementsEOF() } template -typename Scope::Data* +static typename Scope::Data* NewEmptyBindingData(JSContext* cx, LifoAlloc& alloc, uint32_t numBindings) { size_t allocSize = Scope::sizeOfData(numBindings); @@ -1734,9 +1733,8 @@ NewEmptyBindingData(JSContext* cx, LifoAlloc& alloc, uint32_t numBindings) } Maybe -NewGlobalScopeData(JSContext* context, ParseContext::Scope& scope, LifoAlloc& alloc, ParseContext* pc) +ParserBase::newGlobalScopeData(ParseContext::Scope& scope) { - Vector funs(context); Vector vars(context); Vector lets(context); @@ -1799,14 +1797,8 @@ NewGlobalScopeData(JSContext* context, ParseContext::Scope& scope, LifoAlloc& al return Some(bindings); } -Maybe -ParserBase::newGlobalScopeData(ParseContext::Scope& scope) -{ - return NewGlobalScopeData(context, scope, alloc, pc); -} - Maybe -NewModuleScopeData(JSContext* context, ParseContext::Scope& scope, LifoAlloc& alloc, ParseContext* pc) +ParserBase::newModuleScopeData(ParseContext::Scope& scope) { Vector imports(context); Vector vars(context); @@ -1871,14 +1863,8 @@ NewModuleScopeData(JSContext* context, ParseContext::Scope& scope, LifoAlloc& al return Some(bindings); } -Maybe -ParserBase::newModuleScopeData(ParseContext::Scope& scope) -{ - return NewModuleScopeData(context, scope, alloc, pc); -} - Maybe -NewEvalScopeData(JSContext* context, ParseContext::Scope& scope, LifoAlloc& alloc, ParseContext* pc) +ParserBase::newEvalScopeData(ParseContext::Scope& scope) { Vector funs(context); Vector vars(context); @@ -1921,14 +1907,8 @@ NewEvalScopeData(JSContext* context, ParseContext::Scope& scope, LifoAlloc& allo return Some(bindings); } -Maybe -ParserBase::newEvalScopeData(ParseContext::Scope& scope) -{ - return NewEvalScopeData(context, scope, alloc, pc); -} - Maybe -NewFunctionScopeData(JSContext* context, ParseContext::Scope& scope, bool hasParameterExprs, LifoAlloc& alloc, ParseContext* pc) +ParserBase::newFunctionScopeData(ParseContext::Scope& scope, bool hasParameterExprs) { Vector positionalFormals(context); Vector formals(context); @@ -2021,14 +2001,8 @@ NewFunctionScopeData(JSContext* context, ParseContext::Scope& scope, bool hasPar return Some(bindings); } -Maybe -ParserBase::newFunctionScopeData(ParseContext::Scope& scope, bool hasParameterExprs) -{ - return NewFunctionScopeData(context, scope, hasParameterExprs, alloc, pc); -} - Maybe -NewVarScopeData(JSContext* context, ParseContext::Scope& scope, LifoAlloc& alloc, ParseContext* pc) +ParserBase::newVarScopeData(ParseContext::Scope& scope) { Vector vars(context); @@ -2059,14 +2033,8 @@ NewVarScopeData(JSContext* context, ParseContext::Scope& scope, LifoAlloc& alloc return Some(bindings); } -Maybe -ParserBase::newVarScopeData(ParseContext::Scope& scope) -{ - return NewVarScopeData(context, scope, alloc, pc); -} - Maybe -NewLexicalScopeData(JSContext* context, ParseContext::Scope& scope, LifoAlloc& alloc, ParseContext* pc) +ParserBase::newLexicalScopeData(ParseContext::Scope& scope) { Vector lets(context); Vector consts(context); @@ -2116,12 +2084,6 @@ NewLexicalScopeData(JSContext* context, ParseContext::Scope& scope, LifoAlloc& a return Some(bindings); } -Maybe -ParserBase::newLexicalScopeData(ParseContext::Scope& scope) -{ - return NewLexicalScopeData(context, scope, alloc, pc); -} - template SyntaxParseHandler::Node Parser::finishLexicalScope(ParseContext::Scope& scope, Node body) @@ -6586,16 +6548,44 @@ GeneralParser::continueStatement(YieldHandling yieldHandlin if (!matchLabel(yieldHandling, &label)) return null(); - auto validity = pc->checkContinueStatement(label); - if (validity.isErr()) { - switch (validity.unwrapErr()) { - case ParseContext::ContinueStatementError::NotInALoop: - errorAt(begin, JSMSG_BAD_CONTINUE); - break; - case ParseContext::ContinueStatementError::LabelNotFound: - error(JSMSG_LABEL_NOT_FOUND); - break; + // Labeled 'continue' statements target the nearest labeled loop + // statements with the same label. Unlabeled 'continue' statements target + // the innermost loop statement. + auto isLoop = [](ParseContext::Statement* stmt) { + return StatementKindIsLoop(stmt->kind()); + }; + + if (label) { + ParseContext::Statement* stmt = pc->innermostStatement(); + bool foundLoop = false; + + for (;;) { + stmt = ParseContext::Statement::findNearest(stmt, isLoop); + if (!stmt) { + if (foundLoop) + error(JSMSG_LABEL_NOT_FOUND); + else + errorAt(begin, JSMSG_BAD_CONTINUE); + return null(); + } + + foundLoop = true; + + // Is it labeled by our label? + bool foundTarget = false; + stmt = stmt->enclosing(); + while (stmt && stmt->is()) { + if (stmt->as().label() == label) { + foundTarget = true; + break; + } + stmt = stmt->enclosing(); + } + if (foundTarget) + break; } + } else if (!pc->findInnermostStatement(isLoop)) { + error(JSMSG_BAD_CONTINUE); return null(); } diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index eaf500103650..f69b25109cb7 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -49,6 +49,20 @@ public: { } }; +template <> +inline bool +ParseContext::Statement::is() const +{ + return kind_ == StatementKind::Label; +} + +template <> +inline bool +ParseContext::Statement::is() const +{ + return kind_ == StatementKind::Class; +} + template inline T& ParseContext::Statement::as() @@ -257,13 +271,6 @@ ParseContext::VarScope::VarScope(ParserBase* parser) useAsVarScope(parser->pc); } -inline -ParseContext::VarScope::VarScope(JSContext* cx, ParseContext* pc, UsedNameTracker& usedNames) - : Scope(cx, pc, usedNames) -{ - useAsVarScope(pc); -} - enum class ExpressionClosure { Allowed, Forbidden }; template @@ -1282,21 +1289,6 @@ class MOZ_STACK_CLASS AutoAwaitIsKeyword } }; -template -extern typename Scope::Data* -NewEmptyBindingData(JSContext* cx, LifoAlloc& alloc, uint32_t numBindings); - -Maybe -NewGlobalScopeData(JSContext* context, ParseContext::Scope& scope, LifoAlloc& alloc, ParseContext* pc); -Maybe -NewEvalScopeData(JSContext* context, ParseContext::Scope& scope, LifoAlloc& alloc, ParseContext* pc); -Maybe -NewFunctionScopeData(JSContext* context, ParseContext::Scope& scope, bool hasParameterExprs, LifoAlloc& alloc, ParseContext* pc); -Maybe -NewVarScopeData(JSContext* context, ParseContext::Scope& scope, LifoAlloc& alloc, ParseContext* pc); -Maybe -NewLexicalScopeData(JSContext* context, ParseContext::Scope& scope, LifoAlloc& alloc, ParseContext* pc); - } /* namespace frontend */ } /* namespace js */ diff --git a/js/src/frontend/SharedContext.h b/js/src/frontend/SharedContext.h index 56fd3bd5c231..508a7f645ae8 100644 --- a/js/src/frontend/SharedContext.h +++ b/js/src/frontend/SharedContext.h @@ -15,14 +15,12 @@ #include "builtin/ModuleObject.h" #include "ds/InlineTable.h" -#include "frontend/ParseNode.h" #include "frontend/TokenStream.h" #include "vm/EnvironmentObject.h" namespace js { namespace frontend { -class ParseContext; class ParseNode; enum class StatementKind : uint8_t diff --git a/js/src/gc/RootMarking.cpp b/js/src/gc/RootMarking.cpp index ac9e2a2f0a58..c0ee94921941 100644 --- a/js/src/gc/RootMarking.cpp +++ b/js/src/gc/RootMarking.cpp @@ -153,12 +153,6 @@ AutoGCRooter::trace(JSTracer* trc) frontend::TraceParser(trc, this); return; -#if defined(JS_BUILD_BINAST) - case BINPARSER: - frontend::TraceBinParser(trc, this); - return; -#endif // defined(JS_BUILD_BINAST) - case VALARRAY: { /* * We don't know the template size parameter, but we can safely treat it diff --git a/js/src/irregexp/RegExpEngine.cpp b/js/src/irregexp/RegExpEngine.cpp index a34b846cbfcc..10fe9a069ae7 100644 --- a/js/src/irregexp/RegExpEngine.cpp +++ b/js/src/irregexp/RegExpEngine.cpp @@ -2323,8 +2323,7 @@ BoyerMoorePositionInfo::SetInterval(const Interval& interval) } return; } - MOZ_ASSERT(interval.from() <= interval.to()); - for (int i = interval.from(); i != interval.to() + 1; i++) { + for (int i = interval.from(); i <= interval.to(); i++) { int mod_character = (i & kMask); if (!map_[mod_character]) { map_count_++; diff --git a/js/src/jsapi-tests/binast/parser/tester/StrictEquality-001.binjs b/js/src/jsapi-tests/binast/parser/tester/StrictEquality-001.binjs deleted file mode 100644 index 925b6d52d433..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/StrictEquality-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/StrictEquality-001.js b/js/src/jsapi-tests/binast/parser/tester/StrictEquality-001.js deleted file mode 100644 index c96d1be3ef1d..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/StrictEquality-001.js +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: StrictEquality-001.js - * ECMA Section: 11.9.6.js - * Description: - * - * Author: christine@netscape.com - * Date: 4 september 1998 - */ -var SECTION = "StrictEquality-001 - 11.9.6"; -var VERSION = "ECMA_2"; -var TITLE = "The strict equality operator ( === )"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - - -// 1. If Type(x) is different from Type(y) return false - -StrictEquality( true, new Boolean(true), false ); -StrictEquality( new Boolean(), false, false ); -StrictEquality( "", new String(), false ); -StrictEquality( new String("hi"), "hi", false ); - -// 2. If Type(x) is not Number go to step 9. - -// 3. If x is NaN, return false -StrictEquality( NaN, NaN, false ); -StrictEquality( NaN, 0, false ); - -// 4. If y is NaN, return false. -StrictEquality( 0, NaN, false ); - -// 5. if x is the same number value as y, return true - -// 6. If x is +0 and y is -0, return true - -// 7. If x is -0 and y is +0, return true - -// 8. Return false. - - -// 9. If Type(x) is String, then return true if x and y are exactly -// the same sequence of characters ( same length and same characters -// in corresponding positions.) Otherwise return false. - -// 10. If Type(x) is Boolean, return true if x and y are both true or -// both false. otherwise return false. - - -// Return true if x and y refer to the same object. Otherwise return -// false. - -// Return false. - - -test(); - -function StrictEquality( x, y, expect ) { - result = ( x === y ); - - new TestCase( - SECTION, - x +" === " + y, - expect, - result ); -} - diff --git a/js/src/jsapi-tests/binast/parser/tester/apply-001-n.binjs b/js/src/jsapi-tests/binast/parser/tester/apply-001-n.binjs deleted file mode 100644 index f94932cbb4a4..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/apply-001-n.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/apply-001-n.js b/js/src/jsapi-tests/binast/parser/tester/apply-001-n.js deleted file mode 100644 index eac0584461e3..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/apply-001-n.js +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- - * 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/. */ - - -print("STATUS: f.apply crash test."); - -print("BUGNUMBER: 21836"); - -function f () -{ -} - -var SECTION = "apply-001-n"; -var VERSION = "ECMA_1"; -startTest(); -var TITLE = "f.apply(2,2) doesn't crash"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -DESCRIPTION = "f.apply(2,2) doesn't crash"; -EXPECTED = "error"; - -new TestCase( SECTION, "f.apply(2,2) doesn't crash", "error", eval("f.apply(2,2)") ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/boolean-001.binjs b/js/src/jsapi-tests/binast/parser/tester/boolean-001.binjs deleted file mode 100644 index a724010a7b37..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/boolean-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/boolean-001.js b/js/src/jsapi-tests/binast/parser/tester/boolean-001.js deleted file mode 100644 index d2cea72b2913..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/boolean-001.js +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: boolean-001.js - Description: Corresponds to ecma/Boolean/15.6.4.2-4-n.js - - The toString function is not generic; it generates - a runtime error if its this value is not a Boolean - object. Therefore it cannot be transferred to other - kinds of objects for use as a method. - - Author: christine@netscape.com - Date: june 27, 1997 -*/ -var SECTION = "boolean-001.js"; -var VERSION = "JS1_4"; -var TITLE = "Boolean.prototype.toString()"; -startTest(); -writeHeaderToLog( SECTION +" "+ TITLE ); - -var exception = "No exception thrown"; -var result = "Failed"; - -var TO_STRING = Boolean.prototype.toString; - -try { - var s = new String("Not a Boolean"); - s.toString = TO_STRING; - s.toString(); -} catch ( e ) { - result = "Passed!"; - exception = e.toString(); -} - -new TestCase( - SECTION, - "Assigning Boolean.prototype.toString to a String object "+ - "(threw " +exception +")", - "Passed!", - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/boolean-002.binjs b/js/src/jsapi-tests/binast/parser/tester/boolean-002.binjs deleted file mode 100644 index a52b8a39dfdd..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/boolean-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/boolean-002.js b/js/src/jsapi-tests/binast/parser/tester/boolean-002.js deleted file mode 100644 index 8dd55ed6b432..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/boolean-002.js +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: boolean-001.js - Description: Corresponds to ecma/Boolean/15.6.4.3-4-n.js - - 15.6.4.3 Boolean.prototype.valueOf() - Returns this boolean value. - - The valueOf function is not generic; it generates - a runtime error if its this value is not a Boolean - object. Therefore it cannot be transferred to other - kinds of objects for use as a method. - - Author: christine@netscape.com - Date: 09 september 1998 -*/ -var SECTION = "boolean-002.js"; -var VERSION = "JS1_4"; -var TITLE = "Boolean.prototype.valueOf()"; -startTest(); -writeHeaderToLog( SECTION +" "+ TITLE ); - - -var exception = "No exception thrown"; -var result = "Failed"; - -var VALUE_OF = Boolean.prototype.valueOf; - -try { - var s = new String("Not a Boolean"); - s.valueOf = VALUE_0F; - s.valueOf(); -} catch ( e ) { - result = "Passed!"; - exception = e.toString(); -} - -new TestCase( - SECTION, - "Assigning Boolean.prototype.valueOf to a String object "+ - "(threw " +exception +")", - "Passed!", - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/call-1.binjs b/js/src/jsapi-tests/binast/parser/tester/call-1.binjs deleted file mode 100644 index c695c8be4ef5..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/call-1.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/call-1.js b/js/src/jsapi-tests/binast/parser/tester/call-1.js deleted file mode 100644 index 9ff19555e8a6..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/call-1.js +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: call-1.js - Section: Function.prototype.call - Description: - - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "call-1"; -var VERSION = "ECMA_2"; -var TITLE = "Function.prototype.call"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -new TestCase( SECTION, - "ConvertToString.call(this, this)", - GLOBAL, - ConvertToString.call(this, this)); - -new TestCase( SECTION, - "ConvertToString.call(Boolean, Boolean.prototype)", - "false", - ConvertToString.call(Boolean, Boolean.prototype)); - -new TestCase( SECTION, - "ConvertToString.call(Boolean, Boolean.prototype.valueOf())", - "false", - ConvertToString.call(Boolean, Boolean.prototype.valueOf())); - -test(); - -function ConvertToString(obj) { - return obj +""; -} diff --git a/js/src/jsapi-tests/binast/parser/tester/constructor-001.binjs b/js/src/jsapi-tests/binast/parser/tester/constructor-001.binjs deleted file mode 100644 index 0fb83e3759f8..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/constructor-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/constructor-001.js b/js/src/jsapi-tests/binast/parser/tester/constructor-001.js deleted file mode 100644 index b268ae5ed099..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/constructor-001.js +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: RegExp/constructor-001.js - * ECMA Section: 15.7.3.3 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/constructor-001"; -var VERSION = "ECMA_2"; -var TITLE = "new RegExp()"; - -startTest(); - -/* - * for each test case, verify: - * - verify that [[Class]] property is RegExp - * - prototype property should be set to RegExp.prototype - * - source is set to the empty string - * - global property is set to false - * - ignoreCase property is set to false - * - multiline property is set to false - * - lastIndex property is set to 0 - */ - -RegExp.prototype.getClassProperty = Object.prototype.toString; -var re = new RegExp(); - -AddTestCase( - "RegExp.prototype.getClassProperty = Object.prototype.toString; " + - "(new RegExp()).getClassProperty()", - "[object RegExp]", - re.getClassProperty() ); - -AddTestCase( - "(new RegExp()).source", - "(?:)", - re.source ); - -AddTestCase( - "(new RegExp()).global", - false, - re.global ); - -AddTestCase( - "(new RegExp()).ignoreCase", - false, - re.ignoreCase ); - -AddTestCase( - "(new RegExp()).multiline", - false, - re.multiline ); - -AddTestCase( - "(new RegExp()).lastIndex", - 0, - re.lastIndex ); - -test() diff --git a/js/src/jsapi-tests/binast/parser/tester/date-002.binjs b/js/src/jsapi-tests/binast/parser/tester/date-002.binjs deleted file mode 100644 index f79e4756def1..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/date-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/date-002.js b/js/src/jsapi-tests/binast/parser/tester/date-002.js deleted file mode 100644 index 0f379b541276..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/date-002.js +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: date-002.js - Corresponds To: 15.9.5.23-3-n.js - ECMA Section: 15.9.5.23 - Description: Date.prototype.setTime - - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "date-002"; -var VERSION = "JS1_4"; -var TITLE = "Date.prototype.setTime()"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var MYDATE = new MyDate(); - result = MYDATE.setTime(0); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "MYDATE = new MyDate(); MYDATE.setTime(0)" + - " (threw " + exception +")", - expect, - result ); - -test(); - -function MyDate(value) { - this.value = value; - this.setTime = Date.prototype.setTime; - return this; -} diff --git a/js/src/jsapi-tests/binast/parser/tester/date-003.binjs b/js/src/jsapi-tests/binast/parser/tester/date-003.binjs deleted file mode 100644 index 206cfa318f41..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/date-003.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/date-003.js b/js/src/jsapi-tests/binast/parser/tester/date-003.js deleted file mode 100644 index f8f48c6992f2..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/date-003.js +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: date-003.js - Corresponds To 15.9.5.3-1.js - ECMA Section: 15.9.5.3-1 Date.prototype.valueOf - Description: - - The valueOf function returns a number, which is this time value. - - The valueOf function is not generic; it generates a runtime error if - its this value is not a Date object. Therefore it cannot be transferred - to other kinds of objects for use as a method. - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "date-003"; -var VERSION = "JS1_4"; -var TITLE = "Date.prototype.valueOf"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var OBJ = new MyObject( new Date(0) ); - result = OBJ.valueOf(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "OBJ = new MyObject( new Date(0)); OBJ.valueOf()" + - " (threw " + exception +")", - expect, - result ); - -test(); - -function MyObject( value ) { - this.value = value; - this.valueOf = Date.prototype.valueOf; -// The following line causes an infinte loop -// this.toString = new Function( "return this+\"\";"); - return this; -} diff --git a/js/src/jsapi-tests/binast/parser/tester/date-004.binjs b/js/src/jsapi-tests/binast/parser/tester/date-004.binjs deleted file mode 100644 index 75e32116f50b..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/date-004.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/date-004.js b/js/src/jsapi-tests/binast/parser/tester/date-004.js deleted file mode 100644 index fd8733cbddcc..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/date-004.js +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: date-004.js - Corresponds To: 15.9.5.4-2-n.js - ECMA Section: 15.9.5.4-1 Date.prototype.getTime - Description: - - 1. If the this value is not an object whose [[Class]] property is "Date", - generate a runtime error. - 2. Return this time value. - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "date-004"; -var VERSION = "JS1_4"; -var TITLE = "Date.prototype.getTime"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var MYDATE = new MyDate(); - result = MYDATE.getTime(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "MYDATE = new MyDate(); MYDATE.getTime()" + - " (threw " + exception +")", - expect, - result ); - -test(); - -function MyDate( value ) { - this.value = value; - this.getTime = Date.prototype.getTime; -} diff --git a/js/src/jsapi-tests/binast/parser/tester/dowhile-001.binjs b/js/src/jsapi-tests/binast/parser/tester/dowhile-001.binjs deleted file mode 100644 index c606d8345fbf..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/dowhile-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/dowhile-001.js b/js/src/jsapi-tests/binast/parser/tester/dowhile-001.js deleted file mode 100644 index d9a7a033df04..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/dowhile-001.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: dowhile-001 - * ECMA Section: - * Description: do...while statements - * - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "dowhile-002"; -var VERSION = "ECMA_2"; -var TITLE = "do...while with a labeled continue statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -LabeledContinue( 0, 1 ); -LabeledContinue( 1, 1 ); -LabeledContinue( -1, 1 ); -LabeledContinue( 5, 5 ); - -test(); - -function LabeledContinue( limit, expect ) { - i = 0; -woohoo: - do { - i++; - continue woohoo; - } while ( i < limit ); - - new TestCase( - SECTION, - "do while ( " + i +" < " + limit +" )", - expect, - i ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/dowhile-002.binjs b/js/src/jsapi-tests/binast/parser/tester/dowhile-002.binjs deleted file mode 100644 index 9b80e1fcd76b..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/dowhile-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/dowhile-002.js b/js/src/jsapi-tests/binast/parser/tester/dowhile-002.js deleted file mode 100644 index e25557e70bcc..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/dowhile-002.js +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: dowhile-002 - * ECMA Section: - * Description: do...while statements - * - * Verify that code after a labeled break is not executed. Verify that - * a labeled break breaks you out of the whole labeled block, and not - * just the current iteration statement. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "dowhile-002"; -var VERSION = "ECMA_2"; -var TITLE = "do...while with a labeled continue statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -LabeledContinue( 0, 1 ); -LabeledContinue( 1, 1 ); -LabeledContinue( -1, 1 ); -LabeledContinue( 5, 5 ); - -test(); - -// The labeled statement contains statements after the labeled break. -// Verify that the statements after the break are not executed. - -function LabeledContinue( limit, expect ) { - i = 0; - result1 = "pass"; - result2 = "pass"; - -woohoo: { - do { - i++; - if ( ! (i < limit) ) { - break woohoo; - result1 = "fail: evaluated statement after a labeled break"; - } - } while ( true ); - - result2 = "failed: broke out of loop, but not out of labeled block"; - } - - new TestCase( - SECTION, - "do while ( " + i +" < " + limit +" )", - expect, - i ); - - new TestCase( - SECTION, - "breaking out of a do... while loop", - "pass", - result1 ); - - - new TestCase( - SECTION, - "breaking out of a labeled do...while loop", - "pass", - result2 ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/dowhile-003.binjs b/js/src/jsapi-tests/binast/parser/tester/dowhile-003.binjs deleted file mode 100644 index 57436770bd00..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/dowhile-003.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/dowhile-003.js b/js/src/jsapi-tests/binast/parser/tester/dowhile-003.js deleted file mode 100644 index b482823e12f9..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/dowhile-003.js +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: dowhile-003 - * ECMA Section: - * Description: do...while statements - * - * Test do while, when the while expression is a JavaScript Number object. - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "dowhile-003"; -var VERSION = "ECMA_2"; -var TITLE = "do...while with a labeled continue statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile( new DoWhileObject( 1, 1, 0 )); -DoWhile( new DoWhileObject( 1000, 1000, 0 )); -DoWhile( new DoWhileObject( 1001, 1001, 0 )); -DoWhile( new DoWhileObject( 1002, 1001, 1 )); -DoWhile( new DoWhileObject( -1, 1001, -1002 )); - -test(); - -function DoWhileObject( value, iterations, endvalue ) { - this.value = value; - this.iterations = iterations; - this.endvalue = endvalue; -} - -function DoWhile( object ) { - var i = 0; - - do { - object.value = --object.value; - i++; - if ( i > 1000 ) - break; - } while( object.value ); - - new TestCase( - SECTION, - "loop iterations", - object.iterations, - i - ); - - new TestCase( - SECTION, - "object.value", - object.endvalue, - Number( object.value ) - ); - -} diff --git a/js/src/jsapi-tests/binast/parser/tester/dowhile-004.binjs b/js/src/jsapi-tests/binast/parser/tester/dowhile-004.binjs deleted file mode 100644 index e2b7f4de99b5..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/dowhile-004.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/dowhile-004.js b/js/src/jsapi-tests/binast/parser/tester/dowhile-004.js deleted file mode 100644 index 90e376fdee86..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/dowhile-004.js +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: dowhile-004 - * ECMA Section: - * Description: do...while statements - * - * Test a labeled do...while. Break out of the loop with no label - * should break out of the loop, but not out of the label. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "dowhile-004"; -var VERSION = "ECMA_2"; -var TITLE = "do...while with a labeled continue statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile( 0, 1 ); -DoWhile( 1, 1 ); -DoWhile( -1, 1 ); -DoWhile( 5, 5 ); - -test(); - -function DoWhile( limit, expect ) { - i = 0; - result1 = "pass"; - result2 = "failed: broke out of labeled statement unexpectedly"; - -foo: { - do { - i++; - if ( ! (i < limit) ) { - break; - result1 = "fail: evaluated statement after a labeled break"; - } - } while ( true ); - - result2 = "pass"; - } - - new TestCase( - SECTION, - "do while ( " + i +" < " + limit +" )", - expect, - i ); - - new TestCase( - SECTION, - "breaking out of a do... while loop", - "pass", - result1 ); - - - new TestCase( - SECTION, - "breaking out of a labeled do...while loop", - "pass", - result2 ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/dowhile-005.binjs b/js/src/jsapi-tests/binast/parser/tester/dowhile-005.binjs deleted file mode 100644 index 3e1e3c360f29..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/dowhile-005.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/dowhile-005.js b/js/src/jsapi-tests/binast/parser/tester/dowhile-005.js deleted file mode 100644 index 3c339f493a0b..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/dowhile-005.js +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: dowhile-005 - * ECMA Section: - * Description: do...while statements - * - * Test a labeled do...while. Break out of the loop with no label - * should break out of the loop, but not out of the label. - * - * Currently causes an infinite loop in the monkey. Uncomment the - * print statement below and it works OK. - * - * Author: christine@netscape.com - * Date: 26 August 1998 - */ -var SECTION = "dowhile-005"; -var VERSION = "ECMA_2"; -var TITLE = "do...while with a labeled continue statement"; -var BUGNUMBER = "316293"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -NestedLabel(); - - -test(); - -function NestedLabel() { - i = 0; - result1 = "pass"; - result2 = "fail: did not hit code after inner loop"; - result3 = "pass"; - -outer: { - do { - inner: { -// print( i ); - break inner; - result1 = "fail: did break out of inner label"; - } - result2 = "pass"; - break outer; - print(i); - } while ( i++ < 100 ); - - } - - result3 = "fail: did not break out of outer label"; - - new TestCase( - SECTION, - "number of loop iterations", - 0, - i ); - - new TestCase( - SECTION, - "break out of inner loop", - "pass", - result1 ); - - new TestCase( - SECTION, - "break out of outer loop", - "pass", - result2 ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/dowhile-006.binjs b/js/src/jsapi-tests/binast/parser/tester/dowhile-006.binjs deleted file mode 100644 index 7ab5fde07057..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/dowhile-006.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/dowhile-006.js b/js/src/jsapi-tests/binast/parser/tester/dowhile-006.js deleted file mode 100644 index 0a1aa701a68c..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/dowhile-006.js +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: dowhile-006 - * ECMA Section: - * Description: do...while statements - * - * A general do...while test. - * - * Author: christine@netscape.com - * Date: 26 August 1998 - */ -var SECTION = "dowhile-006"; -var VERSION = "ECMA_2"; -var TITLE = "do...while"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile( new DoWhileObject( false, false, 10 ) ); -DoWhile( new DoWhileObject( true, false, 2 ) ); -DoWhile( new DoWhileObject( false, true, 3 ) ); -DoWhile( new DoWhileObject( true, true, 4 ) ); - -test(); - -function looping( object ) { - object.iterations--; - - if ( object.iterations <= 0 ) { - return false; - } else { - return true; - } -} -function DoWhileObject( breakOut, breakIn, iterations, loops ) { - this.iterations = iterations; - this.loops = loops; - this.breakOut = breakOut; - this.breakIn = breakIn; - this.looping = looping; -} -function DoWhile( object ) { - var result1 = false; - var result2 = false; - -outie: { - innie: { - do { - if ( object.breakOut ) - break outie; - - if ( object.breakIn ) - break innie; - - } while ( looping(object) ); - - // statements should be executed if: - // do...while exits normally - // do...while exits abruptly with no label - - result1 = true; - - } - -// statements should be executed if: -// do...while breaks out with label "innie" -// do...while exits normally -// do...while does not break out with "outie" - - result2 = true; - } - - new TestCase( - SECTION, - "hit code after loop in inner loop", - ( object.breakIn || object.breakOut ) ? false : true , - result1 ); - - new TestCase( - SECTION, - "hit code after loop in outer loop", - ( object.breakOut ) ? false : true, - result2 ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/dowhile-007.binjs b/js/src/jsapi-tests/binast/parser/tester/dowhile-007.binjs deleted file mode 100644 index 6e4eae5cd16f..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/dowhile-007.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/dowhile-007.js b/js/src/jsapi-tests/binast/parser/tester/dowhile-007.js deleted file mode 100644 index 44adbcafd988..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/dowhile-007.js +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: dowhile-007 - * ECMA Section: - * Description: do...while statements - * - * A general do...while test. - * - * Author: christine@netscape.com - * Date: 26 August 1998 - */ -var SECTION = "dowhile-007"; -var VERSION = "ECMA_2"; -var TITLE = "do...while"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile( new DoWhileObject( false, false, false, false )); -DoWhile( new DoWhileObject( true, false, false, false )); -DoWhile( new DoWhileObject( true, true, false, false )); -DoWhile( new DoWhileObject( true, true, true, false )); -DoWhile( new DoWhileObject( true, true, true, true )); -DoWhile( new DoWhileObject( false, false, false, true )); -DoWhile( new DoWhileObject( false, false, true, true )); -DoWhile( new DoWhileObject( false, true, true, true )); -DoWhile( new DoWhileObject( false, false, true, false )); - -test(); - -function DoWhileObject( out1, out2, out3, in1 ) { - this.breakOutOne = out1; - this.breakOutTwo = out2; - this.breakOutThree = out3; - this.breakIn = in1; -} -function DoWhile( object ) { - result1 = false; - result2 = false; - result3 = false; - result4 = false; - -outie: - do { - if ( object.breakOutOne ) { - break outie; - } - result1 = true; - - innie: - do { - if ( object.breakOutTwo ) { - break outie; - } - result2 = true; - - if ( object.breakIn ) { - break innie; - } - result3 = true; - - } while ( false ); - if ( object.breakOutThree ) { - break outie; - } - result4 = true; - } while ( false ); - - new TestCase( - SECTION, - "break one: ", - (object.breakOutOne) ? false : true, - result1 ); - - new TestCase( - SECTION, - "break two: ", - (object.breakOutOne||object.breakOutTwo) ? false : true, - result2 ); - - new TestCase( - SECTION, - "break three: ", - (object.breakOutOne||object.breakOutTwo||object.breakIn) ? false : true, - result3 ); - - new TestCase( - SECTION, - "break four: ", - (object.breakOutOne||object.breakOutTwo||object.breakOutThree) ? false: true, - result4 ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-001.binjs b/js/src/jsapi-tests/binast/parser/tester/exception-001.binjs deleted file mode 100644 index 8ab757348fe2..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/exception-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-001.js b/js/src/jsapi-tests/binast/parser/tester/exception-001.js deleted file mode 100644 index 987ba0af888b..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/exception-001.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: exception-001 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * Call error. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-001"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: CallError"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -Call_1(); - -test(); - -function Call_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - Math(); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "Math() [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} - diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-002.binjs b/js/src/jsapi-tests/binast/parser/tester/exception-002.binjs deleted file mode 100644 index 2a03114aa349..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/exception-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-002.js b/js/src/jsapi-tests/binast/parser/tester/exception-002.js deleted file mode 100644 index 74ce79a96b2d..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/exception-002.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: exception-002 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * Construct error. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-002"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: ConstructError"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -Construct_1(); - -test(); - -function Construct_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = new Math(); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "new Math() [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} - diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-003.binjs b/js/src/jsapi-tests/binast/parser/tester/exception-003.binjs deleted file mode 100644 index f7fe5ad49b04..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/exception-003.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-003.js b/js/src/jsapi-tests/binast/parser/tester/exception-003.js deleted file mode 100644 index 7bc02a627920..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/exception-003.js +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: exception-003 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * Target error. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-003"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: TargetError"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -Target_1(); - -test(); - -function Target_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - string = new String("hi"); - string.toString = Boolean.prototype.toString; - string.toString(); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "string = new String(\"hi\");"+ - "string.toString = Boolean.prototype.toString" + - "string.toString() [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} - diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-004.binjs b/js/src/jsapi-tests/binast/parser/tester/exception-004.binjs deleted file mode 100644 index c8b2db4aad27..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/exception-004.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-004.js b/js/src/jsapi-tests/binast/parser/tester/exception-004.js deleted file mode 100644 index 41b7ac3aa4ec..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/exception-004.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: exception-004 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * ToObject error. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-004"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -ToObject_1(); - -test(); - -function ToObject_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = foo["bar"]; - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "foo[\"bar\"] [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} - diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-005.binjs b/js/src/jsapi-tests/binast/parser/tester/exception-005.binjs deleted file mode 100644 index 7bb22fc467a9..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/exception-005.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-005.js b/js/src/jsapi-tests/binast/parser/tester/exception-005.js deleted file mode 100644 index 152aebe4be38..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/exception-005.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: exception-005 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * ToObject error. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-005"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -ToObject_1(); - -test(); - -function ToObject_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = foo["bar"]; - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "foo[\"bar\"] [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} - diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-006.binjs b/js/src/jsapi-tests/binast/parser/tester/exception-006.binjs deleted file mode 100644 index 6413d212c5b6..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/exception-006.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-006.js b/js/src/jsapi-tests/binast/parser/tester/exception-006.js deleted file mode 100644 index cf9df729c827..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/exception-006.js +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: exception-006 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * ToPrimitive error. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-006"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: TypeError"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -ToPrimitive_1(); - -test(); - - -/** - * Getting the [[DefaultValue]] of any instances of MyObject - * should result in a runtime error in ToPrimitive. - */ - -function MyObject() { - this.toString = void 0; - this.valueOf = void 0; -} - -function ToPrimitive_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = new MyObject() + new MyObject(); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "new MyObject() + new MyObject() [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} - diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-007.binjs b/js/src/jsapi-tests/binast/parser/tester/exception-007.binjs deleted file mode 100644 index 163354107106..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/exception-007.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-007.js b/js/src/jsapi-tests/binast/parser/tester/exception-007.js deleted file mode 100644 index bae0027b5ce7..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/exception-007.js +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: exception-007 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * DefaultValue error. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-007"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: TypeError"; -var BUGNUMBER="318250"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DefaultValue_1(); - -test(); - - -/** - * Getting the [[DefaultValue]] of any instances of MyObject - * should result in a runtime error in ToPrimitive. - */ - -function MyObject() { - this.toString = void 0; - this.valueOf = new Object(); -} - -function DefaultValue_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = new MyObject() + new MyObject(); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "new MyObject() + new MyObject() [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} - diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-008.binjs b/js/src/jsapi-tests/binast/parser/tester/exception-008.binjs deleted file mode 100644 index 9e6209ca5591..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/exception-008.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-008.js b/js/src/jsapi-tests/binast/parser/tester/exception-008.js deleted file mode 100644 index f7efa9fb495d..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/exception-008.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: exception-008 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * SyntaxError. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-008"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -Syntax_1(); - -test(); - -function Syntax_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = eval("continue;"); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "eval(\"continue\") [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-009.binjs b/js/src/jsapi-tests/binast/parser/tester/exception-009.binjs deleted file mode 100644 index d53a931f8fb5..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/exception-009.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-009.js b/js/src/jsapi-tests/binast/parser/tester/exception-009.js deleted file mode 100644 index 1229bf561444..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/exception-009.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: exception-009 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * Regression test for nested try blocks. - * - * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=312964 - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-009"; -var VERSION = "JS1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError"; -var BUGNUMBER= "312964"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -try { - expect = "passed: no exception thrown"; - result = expect; - Nested_1(); -} catch ( e ) { - result = "failed: threw " + e; -} finally { - new TestCase( - SECTION, - "nested try", - expect, - result ); -} - - -test(); - -function Nested_1() { - try { - try { - } catch (a) { - } finally { - } - } catch (b) { - } finally { - } -} diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-010-n.binjs b/js/src/jsapi-tests/binast/parser/tester/exception-010-n.binjs deleted file mode 100644 index d6bb139bdc18..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/exception-010-n.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-010-n.js b/js/src/jsapi-tests/binast/parser/tester/exception-010-n.js deleted file mode 100644 index 46fe72fddb23..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/exception-010-n.js +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- - * 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 SECTION = "exception-010"; -var VERSION = "ECMA_2"; -startTest(); -var TITLE = "Don't Crash throwing null"; - -writeHeaderToLog( SECTION + " "+ TITLE); -print("Null throw test."); -print("BUGNUMBER: 21799"); - -DESCRIPTION = "throw null"; -EXPECTED = "error"; - -new TestCase( SECTION, "throw null", "error", eval("throw null" )); - -test(); - -print("FAILED!: Should have exited with uncaught exception."); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-011-n.binjs b/js/src/jsapi-tests/binast/parser/tester/exception-011-n.binjs deleted file mode 100644 index 8397356dc8f4..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/exception-011-n.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/exception-011-n.js b/js/src/jsapi-tests/binast/parser/tester/exception-011-n.js deleted file mode 100644 index 17f19723db73..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/exception-011-n.js +++ /dev/null @@ -1,26 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- - * 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 SECTION = "exception-011"; -var VERSION = "ECMA_2"; -startTest(); -var TITLE = "Don't Crash throwing undefined"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -print("Undefined throw test."); - -DESCRIPTION = "throw undefined"; -EXPECTED = "error"; - -new TestCase( SECTION, "throw undefined", "error", eval("throw (void 0)") ); - -test(); - -print("FAILED!: Should have exited with uncaught exception."); - - - diff --git a/js/src/jsapi-tests/binast/parser/tester/exec-002.binjs b/js/src/jsapi-tests/binast/parser/tester/exec-002.binjs deleted file mode 100644 index bb8d1ab9678f..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/exec-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/exec-002.js b/js/src/jsapi-tests/binast/parser/tester/exec-002.js deleted file mode 100644 index 86d8ccb9a59b..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/exec-002.js +++ /dev/null @@ -1,188 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: RegExp/exec-002.js - * ECMA Section: 15.7.5.3 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Test cases provided by rogerl@netscape.com - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/exec-002"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp.prototype.exec(string)"; - -startTest(); - -/* - * for each test case, verify: - * - type of object returned - * - length of the returned array - * - value of lastIndex - * - value of index - * - value of input - * - value of the array indices - */ - -AddRegExpCases( - /(a|d|q|)x/i, - "bcaDxqy", - 3, - ["Dx", "D"] ); - -AddRegExpCases( - /(a|(e|q))(x|y)/, - "bcaddxqy", - 6, - ["qy","q","q","y"] ); - - -AddRegExpCases( - /a+b+d/, - "aabbeeaabbs", - 0, - null ); - -AddRegExpCases( - /a*b/, - "aaadaabaaa", - 4, - ["aab"] ); - -AddRegExpCases( - /a*b/, - "dddb", - 3, - ["b"] ); - -AddRegExpCases( - /a*b/, - "xxx", - 0, - null ); - -AddRegExpCases( - /x\d\dy/, - "abcx45ysss235", - 3, - ["x45y"] ); - -AddRegExpCases( - /[^abc]def[abc]+/, - "abxdefbb", - 2, - ["xdefbb"] ); - -AddRegExpCases( - /(a*)baa/, - "ccdaaabaxaabaa", - 9, - ["aabaa", "aa"] ); - -AddRegExpCases( - /(a*)baa/, - "aabaa", - 0, - ["aabaa", "aa"] ); - -AddRegExpCases( - /q(a|b)*q/, - "xxqababqyy", - 2, - ["qababq", "b"] ); - -AddRegExpCases( - /(a(.|[^d])c)*/, - "adcaxc", - 0, - ["adcaxc", "axc", "x"] ); - -AddRegExpCases( - /(a*)b\1/, - "abaaaxaabaayy", - 0, - ["aba", "a"] ); - -AddRegExpCases( - /(a*)b\1/, - "abaaaxaabaayy", - 0, - ["aba", "a"] ); - -AddRegExpCases( - /(a*)b\1/, - "cccdaaabaxaabaayy", - 6, - ["aba", "a"] ); - -AddRegExpCases( - /(a*)b\1/, - "cccdaaabqxaabaayy", - 7, - ["b", ""] ); - -AddRegExpCases( - /"(.|[^"\\\\])*"/, - 'xx\"makudonarudo\"yy', - 2, - ["\"makudonarudo\"", "o"] ); - - AddRegExpCases( - /"(.|[^"\\\\])*"/, - "xx\"ma\"yy", - 2, - ["\"ma\"", "a"] ); - - test(); - - function AddRegExpCases( - regexp, pattern, index, matches_array ) { - -// prevent a runtime error - - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } - AddTestCase( - regexp + ".exec(" + pattern +").length", - matches_array.length, - regexp.exec(pattern).length ); - - AddTestCase( - regexp + ".exec(" + pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - regexp + ".exec(" + pattern +").input", - pattern, - regexp.exec(pattern).input ); - - AddTestCase( - regexp + ".exec(" + pattern +").toString()", - matches_array.toString(), - regexp.exec(pattern).toString() ); -/* - var limit = matches_array.length > regexp.exec(pattern).length - ? matches_array.length - : regexp.exec(pattern).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - regexp + ".exec(" + pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } -*/ - } diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-001.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-001.binjs deleted file mode 100644 index bbc38b49e83c..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-001.js b/js/src/jsapi-tests/binast/parser/tester/expression-001.js deleted file mode 100644 index 90b44839ffc6..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-001.js +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-001.js - Corresponds to: ecma/Expressions/11.12-2-n.js - ECMA Section: 11.12 - Description: - - The grammar for a ConditionalExpression in ECMAScript is a little bit - different from that in C and Java, which each allow the second - subexpression to be an Expression but restrict the third expression to - be a ConditionalExpression. The motivation for this difference in - ECMAScript is to allow an assignment expression to be governed by either - arm of a conditional and to eliminate the confusing and fairly useless - case of a comma expression as the center expression. - - Author: christine@netscape.com - Date: 09 september 1998 -*/ -var SECTION = "expression-001"; -var VERSION = "JS1_4"; -var TITLE = "Conditional operator ( ? : )" - startTest(); -writeHeaderToLog( SECTION + " " + TITLE ); - -// the following expression should be an error in JS. - -var result = "Failed" - var exception = "No exception was thrown"; - -try { - eval("var MY_VAR = true ? \"EXPR1\", \"EXPR2\" : \"EXPR3\""); -} catch ( e ) { - result = "Passed"; - exception = e.toString(); -} - -new TestCase( - SECTION, - "comma expression in a conditional statement "+ - "(threw "+ exception +")", - "Passed", - result ); - - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-002.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-002.binjs deleted file mode 100644 index a4cf82517a88..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-002.js b/js/src/jsapi-tests/binast/parser/tester/expression-002.js deleted file mode 100644 index 0110f23b774d..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-002.js +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expressions-002.js - Corresponds to: ecma/Expressions/11.2.1-3-n.js - ECMA Section: 11.2.1 Property Accessors - Description: - - Try to access properties of an object whose value is undefined. - - Author: christine@netscape.com - Date: 09 september 1998 -*/ -var SECTION = "expressions-002.js"; -var VERSION = "JS1_4"; -var TITLE = "Property Accessors"; -writeHeaderToLog( SECTION + " "+TITLE ); - -startTest(); - -// go through all Native Function objects, methods, and properties and get their typeof. - -var PROPERTY = new Array(); -var p = 0; - -// try to access properties of primitive types - -OBJECT = new Property( "undefined", void 0, "undefined", NaN ); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = OBJECT.value.valueOf(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - - -new TestCase( - SECTION, - "Get the value of an object whose value is undefined "+ - "(threw " + exception +")", - expect, - result ); - -test(); - -function Property( object, value, string, number ) { - this.object = object; - this.string = String(value); - this.number = Number(value); - this.valueOf = value; -} diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-003.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-003.binjs deleted file mode 100644 index dc2656b14bf3..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-003.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-003.js b/js/src/jsapi-tests/binast/parser/tester/expression-003.js deleted file mode 100644 index ba5f9c076970..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-003.js +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expressions-003.js - Corresponds to: ecma/Expressions/11.2.1-3-n.js - ECMA Section: 11.2.1 Property Accessors - Description: - - Try to access properties of an object whose value is undefined. - - Author: christine@netscape.com - Date: 09 september 1998 -*/ -var SECTION = "expressions-003.js"; -var VERSION = "JS1_4"; -var TITLE = "Property Accessors"; -writeHeaderToLog( SECTION + " "+TITLE ); - -startTest(); - -// try to access properties of primitive types - -OBJECT = new Property( "undefined", void 0, "undefined", NaN ); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = OBJECT.value.toString(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - - -new TestCase( - SECTION, - "Get the toString value of an object whose value is undefined "+ - "(threw " + exception +")", - expect, - result ); - -test(); - -function Property( object, value, string, number ) { - this.object = object; - this.string = String(value); - this.number = Number(value); - this.value = value; -} diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-004.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-004.binjs deleted file mode 100644 index 2a5ba62ca9bb..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-004.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-004.js b/js/src/jsapi-tests/binast/parser/tester/expression-004.js deleted file mode 100644 index 5bf19d9e5f21..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-004.js +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-004.js - Corresponds To: 11.2.1-4-n.js - ECMA Section: 11.2.1 Property Accessors - Description: - - Author: christine@netscape.com - Date: 09 september 1998 -*/ -var SECTION = "expression-004"; -var VERSION = "JS1_4"; -var TITLE = "Property Accessors"; -writeHeaderToLog( SECTION + " "+TITLE ); -startTest(); - -var OBJECT = new Property( "null", null, "null", 0 ); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = OBJECT.value.toString(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "Get the toString value of an object whose value is null "+ - "(threw " + exception +")", - expect, - result ); - -test(); - -function Property( object, value, string, number ) { - this.object = object; - this.string = String(value); - this.number = Number(value); - this.value = value; -} diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-005.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-005.binjs deleted file mode 100644 index 16c76c4bf702..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-005.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-005.js b/js/src/jsapi-tests/binast/parser/tester/expression-005.js deleted file mode 100644 index c1e76b7c63fa..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-005.js +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-005.js - Corresponds To: 11.2.2-10-n.js - ECMA Section: 11.2.2. The new operator - Description: - - Author: christine@netscape.com - Date: 12 november 1997 -*/ - -var SECTION = "expression-005"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var expect = "Passed"; -var exception = "No exception thrown"; - -try { - result = new Math(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "result= new Math() (threw " + exception + ")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-006.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-006.binjs deleted file mode 100644 index d19dd551a8d2..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-006.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-006.js b/js/src/jsapi-tests/binast/parser/tester/expression-006.js deleted file mode 100644 index 2ab13479a1f0..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-006.js +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-006.js - Corresponds to: 11.2.2-1-n.js - ECMA Section: 11.2.2. The new operator - Description: - - http://scopus/bugsplat/show_bug.cgi?id=327765 - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-006.js"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; -var BUGNUMBER="327765"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var OBJECT = new Object(); - result = new OBJECT(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "OBJECT = new Object; result = new OBJECT()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-007.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-007.binjs deleted file mode 100644 index 39c1bbdedc64..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-007.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-007.js b/js/src/jsapi-tests/binast/parser/tester/expression-007.js deleted file mode 100644 index 3e01e0d8c90a..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-007.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-007.js - Corresponds To: 11.2.2-2-n.js - ECMA Section: 11.2.2. The new operator - Description: - - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-007"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - UNDEFINED = void 0; - result = new UNDEFINED(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "UNDEFINED = void 0; result = new UNDEFINED()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-008.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-008.binjs deleted file mode 100644 index f09c68a792ac..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-008.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-008.js b/js/src/jsapi-tests/binast/parser/tester/expression-008.js deleted file mode 100644 index caf310195bc1..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-008.js +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-008 - Corresponds To: 11.2.2-3-n.js - ECMA Section: 11.2.2. The new operator - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-008"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var NULL = null; -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = new NULL(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "NULL = null; result = new NULL()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-009.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-009.binjs deleted file mode 100644 index 392209cb016b..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-009.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-009.js b/js/src/jsapi-tests/binast/parser/tester/expression-009.js deleted file mode 100644 index 9a997d7fbb25..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-009.js +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-009 - Corresponds to: ecma/Expressions/11.2.2-4-n.js - ECMA Section: 11.2.2. The new operator - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-009"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var STRING = ""; - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = new STRING(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "STRING = ''; result = new STRING()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-010.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-010.binjs deleted file mode 100644 index 988918403d22..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-010.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-010.js b/js/src/jsapi-tests/binast/parser/tester/expression-010.js deleted file mode 100644 index f8ad983cc480..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-010.js +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-010.js - Corresponds To: 11.2.2-5-n.js - ECMA Section: 11.2.2. The new operator - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-010"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var NUMBER = 0; - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = new NUMBER(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "NUMBER=0, result = new NUMBER()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-011.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-011.binjs deleted file mode 100644 index b61edd52d209..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-011.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-011.js b/js/src/jsapi-tests/binast/parser/tester/expression-011.js deleted file mode 100644 index 8337b9b76b95..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-011.js +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-011.js - Corresponds To: ecma/Expressions/11.2.2-6-n.js - ECMA Section: 11.2.2. The new operator - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-011"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var BOOLEAN = true; - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var OBJECT = new BOOLEAN(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "BOOLEAN = true; result = new BOOLEAN()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-012.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-012.binjs deleted file mode 100644 index b2a72d1f0a67..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-012.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-012.js b/js/src/jsapi-tests/binast/parser/tester/expression-012.js deleted file mode 100644 index 69e39ba47c53..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-012.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-012.js - Corresponds To: ecma/Expressions/11.2.2-6-n.js - ECMA Section: 11.2.2. The new operator - Description: - http://scopus/bugsplat/show_bug.cgi?id=327765 - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-012"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; -var BUGNUMBER= "327765"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var STRING = new String("hi"); -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = new STRING(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "STRING = new String(\"hi\"); result = new STRING()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-013.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-013.binjs deleted file mode 100644 index 2c33b5a9c522..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-013.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-013.js b/js/src/jsapi-tests/binast/parser/tester/expression-013.js deleted file mode 100644 index f4986a5c02b5..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-013.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-013.js - Corresponds To: ecma/Expressions/11.2.2-8-n.js - ECMA Section: 11.2.2. The new operator - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-013"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; -var BUGNUMBER= "327765"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var NUMBER = new Number(1); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = new NUMBER(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "NUMBER = new Number(1); result = new NUMBER()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-014.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-014.binjs deleted file mode 100644 index 80dbbd50cb11..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-014.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-014.js b/js/src/jsapi-tests/binast/parser/tester/expression-014.js deleted file mode 100644 index ac2dadaec5cf..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-014.js +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-014.js - Corresponds To: ecma/Expressions/11.2.2-9-n.js - ECMA Section: 11.2.2. The new operator - Description: - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-014.js"; -var VERSION = "ECMA_1"; -var TITLE = "The new operator"; -var BUGNUMBER= "327765"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var BOOLEAN = new Boolean(); - - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = new BOOLEAN(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "BOOLEAN = new Boolean(); result = new BOOLEAN()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-015.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-015.binjs deleted file mode 100644 index 87a6c892fbb5..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-015.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-015.js b/js/src/jsapi-tests/binast/parser/tester/expression-015.js deleted file mode 100644 index 4febd4c3c935..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-015.js +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-015.js - Corresponds To: ecma/Expressions/11.2.3-2-n.js - ECMA Section: 11.2.3. Function Calls - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-015"; -var VERSION = "JS1_4"; -var TITLE = "Function Calls"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("result = 3.valueOf();"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "3.valueOf()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-016.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-016.binjs deleted file mode 100644 index 0632656da961..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-016.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-016.js b/js/src/jsapi-tests/binast/parser/tester/expression-016.js deleted file mode 100644 index 9d0bfcef4e3b..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-016.js +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-016.js - Corresponds To: ecma/Expressions/11.2.3-3-n.js - ECMA Section: 11.2.3. Function Calls - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-016"; -var VERSION = "JS1_4"; -var TITLE = "Function Calls"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = (void 0).valueOf(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "(void 0).valueOf()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-017.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-017.binjs deleted file mode 100644 index afd2dc722533..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-017.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-017.js b/js/src/jsapi-tests/binast/parser/tester/expression-017.js deleted file mode 100644 index 1e357ead7670..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-017.js +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-07.js - Corresponds To: ecma/Expressions/11.2.3-4-n.js - ECMA Section: 11.2.3. Function Calls - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-017"; -var VERSION = "JS1_4"; -var TITLE = "Function Calls"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = nullvalueOf(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "null.valueOf()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-019.binjs b/js/src/jsapi-tests/binast/parser/tester/expression-019.binjs deleted file mode 100644 index ffa699e488bb..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/expression-019.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/expression-019.js b/js/src/jsapi-tests/binast/parser/tester/expression-019.js deleted file mode 100644 index 76c26bcaea73..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/expression-019.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: expression-019.js - Corresponds To: 11.2.2-7-n.js - ECMA Section: 11.2.2. The new operator - Description: - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-019"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; -var BUGNUMBER= "327765"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var STRING = new String("hi"); - result = new STRING(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var STRING = new String(\"hi\"); result = new STRING();" + - " (threw " + exception + ")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/forin-001.binjs b/js/src/jsapi-tests/binast/parser/tester/forin-001.binjs deleted file mode 100644 index b7b533165315..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/forin-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/forin-001.js b/js/src/jsapi-tests/binast/parser/tester/forin-001.js deleted file mode 100644 index 215de6c4c8e6..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/forin-001.js +++ /dev/null @@ -1,297 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: forin-001.js - * ECMA Section: - * Description: The forin-001 statement - * - * Verify that the property name is assigned to the property on the left - * hand side of the for...in expression. - * - * Author: christine@netscape.com - * Date: 28 August 1998 - */ -var SECTION = "forin-001"; -var VERSION = "ECMA_2"; -var TITLE = "The for...in statement"; -var BUGNUMBER="330890"; -var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=344855"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -ForIn_1( { length:4, company:"netscape", year:2000, 0:"zero" } ); -ForIn_2( { length:4, company:"netscape", year:2000, 0:"zero" } ); -ForIn_3( { length:4, company:"netscape", year:2000, 0:"zero" } ); - -// ForIn_6({ length:4, company:"netscape", year:2000, 0:"zero" }); -// ForIn_7({ length:4, company:"netscape", year:2000, 0:"zero" }); -ForIn_8({ length:4, company:"netscape", year:2000, 0:"zero" }); - -test(); - -/** - * Verify that the left side argument is evaluated with every iteration. - * Verify that the name of each property of the object is assigned to a - * a property. - * - */ -function ForIn_1( object ) { - PropertyArray = new Array(); - ValueArray = new Array(); - - for ( PropertyArray[PropertyArray.length] in object ) { - ValueArray[ValueArray.length] = - object[PropertyArray[PropertyArray.length-1]]; - } - - for ( var i = 0; i < PropertyArray.length; i++ ) { - new TestCase( - SECTION, - "object[" + PropertyArray[i] +"]", - object[PropertyArray[i]], - ValueArray[i] - ); - } - - new TestCase( - SECTION, - "object.length", - PropertyArray.length, - object.length ); -} - -/** - * Similar to ForIn_1, except it should increment the counter variable - * every time the left hand expression is evaluated. - */ -function ForIn_2( object ) { - PropertyArray = new Array(); - ValueArray = new Array(); - var i = 0; - - for ( PropertyArray[i++] in object ) { - ValueArray[ValueArray.length] = - object[PropertyArray[PropertyArray.length-1]]; - } - - for ( i = 0; i < PropertyArray.length; i++ ) { - new TestCase( - SECTION, - "object[" + PropertyArray[i] +"]", - object[PropertyArray[i]], - ValueArray[i] - ); - } - - new TestCase( - SECTION, - "object.length", - PropertyArray.length, - object.length ); -} - -/** - * Break out of a for...in loop - * - * - */ -function ForIn_3( object ) { - var checkBreak = "pass"; - var properties = new Array(); - var values = new Array(); - - for ( properties[properties.length] in object ) { - values[values.length] = object[properties[properties.length-1]]; - break; - checkBreak = "fail"; - } - - new TestCase( - SECTION, - "check break out of for...in", - "pass", - checkBreak ); - - new TestCase( - SECTION, - "properties.length", - 1, - properties.length ); - - new TestCase( - SECTION, - "object["+properties[0]+"]", - values[0], - object[properties[0]] ); -} - -/** - * Break out of a labeled for...in loop. - */ -function ForIn_4( object ) { - var result1 = 0; - var result2 = 0; - var result3 = 0; - var result4 = 0; - var i = 0; - var property = new Array(); - -butterbean: { - result1++; - - for ( property[i++] in object ) { - result2++; - break; - result4++; - } - result3++; - } - - new TestCase( - SECTION, - "verify labeled statement is only executed once", - true, - result1 == 1 ); - - new TestCase( - SECTION, - "verify statements in for loop are evaluated", - true, - result2 == i ); - - new TestCase( - SECTION, - "verify break out of labeled for...in loop", - true, - result4 == 0 ); - - new TestCase( - SECTION, - "verify break out of labeled block", - true, - result3 == 0 ); -} - -/** - * Labeled break out of a labeled for...in loop. - */ -function ForIn_5 (object) { - var result1 = 0; - var result2 = 0; - var result3 = 0; - var result4 = 0; - var i = 0; - var property = new Array(); - -bigredbird: { - result1++; - for ( property[i++] in object ) { - result2++; - break bigredbird; - result4++; - } - result3++; - } - - new TestCase( - SECTION, - "verify labeled statement is only executed once", - true, - result1 == 1 ); - - new TestCase( - SECTION, - "verify statements in for loop are evaluated", - true, - result2 == i ); - - new TestCase( - SECTION, - "verify break out of labeled for...in loop", - true, - result4 == 0 ); - - new TestCase( - SECTION, - "verify break out of labeled block", - true, - result3 == 0 ); -} - -/** - * Labeled continue from a labeled for...in loop - */ -function ForIn_7( object ) { - var result1 = 0; - var result2 = 0; - var result3 = 0; - var result4 = 0; - var i = 0; - var property = new Array(); - -bigredbird: - for ( property[i++] in object ) { - result2++; - continue bigredbird; - result4++; - } - - new TestCase( - SECTION, - "verify statements in for loop are evaluated", - true, - result2 == i ); - - new TestCase( - SECTION, - "verify break out of labeled for...in loop", - true, - result4 == 0 ); - - new TestCase( - SECTION, - "verify break out of labeled block", - true, - result3 == 1 ); -} - - -/** - * continue in a for...in loop - * - */ -function ForIn_8( object ) { - var checkBreak = "pass"; - var properties = new Array(); - var values = new Array(); - - for ( properties[properties.length] in object ) { - values[values.length] = object[properties[properties.length-1]]; - break; - checkBreak = "fail"; - } - - new TestCase( - SECTION, - "check break out of for...in", - "pass", - checkBreak ); - - new TestCase( - SECTION, - "properties.length", - 1, - properties.length ); - - new TestCase( - SECTION, - "object["+properties[0]+"]", - values[0], - object[properties[0]] ); -} - diff --git a/js/src/jsapi-tests/binast/parser/tester/forin-002.binjs b/js/src/jsapi-tests/binast/parser/tester/forin-002.binjs deleted file mode 100644 index 3c83f7818540..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/forin-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/forin-002.js b/js/src/jsapi-tests/binast/parser/tester/forin-002.js deleted file mode 100644 index 7d898d6bcf40..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/forin-002.js +++ /dev/null @@ -1,77 +0,0 @@ -// |reftest| skip-if(Android) -- bug - nsIDOMWindow.crypto throws NS_ERROR_NOT_IMPLEMENTED on Android -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/. */ - - -/** - * File Name: forin-002.js - * ECMA Section: - * Description: The forin-001 statement - * - * Verify that the property name is assigned to the property on the left - * hand side of the for...in expression. - * - * Author: christine@netscape.com - * Date: 28 August 1998 - */ -var SECTION = "forin-002"; -var VERSION = "ECMA_2"; -var TITLE = "The for...in statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -function MyObject( value ) { - this.value = value; - this.valueOf = new Function ( "return this.value" ); - this.toString = new Function ( "return this.value + \"\"" ); - this.toNumber = new Function ( "return this.value + 0" ); - this.toBoolean = new Function ( "return Boolean( this.value )" ); -} - -ForIn_1(this); -ForIn_2(this); - -ForIn_1(new MyObject(true)); -ForIn_2(new MyObject(new Boolean(true))); - -ForIn_2(3); - -test(); - -/** - * For ... In in a With Block - * - */ -function ForIn_1( object) { - with ( object ) { - for ( property in object ) { - new TestCase( - SECTION, - "with loop in a for...in loop. ("+object+")["+property +"] == "+ - "eval ( " + property +" )", - true, - object[property] == eval(property) ); - } - } -} - -/** - * With block in a For...In loop - * - */ -function ForIn_2(object) { - for ( property in object ) { - with ( object ) { - new TestCase( - SECTION, - "with loop in a for...in loop. ("+object+")["+property +"] == "+ - "eval ( " + property +" )", - true, - object[property] == eval(property) ); - } - } -} - diff --git a/js/src/jsapi-tests/binast/parser/tester/function-001.binjs b/js/src/jsapi-tests/binast/parser/tester/function-001.binjs deleted file mode 100644 index 775b94c1a520..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/function-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/function-001.js b/js/src/jsapi-tests/binast/parser/tester/function-001.js deleted file mode 100644 index df45e048d784..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/function-001.js +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: RegExp/function-001.js - * ECMA Section: 15.7.2.1 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/function-001"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp( pattern, flags )"; - -startTest(); - -/* - * for each test case, verify: - * - verify that [[Class]] property is RegExp - * - prototype property should be set to RegExp.prototype - * - source is set to the empty string - * - global property is set to false - * - ignoreCase property is set to false - * - multiline property is set to false - * - lastIndex property is set to 0 - */ - -RegExp.prototype.getClassProperty = Object.prototype.toString; -var re = new RegExp(); - -AddTestCase( - "new RegExp().__proto__", - RegExp.prototype, - re.__proto__ - ); - -test() diff --git a/js/src/jsapi-tests/binast/parser/tester/global-001.binjs b/js/src/jsapi-tests/binast/parser/tester/global-001.binjs deleted file mode 100644 index 543e407d825b..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/global-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/global-001.js b/js/src/jsapi-tests/binast/parser/tester/global-001.js deleted file mode 100644 index 228b110c8954..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/global-001.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: global-001 - Corresponds To: ecma/GlobalObject/15.1-1-n.js - ECMA Section: The global object - Description: - - The global object does not have a [[Construct]] property; it is not - possible to use the global object as a constructor with the new operator. - - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "global-001"; -var VERSION = "ECMA_1"; -var TITLE = "The Global Object"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = new this(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "result = new this()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/global-002.binjs b/js/src/jsapi-tests/binast/parser/tester/global-002.binjs deleted file mode 100644 index 6e10384cbdb2..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/global-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/global-002.js b/js/src/jsapi-tests/binast/parser/tester/global-002.js deleted file mode 100644 index 1639a34bb783..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/global-002.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: global-002 - Corresponds To: ecma/GlobalObject/15.1-2-n.js - ECMA Section: The global object - Description: - - The global object does not have a [[Construct]] property; it is not - possible to use the global object as a constructor with the new operator. - - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "global-002"; -var VERSION = "JS1_4"; -var TITLE = "The Global Object"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = this(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "result = this()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/hex-001.binjs b/js/src/jsapi-tests/binast/parser/tester/hex-001.binjs deleted file mode 100644 index f210c40d6b2c..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/hex-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/hex-001.js b/js/src/jsapi-tests/binast/parser/tester/hex-001.js deleted file mode 100644 index 04c3a97b9450..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/hex-001.js +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: RegExp/hex-001.js - * ECMA Section: 15.7.3.1 - * Description: Based on ECMA 2 Draft 7 February 1999 - * Positive test cases for constructing a RegExp object - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/hex-001"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp patterns that contain HexicdecimalEscapeSequences"; - -startTest(); - -// These examples come from 15.7.1, HexidecimalEscapeSequence - -AddRegExpCases( new RegExp("\x41"), "new RegExp('\\x41')", "A", "A", 1, 0, ["A"] ); -AddRegExpCases( new RegExp("\x412"),"new RegExp('\\x412')", "A2", "A2", 1, 0, ["A2"] ); - -AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x41", "\\x41", 1, 0, ["A"] ); -AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x412", "\\x412", 1, 0, ["A"] ); -AddRegExpCases( new RegExp("^x"), "new RegExp('^x')", "x412", "x412", 1, 0, ["x"]); -AddRegExpCases( new RegExp("A"), "new RegExp('A')", "A2", "A2", 1, 0, ["A"] ); - -test(); - -function AddRegExpCases( - regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - str_regexp + ".exec(" + pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").length", - length, - regexp.exec(pattern).length ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").input", - pattern, - regexp.exec(pattern).input ); - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - str_regexp + ".exec(" + str_pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } -} diff --git a/js/src/jsapi-tests/binast/parser/tester/if-001.binjs b/js/src/jsapi-tests/binast/parser/tester/if-001.binjs deleted file mode 100644 index da9cb6cb563f..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/if-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/if-001.js b/js/src/jsapi-tests/binast/parser/tester/if-001.js deleted file mode 100644 index ffc621a32c5d..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/if-001.js +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: if-001.js - * ECMA Section: - * Description: The if statement - * - * Verify that assignment in the if expression is evaluated correctly. - * Verifies the fix for bug http://scopus/bugsplat/show_bug.cgi?id=148822. - * - * Author: christine@netscape.com - * Date: 28 August 1998 - */ -var SECTION = "for-001"; -var VERSION = "ECMA_2"; -var TITLE = "The if statement"; -var BUGNUMBER="148822"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var a = 0; -var b = 0; -var result = "passed"; - -if ( a = b ) { - result = "failed: a = b should return 0"; -} - -new TestCase( - SECTION, - "if ( a = b ), where a and b are both equal to 0", - "passed", - result ); - - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/instanceof-001.binjs b/js/src/jsapi-tests/binast/parser/tester/instanceof-001.binjs deleted file mode 100644 index 1f10b0947393..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/instanceof-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/instanceof-001.js b/js/src/jsapi-tests/binast/parser/tester/instanceof-001.js deleted file mode 100644 index 9bdc7bfe3f8b..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/instanceof-001.js +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: instanceof-1.js - ECMA Section: - Description: instanceof operator - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = ""; -var VERSION = "ECMA_2"; -var TITLE = "instanceof operator"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var b = new Boolean(); - -new TestCase( SECTION, - "var b = new Boolean(); b instanceof Boolean", - true, - b instanceof Boolean ); - -new TestCase( SECTION, - "b instanceof Object", - true, - b instanceof Object ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/instanceof-002.binjs b/js/src/jsapi-tests/binast/parser/tester/instanceof-002.binjs deleted file mode 100644 index 293e9645539d..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/instanceof-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/instanceof-002.js b/js/src/jsapi-tests/binast/parser/tester/instanceof-002.js deleted file mode 100644 index 6b2bb7f4f690..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/instanceof-002.js +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: - ECMA Section: - Description: Call Objects - - - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = ""; -var VERSION = "ECMA_2"; -var TITLE = "The Call Constructor"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var b = new Boolean(); - -new TestCase( SECTION, - "var b = new Boolean(); b instanceof Boolean", - true, - b instanceof Boolean ); - -new TestCase( SECTION, - "b instanceof Object", - true, - b instanceof Object ); - -new TestCase( SECTION, - "b instanceof Array", - false, - b instanceof Array ); - -new TestCase( SECTION, - "true instanceof Boolean", - false, - true instanceof Boolean ); - -new TestCase( SECTION, - "Boolean instanceof Object", - true, - Boolean instanceof Object ); -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/instanceof-003-n.binjs b/js/src/jsapi-tests/binast/parser/tester/instanceof-003-n.binjs deleted file mode 100644 index 8a2e95ec8461..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/instanceof-003-n.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/instanceof-003-n.js b/js/src/jsapi-tests/binast/parser/tester/instanceof-003-n.js deleted file mode 100644 index 1b3937ac8ab2..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/instanceof-003-n.js +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: instanceof-001.js - * ECMA Section: 11.8.6 - * Description: - * - * RelationalExpression instanceof Identifier - * - * Author: christine@netscape.com - * Date: 2 September 1998 - */ -var SECTION = "instanceof-003-n"; -var VERSION = "ECMA_2"; -var TITLE = "instanceof" - - startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -function InstanceOf( object_1, object_2, expect ) { - - result = object_1 instanceof object_2; - - new TestCase( - SECTION, - "(" + object_1 + ") instanceof " + object_2, - expect, - result ); -} - -function Gen3(value) { - this.value = value; - this.generation = 3; - this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); -} -Gen3.name = 3; -Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); - -function Gen2(value) { - this.value = value; - this.generation = 2; -} -Gen2.name = 2; -Gen2.prototype = new Gen3(); - -function Gen1(value) { - this.value = value; - this.generation = 1; -} -Gen1.name = 1; -Gen1.prototype = new Gen2(); - -function Gen0(value) { - this.value = value; - this.generation = 0; -} -Gen0.name = 0; -Gen0.prototype = new Gen1(); - - -function GenA(value) { - this.value = value; - this.generation = "A"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - -} -GenA.prototype = new Gen0(); -GenA.name = "A"; - -function GenB(value) { - this.value = value; - this.generation = "B"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); -} -GenB.name = "B" - GenB.prototype = void 0; - -// Identifier is not a function -DESCRIPTION = "Identifier is not a function"; -EXPECTED = "error"; - -InstanceOf( true, true, "error" ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/instanceof-003.binjs b/js/src/jsapi-tests/binast/parser/tester/instanceof-003.binjs deleted file mode 100644 index 7c92d661ec14..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/instanceof-003.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/instanceof-003.js b/js/src/jsapi-tests/binast/parser/tester/instanceof-003.js deleted file mode 100644 index 1021914e9577..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/instanceof-003.js +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: instanceof-003.js - ECMA Section: - Description: http://bugzilla.mozilla.org/show_bug.cgi?id=7635 - - js> function Foo() {} - js> theproto = {}; - [object Object] - js> Foo.prototype = theproto - [object Object] - js> theproto instanceof Foo - true - - I think this should be 'false' - - - Author: christine@netscape.com - Date: 12 november 1997 - - Modified to conform to ECMA3 - https://bugzilla.mozilla.org/show_bug.cgi?id=281606 -*/ -var SECTION = "instanceof-003"; -var VERSION = "ECMA_2"; -var TITLE = "instanceof operator"; -var BUGNUMBER ="7635"; - -startTest(); - -function Foo() {}; -theproto = {}; -Foo.prototype = theproto; - -AddTestCase( - "function Foo() = {}; theproto = {}; Foo.prototype = theproto; " + - "theproto instanceof Foo", - false, - theproto instanceof Foo ); - - -var o = {}; - -// https://bugzilla.mozilla.org/show_bug.cgi?id=281606 -try -{ - AddTestCase( - "o = {}; o instanceof o", - "error", - o instanceof o ); -} -catch(e) -{ - AddTestCase( - "o = {}; o instanceof o", - "error", - "error" ); -} - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/instanceof-004-n.binjs b/js/src/jsapi-tests/binast/parser/tester/instanceof-004-n.binjs deleted file mode 100644 index 1d16ce0406f3..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/instanceof-004-n.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/instanceof-004-n.js b/js/src/jsapi-tests/binast/parser/tester/instanceof-004-n.js deleted file mode 100644 index 18de1c8da079..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/instanceof-004-n.js +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: instanceof-001.js - * ECMA Section: 11.8.6 - * Description: - * - * RelationalExpression instanceof Identifier - * - * Author: christine@netscape.com - * Date: 2 September 1998 - */ -var SECTION = "instanceof-004-n"; -var VERSION = "ECMA_2"; -var TITLE = "instanceof" - - startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -function InstanceOf( object_1, object_2, expect ) { - result = object_1 instanceof object_2; - - new TestCase( - SECTION, - "(" + object_1 + ") instanceof " + object_2, - expect, - result ); -} - -function Gen3(value) { - this.value = value; - this.generation = 3; - this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); -} -Gen3.name = 3; -Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); - -function Gen2(value) { - this.value = value; - this.generation = 2; -} -Gen2.name = 2; -Gen2.prototype = new Gen3(); - -function Gen1(value) { - this.value = value; - this.generation = 1; -} -Gen1.name = 1; -Gen1.prototype = new Gen2(); - -function Gen0(value) { - this.value = value; - this.generation = 0; -} -Gen0.name = 0; -Gen0.prototype = new Gen1(); - - -function GenA(value) { - this.value = value; - this.generation = "A"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - -} -GenA.prototype = new Gen0(); -GenA.name = "A"; - -function GenB(value) { - this.value = value; - this.generation = "B"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); -} -GenB.name = "B" - GenB.prototype = void 0; - -// Identifier is not a function - -DESCRIPTION = "Identifier is not a function"; -EXPECTED = "error"; - -InstanceOf( new Boolean(true), false, "error" ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/instanceof-005-n.binjs b/js/src/jsapi-tests/binast/parser/tester/instanceof-005-n.binjs deleted file mode 100644 index 170b78ef4b53..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/instanceof-005-n.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/instanceof-005-n.js b/js/src/jsapi-tests/binast/parser/tester/instanceof-005-n.js deleted file mode 100644 index 8f02162cabd9..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/instanceof-005-n.js +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: instanceof-001.js - * ECMA Section: 11.8.6 - * Description: - * - * RelationalExpression instanceof Identifier - * - * Author: christine@netscape.com - * Date: 2 September 1998 - */ -var SECTION = "instanceof-005-n"; -var VERSION = "ECMA_2"; -var TITLE = "instanceof" - - startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -function InstanceOf( object_1, object_2, expect ) { - result = object_1 instanceof object_2; - - new TestCase( - SECTION, - "(" + object_1 + ") instanceof " + object_2, - expect, - result ); -} - -function Gen3(value) { - this.value = value; - this.generation = 3; - this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); -} -Gen3.name = 3; -Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); - -function Gen2(value) { - this.value = value; - this.generation = 2; -} -Gen2.name = 2; -Gen2.prototype = new Gen3(); - -function Gen1(value) { - this.value = value; - this.generation = 1; -} -Gen1.name = 1; -Gen1.prototype = new Gen2(); - -function Gen0(value) { - this.value = value; - this.generation = 0; -} -Gen0.name = 0; -Gen0.prototype = new Gen1(); - - -function GenA(value) { - this.value = value; - this.generation = "A"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - -} -GenA.prototype = new Gen0(); -GenA.name = "A"; - -function GenB(value) { - this.value = value; - this.generation = "B"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); -} -GenB.name = "B" - GenB.prototype = void 0; - - -// Identifier is a function, prototype of Identifier is not an object - -DESCRIPTION = "Identifier is a function, prototype of Identifier is not an object"; -EXPECTED = "error"; - -InstanceOf( new GenB(), GenB, "error" ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/instanceof-006.binjs b/js/src/jsapi-tests/binast/parser/tester/instanceof-006.binjs deleted file mode 100644 index 36ed72efb86a..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/instanceof-006.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/instanceof-006.js b/js/src/jsapi-tests/binast/parser/tester/instanceof-006.js deleted file mode 100644 index 9f18c4e103f9..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/instanceof-006.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: instanceof-001.js - * ECMA Section: 11.8.6 - * Description: - * - * RelationalExpression instanceof Identifier - * - * Author: christine@netscape.com - * Date: 2 September 1998 - */ -var SECTION = "instanceof-001"; -var VERSION = "ECMA_2"; -var TITLE = "instanceof" - - startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -function InstanceOf( object_1, object_2, expect ) { - result = object_1 instanceof object_2; - - new TestCase( - SECTION, - "(" + object_1 + ") instanceof " + object_2, - expect, - result ); -} - -function Gen3(value) { - this.value = value; - this.generation = 3; - this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); -} -Gen3.name = 3; -Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); - -function Gen2(value) { - this.value = value; - this.generation = 2; -} -Gen2.name = 2; -Gen2.prototype = new Gen3(); - -function Gen1(value) { - this.value = value; - this.generation = 1; -} -Gen1.name = 1; -Gen1.prototype = new Gen2(); - -function Gen0(value) { - this.value = value; - this.generation = 0; -} -Gen0.name = 0; -Gen0.prototype = new Gen1(); - - -function GenA(value) { - this.value = value; - this.generation = "A"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - -} -GenA.prototype = new Gen0(); -GenA.name = "A"; - -function GenB(value) { - this.value = value; - this.generation = "B"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); -} -GenB.name = "B" - GenB.prototype = void 0; - -// RelationalExpression is not an object. - -// InstanceOf( true, Boolean, false ); -InstanceOf( new Boolean(false), Boolean, true ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/keywords-001.binjs b/js/src/jsapi-tests/binast/parser/tester/keywords-001.binjs deleted file mode 100644 index 60ae7a7dba8c..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/keywords-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/keywords-001.js b/js/src/jsapi-tests/binast/parser/tester/keywords-001.js deleted file mode 100644 index 411386100bfe..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/keywords-001.js +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: - * ECMA Section: - * Description: - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = ""; -var VERSION = "ECMA_2"; -var TITLE = "Keywords"; - -startTest(); - -print("This test requires option javascript.options.strict enabled"); - -if (!options().match(/strict/)) -{ - options('strict'); -} -if (!options().match(/werror/)) -{ - options('werror'); -} - -var result = "failed"; - -try { - eval("super;"); -} -catch (x) { - if (x instanceof SyntaxError) - result = x.name; -} - -AddTestCase( - "using the expression \"super\" shouldn't cause js to crash", - "SyntaxError", - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/label-001.binjs b/js/src/jsapi-tests/binast/parser/tester/label-001.binjs deleted file mode 100644 index 92fc9e5e0842..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/label-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/label-001.js b/js/src/jsapi-tests/binast/parser/tester/label-001.js deleted file mode 100644 index 391732a2d3dd..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/label-001.js +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: label-001.js - * ECMA Section: - * Description: Labeled statements - * - * Labeled break and continue within a for loop. - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "label-003"; -var VERSION = "ECMA_2"; -var TITLE = "Labeled statements"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -LabelTest(0, 0); -LabelTest(1, 1) - LabelTest(-1, 1000); -LabelTest(false, 0); -LabelTest(true, 1); - -test(); - -function LabelTest( limit, expect) { -woo: for ( var result = 0; result < 1000; result++ ) { if (result == limit) { break woo; } else { continue woo; } }; - - new TestCase( - SECTION, - "break out of a labeled for loop: "+ limit, - expect, - result ); -} - diff --git a/js/src/jsapi-tests/binast/parser/tester/label-002.binjs b/js/src/jsapi-tests/binast/parser/tester/label-002.binjs deleted file mode 100644 index be279c14ee93..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/label-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/label-002.js b/js/src/jsapi-tests/binast/parser/tester/label-002.js deleted file mode 100644 index 1e2b63adca7f..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/label-002.js +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: label-002.js - * ECMA Section: - * Description: Labeled statements - * - * Labeled break and continue within a for-in loop. - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "label-002"; -var VERSION = "ECMA_2"; -var TITLE = "Labeled statements"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -LabelTest( { p1:"hi,", p2:" norris" }, "hi, norris", " norrishi," ); -LabelTest( { 0:"zero", 1:"one" }, "zeroone", "onezero" ); - -LabelTest2( { p1:"hi,", p2:" norris" }, "hi,", " norris" ); -LabelTest2( { 0:"zero", 1:"one" }, "zero", "one" ); - -test(); - -function LabelTest( object, expect1, expect2 ) { - result = ""; - -yoohoo: { for ( property in object ) { result += object[property]; }; break yoohoo }; - - new TestCase( - SECTION, - "yoohoo: for ( property in object ) { result += object[property]; } break yoohoo }", - true, - result == expect1 || result == expect2 ); -} - -function LabelTest2( object, expect1, expect2 ) { - result = ""; - -yoohoo: { for ( property in object ) { result += object[property]; break yoohoo } }; ; - - new TestCase( - SECTION, - "yoohoo: for ( property in object ) { result += object[property]; break yoohoo }}", - true, - result == expect1 || result == expect2 ); -} - diff --git a/js/src/jsapi-tests/binast/parser/tester/label-003.binjs b/js/src/jsapi-tests/binast/parser/tester/label-003.binjs deleted file mode 100644 index e0250521e717..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/label-003.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/label-003.js b/js/src/jsapi-tests/binast/parser/tester/label-003.js deleted file mode 100644 index 934732949857..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/label-003.js +++ /dev/null @@ -1,15 +0,0 @@ -/* -*- 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/. */ - -// The colon for a labeled statement may be on a separate line. -var x; -label -: { - x = 1; - break label; - x = 2; -} -assertEq(x, 1); -reportCompare(0, 0, 'ok'); diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-001.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-001.binjs deleted file mode 100644 index 3b0f7fec00d5..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-001.js b/js/src/jsapi-tests/binast/parser/tester/lexical-001.js deleted file mode 100644 index 3dbd61d997c0..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-001.js +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-001.js - CorrespondsTo: ecma/LexicalConventions/7.2.js - ECMA Section: 7.2 Line Terminators - Description: - readability - - separate tokens - - may occur between any two tokens - - cannot occur within any token, not even a string - - affect the process of automatic semicolon insertion. - - white space characters are: - unicode name formal name string representation - \u000A line feed \n - \u000D carriage return \r - - this test uses onerror to capture line numbers. because - we use on error, we can only have one test case per file. - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "lexical-001"; -var VERSION = "JS1_4"; -var TITLE = "Line Terminators"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = eval("\r\n\expect"); -} catch ( e ) { - exception = e.toString(); -} - -new TestCase( - SECTION, - "OBJECT = new Object; result = new OBJECT()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-002.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-002.binjs deleted file mode 100644 index a35cb02ca93d..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-002.js b/js/src/jsapi-tests/binast/parser/tester/lexical-002.js deleted file mode 100644 index 19eb30c0d53e..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-002.js +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-002.js - Corresponds To: ecma/LexicalConventions/7.2-3-n.js - ECMA Section: 7.2 Line Terminators - Description: - readability - - separate tokens - - may occur between any two tokens - - cannot occur within any token, not even a string - - affect the process of automatic semicolon insertion. - - white space characters are: - unicode name formal name string representation - \u000A line feed \n - \u000D carriage return \r - - this test uses onerror to capture line numbers. because - we use on error, we can only have one test case per file. - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "lexical-002"; -var VERSION = "JS1_4"; -var TITLE = "Line Terminators"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = eval("\r\n\expect"); -} catch ( e ) { - exception = e.toString(); -} - -new TestCase( - SECTION, - "result=eval(\"\r\nexpect\")" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-003.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-003.binjs deleted file mode 100644 index 40c4dc64d15d..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-003.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-003.js b/js/src/jsapi-tests/binast/parser/tester/lexical-003.js deleted file mode 100644 index 46d60cb7fbc8..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-003.js +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-003.js - Corresponds To: 7.3-13-n.js - ECMA Section: 7.3 Comments - Description: - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-003.js"; -var VERSION = "JS1_4"; -var TITLE = "Comments"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("/*\n/* nested comment */\n*/\n"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "/*/*nested comment*/ */" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-004.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-004.binjs deleted file mode 100644 index 4bf2d6454c9b..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-004.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-004.js b/js/src/jsapi-tests/binast/parser/tester/lexical-004.js deleted file mode 100644 index 853887db3ef5..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-004.js +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-004.js - Corresponds To: ecma/LexicalExpressions/7.4.1-1-n.js - ECMA Section: 7.4.1 - - Description: - - Reserved words cannot be used as identifiers. - - ReservedWord :: - Keyword - FutureReservedWord - NullLiteral - BooleanLiteral - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-004"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var null = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var null = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-005.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-005.binjs deleted file mode 100644 index 880e4d973618..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-005.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-005.js b/js/src/jsapi-tests/binast/parser/tester/lexical-005.js deleted file mode 100644 index 2f3d3bdd8226..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-005.js +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-005.js - Corresponds To: 7.4.1-2.js - ECMA Section: 7.4.1 - - Description: - - Reserved words cannot be used as identifiers. - - ReservedWord :: - Keyword - FutureReservedWord - NullLiteral - BooleanLiteral - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-005"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("true = false;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "true = false" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-006.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-006.binjs deleted file mode 100644 index 2d07274734b8..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-006.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-006.js b/js/src/jsapi-tests/binast/parser/tester/lexical-006.js deleted file mode 100644 index b37fe0d529a9..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-006.js +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-006.js - Corresponds To: 7.4.2-1.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-006"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("break = new Object();"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "break = new Object()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-007.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-007.binjs deleted file mode 100644 index a4f7be41d0ad..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-007.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-007.js b/js/src/jsapi-tests/binast/parser/tester/lexical-007.js deleted file mode 100644 index 255a8b859fb1..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-007.js +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-005.js - Corresponds To: 7.4.1-3-n.js - ECMA Section: 7.4.1 - - Description: - - Reserved words cannot be used as identifiers. - - ReservedWord :: - Keyword - FutureReservedWord - NullLiteral - BooleanLiteral - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-005"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("false = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "false = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-008.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-008.binjs deleted file mode 100644 index ac103a3ae560..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-008.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-008.js b/js/src/jsapi-tests/binast/parser/tester/lexical-008.js deleted file mode 100644 index b24b85875856..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-008.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-008.js - Corresponds To: 7.4.3-1-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-008.js"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("case = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "case = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-009.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-009.binjs deleted file mode 100644 index 952fefbd972d..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-009.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-009.js b/js/src/jsapi-tests/binast/parser/tester/lexical-009.js deleted file mode 100644 index d5dc0ed44303..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-009.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-009 - Corresponds To: 7.4.3-2-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-009"; -var VERSION = "ECMA_1"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("debugger = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "debugger = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-011.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-011.binjs deleted file mode 100644 index 717f1822c139..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-011.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-011.js b/js/src/jsapi-tests/binast/parser/tester/lexical-011.js deleted file mode 100644 index b6703284269d..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-011.js +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-011.js - Corresponds To: 7.4.3-4-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-011"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -print("This test requires option javascript.options.strict enabled"); - -if (!options().match(/strict/)) -{ - options('strict'); -} -if (!options().match(/werror/)) -{ - options('werror'); -} - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("super = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "super = true" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-012.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-012.binjs deleted file mode 100644 index 7f55206ac98e..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-012.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-012.js b/js/src/jsapi-tests/binast/parser/tester/lexical-012.js deleted file mode 100644 index bed3322dde22..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-012.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-012.js - Corresponds To: 7.4.3-5-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-012"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("catch = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "catch = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-013.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-013.binjs deleted file mode 100644 index ce63ba5c86ef..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-013.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-013.js b/js/src/jsapi-tests/binast/parser/tester/lexical-013.js deleted file mode 100644 index 1fc0bf38a5b1..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-013.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-013.js - Corresponds To: 7.4.3-6-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-013"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("default = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "default = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-014.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-014.binjs deleted file mode 100644 index eb56f5bb3054..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-014.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-014.js b/js/src/jsapi-tests/binast/parser/tester/lexical-014.js deleted file mode 100644 index 05f0c3cf9107..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-014.js +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-014.js - Corresponds To: 7.4.3-7-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-014.js"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -print("This test requires option javascript.options.strict enabled"); - -if (!options().match(/strict/)) -{ - options('strict'); -} -if (!options().match(/werror/)) -{ - options('werror'); -} - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("extends = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "extends = true" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-015.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-015.binjs deleted file mode 100644 index c0d1fe40b626..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-015.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-015.js b/js/src/jsapi-tests/binast/parser/tester/lexical-015.js deleted file mode 100644 index 7d8c8e80bafc..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-015.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-015.js - Corresponds To: 7.4.3-8-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-015"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("switch = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "switch = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-016.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-016.binjs deleted file mode 100644 index 8c60e0ac54f0..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-016.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-016.js b/js/src/jsapi-tests/binast/parser/tester/lexical-016.js deleted file mode 100644 index 419af22c0e99..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-016.js +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-016 - Corresponds To: 7.4.3-9-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-016"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -print("This test requires option javascript.options.strict enabled"); - -if (!options().match(/strict/)) -{ - options('strict'); -} -if (!options().match(/werror/)) -{ - options('werror'); -} - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("class = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "class = true" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-017.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-017.binjs deleted file mode 100644 index a1e0e6e59198..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-017.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-017.js b/js/src/jsapi-tests/binast/parser/tester/lexical-017.js deleted file mode 100644 index d7d33b4f0182..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-017.js +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-017.js - Corresponds To: 7.4.3-10-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-017"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("do = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "do = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-018.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-018.binjs deleted file mode 100644 index 8d7deb8b9cf3..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-018.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-018.js b/js/src/jsapi-tests/binast/parser/tester/lexical-018.js deleted file mode 100644 index 4d151e67bd14..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-018.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-018 - Corresponds To: 7.4.3-11-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-018"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("finally = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "finally = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-019.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-019.binjs deleted file mode 100644 index ba6774fe3e5f..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-019.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-019.js b/js/src/jsapi-tests/binast/parser/tester/lexical-019.js deleted file mode 100644 index 0280b77102cb..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-019.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-019.js - Corresponds To: 7.4.3-12-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-019"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("throw = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "throw = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-020.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-020.binjs deleted file mode 100644 index bd74082c9a61..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-020.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-020.js b/js/src/jsapi-tests/binast/parser/tester/lexical-020.js deleted file mode 100644 index 7be919181b98..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-020.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-020.js - Corresponds To 7.4.3-13-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-020"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("const = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "const = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-021.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-021.binjs deleted file mode 100644 index dd38b63a2dd7..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-021.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-021.js b/js/src/jsapi-tests/binast/parser/tester/lexical-021.js deleted file mode 100644 index a3b4422ccc75..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-021.js +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-021.js - Corresponds To: 7.4.3-14-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-021.js"; -var VERSION = "ECMA_1"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -print("This test requires option javascript.options.strict enabled"); - -if (!options().match(/strict/)) -{ - options('strict'); -} -if (!options().match(/werror/)) -{ - options('werror'); -} - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("enum = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "enum = true" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-023.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-023.binjs deleted file mode 100644 index 39a9aca701bb..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-023.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-023.js b/js/src/jsapi-tests/binast/parser/tester/lexical-023.js deleted file mode 100644 index d5df7ce7d8ad..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-023.js +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-023.js - Corresponds To: 7.4.3-16-n.js - ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-023.js"; -var VERSION = "ECMA_1"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("try = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "try = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-024.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-024.binjs deleted file mode 100644 index 8f4f5a90348a..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-024.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-024.js b/js/src/jsapi-tests/binast/parser/tester/lexical-024.js deleted file mode 100644 index be1c3a7b9145..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-024.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-024 - Corresponds To: 7.4.2-1-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-024"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var break;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var break" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-025.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-025.binjs deleted file mode 100644 index aa3e59877d2d..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-025.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-025.js b/js/src/jsapi-tests/binast/parser/tester/lexical-025.js deleted file mode 100644 index 0dbb3ac63d5d..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-025.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-025.js - Corresponds To 7.4.2-2-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-025"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var for;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var for" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-026.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-026.binjs deleted file mode 100644 index 3b5d230297ee..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-026.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-026.js b/js/src/jsapi-tests/binast/parser/tester/lexical-026.js deleted file mode 100644 index 2711de0892b9..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-026.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-026.js - Corresponds To: 7.4.2-3-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-026"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var new;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var new" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-027.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-027.binjs deleted file mode 100644 index a29bed12aad5..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-027.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-027.js b/js/src/jsapi-tests/binast/parser/tester/lexical-027.js deleted file mode 100644 index 0d8ddf079875..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-027.js +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-027.js - Corresponds To: 7.4.2-4-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - var - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-027"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var var;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var var" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-028.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-028.binjs deleted file mode 100644 index c0ef34a00cd7..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-028.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-028.js b/js/src/jsapi-tests/binast/parser/tester/lexical-028.js deleted file mode 100644 index 2b75204c7fe6..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-028.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-028.js - Corresponds To: 7.4.2-5-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-028"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var continue=true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var continue=true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-029.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-029.binjs deleted file mode 100644 index e79fe5f1e264..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-029.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-029.js b/js/src/jsapi-tests/binast/parser/tester/lexical-029.js deleted file mode 100644 index f559b5d050aa..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-029.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-029.js - Corresponds To: 7.4.2-6.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-029"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var function = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var function = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-030.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-030.binjs deleted file mode 100644 index 5acef3d410c1..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-030.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-030.js b/js/src/jsapi-tests/binast/parser/tester/lexical-030.js deleted file mode 100644 index f5fc09620f44..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-030.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-030.js - Corresponds To: 7.4.2-7-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-030"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var return = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var return = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-031.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-031.binjs deleted file mode 100644 index 7430834e08b2..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-031.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-031.js b/js/src/jsapi-tests/binast/parser/tester/lexical-031.js deleted file mode 100644 index 53f0c399c8b5..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-031.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-031.js - Corresponds To: 7.4.2-8-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-031"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var return;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var return" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-032.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-032.binjs deleted file mode 100644 index daa962e4b952..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-032.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-032.js b/js/src/jsapi-tests/binast/parser/tester/lexical-032.js deleted file mode 100644 index a4196950b8ba..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-032.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-032.js - Corresponds To: 7.4.2-9-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-032"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("delete = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "delete = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-033.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-033.binjs deleted file mode 100644 index 079b441d7d92..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-033.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-033.js b/js/src/jsapi-tests/binast/parser/tester/lexical-033.js deleted file mode 100644 index f36daaff80d5..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-033.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-033.js - Corresponds To: 7.4.2-10.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-033"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("if = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "if = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-034.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-034.binjs deleted file mode 100644 index b3278d53d217..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-034.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-034.js b/js/src/jsapi-tests/binast/parser/tester/lexical-034.js deleted file mode 100644 index b160e3d030a5..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-034.js +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: 7.4.2-11-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-034"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("this = true"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "this = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-035.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-035.binjs deleted file mode 100644 index b5015535d3c6..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-035.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-035.js b/js/src/jsapi-tests/binast/parser/tester/lexical-035.js deleted file mode 100644 index c061c60abad9..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-035.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-035.js - Correpsonds To: 7.4.2-12-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-035"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var while"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var while" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-036.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-036.binjs deleted file mode 100644 index 5836694ee868..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-036.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-036.js b/js/src/jsapi-tests/binast/parser/tester/lexical-036.js deleted file mode 100644 index 6b0c3e9edc2a..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-036.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-036.js - Corresponds To: 7.4.2-13-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-036"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("else = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "else = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-037.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-037.binjs deleted file mode 100644 index ff6c26bf6479..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-037.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-037.js b/js/src/jsapi-tests/binast/parser/tester/lexical-037.js deleted file mode 100644 index d42c13170aee..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-037.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-037.js - Corresponds To: 7.4.2-14-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-028"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var in;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var in" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-038.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-038.binjs deleted file mode 100644 index a490d4fc7b2a..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-038.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-038.js b/js/src/jsapi-tests/binast/parser/tester/lexical-038.js deleted file mode 100644 index abcb85790bad..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-038.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-038.js - Corresponds To: 7.4.2-15-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-038"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("typeof = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "typeof = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-039.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-039.binjs deleted file mode 100644 index dfc706264557..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-039.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-039.js b/js/src/jsapi-tests/binast/parser/tester/lexical-039.js deleted file mode 100644 index 01e4407b32ab..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-039.js +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-039 - Corresponds To: 7.5-2-n.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "lexical-039"; -var VERSION = "JS1_4"; -var TITLE = "Identifiers"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var 0abc;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var 0abc" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-040.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-040.binjs deleted file mode 100644 index fd39cc1f252e..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-040.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-040.js b/js/src/jsapi-tests/binast/parser/tester/lexical-040.js deleted file mode 100644 index 346345579623..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-040.js +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-040.js - Corresponds To: 7.5-2.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "lexical-040"; -var VERSION = "JS1_4"; -var TITLE = "Identifiers"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var 1abc;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var 1abc" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-041.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-041.binjs deleted file mode 100644 index 57264e20375f..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-041.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-041.js b/js/src/jsapi-tests/binast/parser/tester/lexical-041.js deleted file mode 100644 index 9687c7adc472..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-041.js +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-041.js - Corresponds To: 7.5-8-n.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "lexical-041"; -var VERSION = "ECMA_1"; -var TITLE = "Identifiers"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var @abc;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var @abc" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-042.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-042.binjs deleted file mode 100644 index 47f879d5daeb..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-042.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-042.js b/js/src/jsapi-tests/binast/parser/tester/lexical-042.js deleted file mode 100644 index 0defe9708958..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-042.js +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-042.js - Corresponds To: 7.5-9-n.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "lexical-042"; -var VERSION = "JS1_4"; -var TITLE = "Identifiers"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var 123;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var 123" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-047.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-047.binjs deleted file mode 100644 index 483ce6f420cb..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-047.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-047.js b/js/src/jsapi-tests/binast/parser/tester/lexical-047.js deleted file mode 100644 index 7fa084bd3fc9..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-047.js +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-047.js - Corresponds To: 7.8.1-7-n.js - ECMA Section: 7.8.1 - Description: - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "lexical-047"; -var VERSION = "JS1_4"; -var TITLE = "for loops"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var counter = 0; - eval("for ( counter = 0\n" - + "counter <= 1\n" - + "counter++ )\n" - + "{\n" - + "result += \": got to inner loop\";\n" - + "}\n"); - -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "line breaks within a for expression" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-048.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-048.binjs deleted file mode 100644 index 5db347b431af..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-048.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-048.js b/js/src/jsapi-tests/binast/parser/tester/lexical-048.js deleted file mode 100644 index 788c3240ec90..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-048.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-048.js - Corresponds To: 7.8.1-1.js - ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertion - Description: - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "lexical-048"; -var VERSION = "JS1_4"; -var TITLE = "The Rules of Automatic Semicolon Insertion"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var counter = 0; - eval( "for ( counter = 0;\ncounter <= 1\ncounter++ ) {\nresult += \": got inside for loop\")"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "line breaks within a for expression" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-049.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-049.binjs deleted file mode 100644 index 53d2a5856246..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-049.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-049.js b/js/src/jsapi-tests/binast/parser/tester/lexical-049.js deleted file mode 100644 index ea2483fd8fb1..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-049.js +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-049 - Corresponds To: 7.8.1-1.js - ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertioin - Description: - Author: christine@netscape.com - Date: 15 september 1997 -*/ -var SECTION = "lexical-049"; -var VERSION = "JS1_4"; -var TITLE = "The Rules of Automatic Semicolon Insertion"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var counter = 0; - eval("for ( counter = 0\n" - + "counter <= 1;\n" - + "counter++ )\n" - + "{\n" - + "result += \": got inside for loop\";\n" - + "}\n"); - -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "line breaks within a for expression" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-050.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-050.binjs deleted file mode 100644 index 38c0cbdcfdef..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-050.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-050.js b/js/src/jsapi-tests/binast/parser/tester/lexical-050.js deleted file mode 100644 index d0079468a916..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-050.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-050.js - Corresponds to: 7.8.2-1-n.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "lexical-050"; -var VERSION = "JS1_4"; -var TITLE = "Examples of Automatic Semicolon Insertion"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("{ 1 2 } 3"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "{ 1 2 } 3" + - " (threw " + exception +")", - expect, - result ); - -test(); - - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-051.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-051.binjs deleted file mode 100644 index fa840f33e0af..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-051.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-051.js b/js/src/jsapi-tests/binast/parser/tester/lexical-051.js deleted file mode 100644 index 1fec695d642f..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-051.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-051.js - Corresponds to: 7.8.2-3-n.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "lexical-051"; -var VERSION = "JS1_4"; -var TITLE = "Examples of Automatic Semicolon Insertion"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("for (a; b\n) result += \": got to inner loop\";") - } catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "for (a; b\n)" + - " (threw " + exception +")", - expect, - result ); - -test(); - - - diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-052.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-052.binjs deleted file mode 100644 index 02ce208c76af..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-052.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-052.js b/js/src/jsapi-tests/binast/parser/tester/lexical-052.js deleted file mode 100644 index b134b9743095..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-052.js +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-052.js - Corresponds to: 7.8.2-4-n.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "lexical-052"; -var VERSION = "JS1_4"; -var TITLE = "Examples of Automatic Semicolon Insertion"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - MyFunction(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "calling return indirectly" + - " (threw " + exception +")", - expect, - result ); - -test(); - -function MyFunction() { - var s = "return"; - eval(s); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-053.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-053.binjs deleted file mode 100644 index 10394859b5cf..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-053.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-053.js b/js/src/jsapi-tests/binast/parser/tester/lexical-053.js deleted file mode 100644 index 8739afbadada..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-053.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-053.js - Corresponds to: 7.8.2-7-n.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "lexical-053"; -var VERSION = "JS1_4"; -var TITLE = "Examples of Automatic Semicolon Insertion"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - a = true - b = false - - eval('if (a > b)\nelse result += ": got to else statement"'); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "calling return indirectly" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-054.binjs b/js/src/jsapi-tests/binast/parser/tester/lexical-054.binjs deleted file mode 100644 index 142d4f35c604..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/lexical-054.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/lexical-054.js b/js/src/jsapi-tests/binast/parser/tester/lexical-054.js deleted file mode 100644 index 1b6e995c361d..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/lexical-054.js +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: lexical-054.js - Corresponds to: 7.8.2-7-n.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "lexical-054"; -var VERSION = "JS1_4"; -var TITLE = "Examples of Automatic Semicolon Insertion"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - a=0; - b=1; - c=2; - d=3; - eval("if (a > b)\nelse c = d"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "if (a > b)\nelse c = d" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/match-001.binjs b/js/src/jsapi-tests/binast/parser/tester/match-001.binjs deleted file mode 100644 index 075236aa2fd1..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/match-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/match-001.js b/js/src/jsapi-tests/binast/parser/tester/match-001.js deleted file mode 100644 index ab6082a1a7fd..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/match-001.js +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: String/match-001.js - * ECMA Section: 15.6.4.9 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ - -/* - * String.match( regexp ) - * - * If regexp is not an object of type RegExp, it is replaced with result - * of the expression new RegExp(regexp). Let string denote the result of - * converting the this value to a string. If regexp.global is false, - * return the result obtained by invoking RegExp.prototype.exec (see - * section 15.7.5.3) on regexp with string as parameter. - * - * Otherwise, set the regexp.lastIndex property to 0 and invoke - * RegExp.prototype.exec repeatedly until there is no match. If there is a - * match with an empty string (in other words, if the value of - * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. - * The value returned is an array with the properties 0 through n-1 - * corresponding to the first element of the result of each matching - * invocation of RegExp.prototype.exec. - * - * Note that the match function is intentionally generic; it does not - * require that its this value be a string object. Therefore, it can be - * transferred to other kinds of objects for use as a method. - */ - -var SECTION = "String/match-001.js"; -var VERSION = "ECMA_2"; -var TITLE = "String.prototype.match( regexp )"; - -startTest(); - -// the regexp argument is not a RegExp object -// this is not a string object - -// cases in which the regexp global property is false - -AddRegExpCases( 3, "3", "1234567890", 1, 2, ["3"] ); - -// cases in which the regexp object global property is true - -AddGlobalRegExpCases( /34/g, "/34/g", "343443444", 3, ["34", "34", "34"] ); -AddGlobalRegExpCases( /\d{1}/g, "/d{1}/g", "123456abcde7890", 10, - ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] ); - -AddGlobalRegExpCases( /\d{2}/g, "/d{2}/g", "123456abcde7890", 5, - ["12", "34", "56", "78", "90"] ); - -AddGlobalRegExpCases( /\D{2}/g, "/d{2}/g", "123456abcde7890", 2, - ["ab", "cd"] ); - -test(); - - -function AddRegExpCases( - regexp, str_regexp, string, length, index, matches_array ) { - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - length, - string.match(regexp).length ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").index", - index, - string.match(regexp).index ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").input", - string, - string.match(regexp).input ); - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } -} - -function AddGlobalRegExpCases( - regexp, str_regexp, string, length, matches_array ) { - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - length, - string.match(regexp).length ); - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } -} diff --git a/js/src/jsapi-tests/binast/parser/tester/match-002.binjs b/js/src/jsapi-tests/binast/parser/tester/match-002.binjs deleted file mode 100644 index 772363013e94..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/match-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/match-002.js b/js/src/jsapi-tests/binast/parser/tester/match-002.js deleted file mode 100644 index 21b832501700..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/match-002.js +++ /dev/null @@ -1,174 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: String/match-002.js - * ECMA Section: 15.6.4.9 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ - -/* - * String.match( regexp ) - * - * If regexp is not an object of type RegExp, it is replaced with result - * of the expression new RegExp(regexp). Let string denote the result of - * converting the this value to a string. If regexp.global is false, - * return the result obtained by invoking RegExp.prototype.exec (see - * section 15.7.5.3) on regexp with string as parameter. - * - * Otherwise, set the regexp.lastIndex property to 0 and invoke - * RegExp.prototype.exec repeatedly until there is no match. If there is a - * match with an empty string (in other words, if the value of - * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. - * The value returned is an array with the properties 0 through n-1 - * corresponding to the first element of the result of each matching - * invocation of RegExp.prototype.exec. - * - * Note that the match function is intentionally generic; it does not - * require that its this value be a string object. Therefore, it can be - * transferred to other kinds of objects for use as a method. - * - * This file tests cases in which regexp.global is false. Therefore, - * results should behave as regexp.exec with string passed as a parameter. - * - */ - -var SECTION = "String/match-002.js"; -var VERSION = "ECMA_2"; -var TITLE = "String.prototype.match( regexp )"; - -startTest(); - -// the regexp argument is not a RegExp object -// this is not a string object - -AddRegExpCases( /([\d]{5})([-\ ]?[\d]{4})?$/, - "/([\d]{5})([-\ ]?[\d]{4})?$/", - "Boston, Mass. 02134", - 14, - ["02134", "02134", undefined]); - -AddGlobalRegExpCases( /([\d]{5})([-\ ]?[\d]{4})?$/g, - "/([\d]{5})([-\ ]?[\d]{4})?$/g", - "Boston, Mass. 02134", - ["02134"]); - -// set the value of lastIndex -re = /([\d]{5})([-\ ]?[\d]{4})?$/; -re.lastIndex = 0; - -s = "Boston, MA 02134"; - -AddRegExpCases( re, - "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex =0", - s, - s.lastIndexOf("0"), - ["02134", "02134", undefined]); - - -re.lastIndex = s.length; - -AddRegExpCases( re, - "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + - s.length, - s, - s.lastIndexOf("0"), - ["02134", "02134", undefined] ); - -re.lastIndex = s.lastIndexOf("0"); - -AddRegExpCases( re, - "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + - s.lastIndexOf("0"), - s, - s.lastIndexOf("0"), - ["02134", "02134", undefined]); - -re.lastIndex = s.lastIndexOf("0") + 1; - -AddRegExpCases( re, - "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + - s.lastIndexOf("0") +1, - s, - s.lastIndexOf("0"), - ["02134", "02134", undefined]); - -test(); - -function AddRegExpCases( - regexp, str_regexp, string, index, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(string) == null || matches_array == null ) { - AddTestCase( - string + ".match(" + regexp +")", - matches_array, - string.match(regexp) ); - - return; - } - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - matches_array.length, - string.match(regexp).length ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").index", - index, - string.match(regexp).index ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").input", - string, - string.match(regexp).input ); - - var limit = matches_array.length > string.match(regexp).length ? - matches_array.length : - string.match(regexp).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } -} - -function AddGlobalRegExpCases( - regexp, str_regexp, string, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(string) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + string +")", - matches_array, - regexp.exec(string) ); - - return; - } - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - matches_array.length, - string.match(regexp).length ); - - var limit = matches_array.length > string.match(regexp).length ? - matches_array.length : - string.match(regexp).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } -} diff --git a/js/src/jsapi-tests/binast/parser/tester/match-003.binjs b/js/src/jsapi-tests/binast/parser/tester/match-003.binjs deleted file mode 100644 index 1422b2f79d54..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/match-003.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/match-003.js b/js/src/jsapi-tests/binast/parser/tester/match-003.js deleted file mode 100644 index 24453e621cc9..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/match-003.js +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: String/match-003.js - * ECMA Section: 15.6.4.9 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ - -/* - * String.match( regexp ) - * - * If regexp is not an object of type RegExp, it is replaced with result - * of the expression new RegExp(regexp). Let string denote the result of - * converting the this value to a string. If regexp.global is false, - * return the result obtained by invoking RegExp.prototype.exec (see - * section 15.7.5.3) on regexp with string as parameter. - * - * Otherwise, set the regexp.lastIndex property to 0 and invoke - * RegExp.prototype.exec repeatedly until there is no match. If there is a - * match with an empty string (in other words, if the value of - * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. - * The value returned is an array with the properties 0 through n-1 - * corresponding to the first element of the result of each matching - * invocation of RegExp.prototype.exec. - * - * Note that the match function is intentionally generic; it does not - * require that its this value be a string object. Therefore, it can be - * transferred to other kinds of objects for use as a method. - */ - -var SECTION = "String/match-003.js"; -var VERSION = "ECMA_2"; -var TITLE = "String.prototype.match( regexp )"; - -startTest(); - -// the regexp argument is not a RegExp object -// this is not a string object - - -// [if regexp.global is true] set the regexp.lastIndex property to 0 and -// invoke RegExp.prototype.exec repeatedly until there is no match. If -// there is a match with an empty string (in other words, if the value of -// regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. -// The value returned is an array with the properties 0 through n-1 -// corresponding to the first element of the result of each matching invocation -// of RegExp.prototype.exec. - - -// set the value of lastIndex -re = /([\d]{5})([-\ ]?[\d]{4})?$/g; - - -s = "Boston, MA 02134"; - -AddGlobalRegExpCases( re, - "re = " + re, - s, - ["02134" ]); - -re.lastIndex = 0; - -AddGlobalRegExpCases( - re, - "re = " + re + "; re.lastIndex = 0 ", - s, - ["02134"]); - - -re.lastIndex = s.length; - -AddGlobalRegExpCases( - re, - "re = " + re + "; re.lastIndex = " + s.length, - s, - ["02134"] ); - -re.lastIndex = s.lastIndexOf("0"); - -AddGlobalRegExpCases( - re, - "re = "+ re +"; re.lastIndex = " + s.lastIndexOf("0"), - s, - ["02134"]); - -re.lastIndex = s.lastIndexOf("0") + 1; - -AddGlobalRegExpCases( - re, - "re = " +re+ "; re.lastIndex = " + (s.lastIndexOf("0") +1), - s, - ["02134"]); - -test(); - -function AddGlobalRegExpCases( - regexp, str_regexp, string, matches_array ) { - - // prevent a runtime error - - if ( string.match(regexp) == null || matches_array == null ) { - AddTestCase( - string + ".match(" + str_regexp +")", - matches_array, - string.match(regexp) ); - - return; - } - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - matches_array.length, - string.match(regexp).length ); - - var limit = matches_array.length > string.match(regexp).length ? - matches_array.length : - string.match(regexp).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } -} diff --git a/js/src/jsapi-tests/binast/parser/tester/match-004.binjs b/js/src/jsapi-tests/binast/parser/tester/match-004.binjs deleted file mode 100644 index 7643a2be422b..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/match-004.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/match-004.js b/js/src/jsapi-tests/binast/parser/tester/match-004.js deleted file mode 100644 index 7c17396afa75..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/match-004.js +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: String/match-004.js - * ECMA Section: 15.6.4.9 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ - -/* - * String.match( regexp ) - * - * If regexp is not an object of type RegExp, it is replaced with result - * of the expression new RegExp(regexp). Let string denote the result of - * converting the this value to a string. If regexp.global is false, - * return the result obtained by invoking RegExp.prototype.exec (see - * section 15.7.5.3) on regexp with string as parameter. - * - * Otherwise, set the regexp.lastIndex property to 0 and invoke - * RegExp.prototype.exec repeatedly until there is no match. If there is a - * match with an empty string (in other words, if the value of - * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. - * The value returned is an array with the properties 0 through n-1 - * corresponding to the first element of the result of each matching - * invocation of RegExp.prototype.exec. - * - * Note that the match function is intentionally generic; it does not - * require that its this value be a string object. Therefore, it can be - * transferred to other kinds of objects for use as a method. - * - * - * The match function should be intentionally generic, and not require - * this to be a string. - * - */ - -var SECTION = "String/match-004.js"; -var VERSION = "ECMA_2"; -var TITLE = "String.prototype.match( regexp )"; - -var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=345818"; - -startTest(); - -// set the value of lastIndex -re = /0./; -s = 10203040506070809000; - -Number.prototype.match = String.prototype.match; - -AddRegExpCases( re, - "re = " + re , - s, - String(s), - 1, - ["02"]); - - -re.lastIndex = 0; -AddRegExpCases( re, - "re = " + re +" [lastIndex is " + re.lastIndex+"]", - s, - String(s), - 1, - ["02"]); -/* - -re.lastIndex = s.length; - -AddRegExpCases( re, -"re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + -s.length, -s, -s.lastIndexOf("0"), -null ); - -re.lastIndex = s.lastIndexOf("0"); - -AddRegExpCases( re, -"re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + -s.lastIndexOf("0"), -s, -s.lastIndexOf("0"), -["02134"]); - -re.lastIndex = s.lastIndexOf("0") + 1; - -AddRegExpCases( re, -"re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + -s.lastIndexOf("0") +1, -s, -0, -null); -*/ -test(); - -function AddRegExpCases( - regexp, str_regexp, string, str_string, index, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(string) == null || matches_array == null ) { - AddTestCase( - string + ".match(" + regexp +")", - matches_array, - string.match(regexp) ); - - return; - } - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - matches_array.length, - string.match(regexp).length ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").index", - index, - string.match(regexp).index ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").input", - str_string, - string.match(regexp).input ); - - var limit = matches_array.length > string.match(regexp).length ? - matches_array.length : - string.match(regexp).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } -} - -function AddGlobalRegExpCases( - regexp, str_regexp, string, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(string) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + string +")", - matches_array, - regexp.exec(string) ); - - return; - } - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - matches_array.length, - string.match(regexp).length ); - - var limit = matches_array.length > string.match(regexp).length ? - matches_array.length : - string.match(regexp).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } -} diff --git a/js/src/jsapi-tests/binast/parser/tester/multiline-001.binjs b/js/src/jsapi-tests/binast/parser/tester/multiline-001.binjs deleted file mode 100644 index 7c56b53f6e51..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/multiline-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/multiline-001.js b/js/src/jsapi-tests/binast/parser/tester/multiline-001.js deleted file mode 100644 index 9e69022d5d7b..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/multiline-001.js +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: RegExp/multiline-001.js - * ECMA Section: - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Date: 19 February 1999 - */ - -var SECTION = "RegExp/multiline-001"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp: multiline flag"; -var BUGNUMBER="343901"; - -startTest(); - -var woodpeckers = "ivory-billed\ndowny\nhairy\nacorn\nyellow-bellied sapsucker\n" + - "northern flicker\npileated\n"; - -AddRegExpCases( /.*[y]$/m, woodpeckers, woodpeckers.indexOf("downy"), ["downy"] ); - -AddRegExpCases( /.*[d]$/m, woodpeckers, woodpeckers.indexOf("ivory-billed"), ["ivory-billed"] ); - -test(); - - -function AddRegExpCases -( regexp, pattern, index, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } - - AddTestCase( - regexp.toString() + ".exec(" + pattern +").length", - matches_array.length, - regexp.exec(pattern).length ); - - AddTestCase( - regexp.toString() + ".exec(" + pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - regexp + ".exec(" + pattern +").input", - pattern, - regexp.exec(pattern).input ); - - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - regexp + ".exec(" + pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } -} diff --git a/js/src/jsapi-tests/binast/parser/tester/number-001.binjs b/js/src/jsapi-tests/binast/parser/tester/number-001.binjs deleted file mode 100644 index dea41480451c..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/number-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/number-001.js b/js/src/jsapi-tests/binast/parser/tester/number-001.js deleted file mode 100644 index 37ba1b798bc5..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/number-001.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: number-001 - Corresponds To: 15.7.4.2-2-n.js - ECMA Section: 15.7.4.2.2 Number.prototype.toString() - Description: - If the radix is the number 10 or not supplied, then this number value is - given as an argument to the ToString operator; the resulting string value - is returned. - - If the radix is supplied and is an integer from 2 to 36, but not 10, the - result is a string, the choice of which is implementation dependent. - - The toString function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. - - Author: christine@netscape.com - Date: 16 september 1997 -*/ -var SECTION = "number-001"; -var VERSION = "JS1_4"; -var TITLE = "Exceptions for Number.toString()"; - -startTest(); -writeHeaderToLog( SECTION + " Number.prototype.toString()"); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - object= new Object(); - object.toString = Number.prototype.toString; - result = object.toString(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "object = new Object(); object.toString = Number.prototype.toString; object.toString()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/number-002.binjs b/js/src/jsapi-tests/binast/parser/tester/number-002.binjs deleted file mode 100644 index f8d2838668da..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/number-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/number-002.js b/js/src/jsapi-tests/binast/parser/tester/number-002.js deleted file mode 100644 index 5f4462e043f8..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/number-002.js +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: number-002.js - Corresponds To: ecma/Number/15.7.4.3-2-n.js - ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() - Description: - Returns this number value. - - The valueOf function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. - - Author: christine@netscape.com - Date: 16 september 1997 -*/ -var SECTION = "number-002"; -var VERSION = "JS1_4"; -var TITLE = "Exceptions for Number.valueOf()"; - -startTest(); -writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - object= new Object(); - object.toString = Number.prototype.valueOf; - result = object.toString(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "object = new Object(); object.valueOf = Number.prototype.valueOf; object.valueOf()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/number-003.binjs b/js/src/jsapi-tests/binast/parser/tester/number-003.binjs deleted file mode 100644 index 5ff1d672080e..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/number-003.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/number-003.js b/js/src/jsapi-tests/binast/parser/tester/number-003.js deleted file mode 100644 index 8d0ad83db006..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/number-003.js +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: number-003.js - Corresponds To: 15.7.4.3-3.js - ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() - Description: - Returns this number value. - - The valueOf function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. - - Author: christine@netscape.com - Date: 16 september 1997 -*/ -var SECTION = "number-003"; -var VERSION = "JS1_4"; -var TITLE = "Exceptions for Number.valueOf()"; - -startTest(); -writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - VALUE_OF = Number.prototype.valueOf; - OBJECT = new String("Infinity"); - OBJECT.valueOf = VALUE_OF; - result = OBJECT.valueOf(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "Assigning Number.prototype.valueOf as the valueOf of a String object " + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/octal-001.binjs b/js/src/jsapi-tests/binast/parser/tester/octal-001.binjs deleted file mode 100644 index 5a3c602eecff..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/octal-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/octal-001.js b/js/src/jsapi-tests/binast/parser/tester/octal-001.js deleted file mode 100644 index 0aa1d040746e..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/octal-001.js +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: RegExp/octal-001.js - * ECMA Section: 15.7.1 - * Description: Based on ECMA 2 Draft 7 February 1999 - * Simple test cases for matching OctalEscapeSequences. - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/octal-001.js"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp patterns that contain OctalEscapeSequences"; -var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346196"; - -startTest(); - - -// backreference -AddRegExpCases( - /(.)\1/, - "/(.)\\1/", - "HI!!", - "HI!", - 2, - ["!!", "!"] ); - -test(); - -function AddRegExpCases( - regexp, str_regexp, pattern, str_pattern, index, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + str_pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } - AddTestCase( - str_regexp + ".exec(" + str_pattern +").length", - matches_array.length, - regexp.exec(pattern).length ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").input", - pattern, - regexp.exec(pattern).input ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").toString()", - matches_array.toString(), - regexp.exec(pattern).toString() ); -/* - var limit = matches_array.length > regexp.exec(pattern).length - ? matches_array.length - : regexp.exec(pattern).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - str_regexp + ".exec(" + str_pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } -*/ -} diff --git a/js/src/jsapi-tests/binast/parser/tester/octal-002.binjs b/js/src/jsapi-tests/binast/parser/tester/octal-002.binjs deleted file mode 100644 index 3a42bcc33bef..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/octal-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/octal-002.js b/js/src/jsapi-tests/binast/parser/tester/octal-002.js deleted file mode 100644 index 309fff473e17..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/octal-002.js +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: RegExp/octal-002.js - * ECMA Section: 15.7.1 - * Description: Based on ECMA 2 Draft 7 February 1999 - * Simple test cases for matching OctalEscapeSequences. - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/octal-002.js"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp patterns that contain OctalEscapeSequences"; -var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346189"; - -startTest(); - -// backreference -AddRegExpCases( - /(.)(.)(.)(.)(.)(.)(.)(.)\8/, - "/(.)(.)(.)(.)(.)(.)(.)(.)\\8", - "aabbccaaabbbccc", - "aabbccaaabbbccc", - 0, - ["aabbccaaa", "a", "a", "b", "b", "c", "c", "a", "a"] ); - -AddRegExpCases( - /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9/, - "/(.)(.)(.)(.)(.)(.)(.)(.)\\9", - "aabbccaabbcc", - "aabbccaabbcc", - 0, - ["aabbccaabb", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); - -AddRegExpCases( - /(.)(.)(.)(.)(.)(.)(.)(.)(.)\8/, - "/(.)(.)(.)(.)(.)(.)(.)(.)(.)\\8", - "aabbccaababcc", - "aabbccaababcc", - 0, - ["aabbccaaba", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); - -test(); - -function AddRegExpCases( - regexp, str_regexp, pattern, str_pattern, index, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + str_pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } - AddTestCase( - str_regexp + ".exec(" + str_pattern +").length", - matches_array.length, - regexp.exec(pattern).length ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").input", - pattern, - regexp.exec(pattern).input ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").toString()", - matches_array.toString(), - regexp.exec(pattern).toString() ); -/* - var limit = matches_array.length > regexp.exec(pattern).length - ? matches_array.length - : regexp.exec(pattern).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - str_regexp + ".exec(" + str_pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } -*/ -} diff --git a/js/src/jsapi-tests/binast/parser/tester/octal-003.binjs b/js/src/jsapi-tests/binast/parser/tester/octal-003.binjs deleted file mode 100644 index c1c1dd331e51..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/octal-003.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/octal-003.js b/js/src/jsapi-tests/binast/parser/tester/octal-003.js deleted file mode 100644 index a73d7d40e232..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/octal-003.js +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: RegExp/octal-003.js - * ECMA Section: 15.7.1 - * Description: Based on ECMA 2 Draft 7 February 1999 - * Simple test cases for matching OctalEscapeSequences. - * Author: christine@netscape.com - * Date: 19 February 1999 - * - * Revised: 02 August 2002 - * Author: pschwartau@netscape.com - * - * WHY: the original test expected the regexp /.\011/ - * to match 'a' + String.fromCharCode(0) + '11' - * - * This is incorrect: the string is a 4-character string consisting of - * the characters <'a'>, , <'1'>, <'1'>. By contrast, the \011 in the - * regexp should be parsed as a single token: it is the octal escape sequence - * for the horizontal tab character '\t' === '\u0009' === '\x09' === '\011'. - * - * So the regexp consists of 2 characters: , <'\t'>. - * There is no match between the regexp and the string. - * - * See the testcase ecma_3/RegExp/octal-002.js for an elaboration. - * - */ -var SECTION = "RegExp/octal-003.js"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp patterns that contain OctalEscapeSequences"; -var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346132"; - -startTest(); - -AddRegExpCases( /.\011/, "/\\011/", "a" + String.fromCharCode(0) + "11", "a\\011", 0, null ); - -test(); - -function AddRegExpCases( - regexp, str_regexp, pattern, str_pattern, index, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + str_pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } - AddTestCase( - str_regexp + ".exec(" + str_pattern +").length", - matches_array.length, - regexp.exec(pattern).length ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").input", - escape(pattern), - escape(regexp.exec(pattern).input) ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").toString()", - matches_array.toString(), - escape(regexp.exec(pattern).toString()) ); - - var limit = matches_array.length > regexp.exec(pattern).length - ? matches_array.length - : regexp.exec(pattern).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - str_regexp + ".exec(" + str_pattern +")[" + matches +"]", - matches_array[matches], - escape(regexp.exec(pattern)[matches]) ); - } - -} diff --git a/js/src/jsapi-tests/binast/parser/tester/properties-001.binjs b/js/src/jsapi-tests/binast/parser/tester/properties-001.binjs deleted file mode 100644 index f520e8914f2b..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/properties-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/properties-001.js b/js/src/jsapi-tests/binast/parser/tester/properties-001.js deleted file mode 100644 index b0ee18e209ea..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/properties-001.js +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: RegExp/properties-001.js - * ECMA Section: 15.7.6.js - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/properties-001.js"; -var VERSION = "ECMA_2"; -var TITLE = "Properties of RegExp Instances"; -var BUGNUMBER =""; - -startTest(); - -AddRegExpCases( new RegExp, "(?:)", false, false, false, 0 ); -AddRegExpCases( /.*/, ".*", false, false, false, 0 ); -AddRegExpCases( /[\d]{5}/g, "[\\d]{5}", true, false, false, 0 ); -AddRegExpCases( /[\S]?$/i, "[\\S]?$", false, true, false, 0 ); -AddRegExpCases( /^([a-z]*)[^\w\s\f\n\r]+/m, "^([a-z]*)[^\\w\\s\\f\\n\\r]+", false, false, true, 0 ); -AddRegExpCases( /[\D]{1,5}[\ -][\d]/gi, "[\\D]{1,5}[\\ -][\\d]", true, true, false, 0 ); -AddRegExpCases( /[a-zA-Z0-9]*/gm, "[a-zA-Z0-9]*", true, false, true, 0 ); -AddRegExpCases( /x|y|z/gim, "x|y|z", true, true, true, 0 ); - -AddRegExpCases( /\u0051/im, "\\u0051", false, true, true, 0 ); -AddRegExpCases( /\x45/gm, "\\x45", true, false, true, 0 ); -AddRegExpCases( /\097/gi, "\\097", true, true, false, 0 ); - -test(); - -function AddRegExpCases( re, s, g, i, m, l ) { - - AddTestCase( re + ".test == RegExp.prototype.test", - true, - re.test == RegExp.prototype.test ); - - AddTestCase( re + ".toString == RegExp.prototype.toString", - true, - re.toString == RegExp.prototype.toString ); - - AddTestCase( re + ".contructor == RegExp.prototype.constructor", - true, - re.constructor == RegExp.prototype.constructor ); - - AddTestCase( re + ".compile == RegExp.prototype.compile", - true, - re.compile == RegExp.prototype.compile ); - - AddTestCase( re + ".exec == RegExp.prototype.exec", - true, - re.exec == RegExp.prototype.exec ); - - // properties - - AddTestCase( re + ".source", - s, - re.source ); - -/* - * http://bugzilla.mozilla.org/show_bug.cgi?id=225550 changed - * the behavior of toString() and toSource() on empty regexps. - * So branch if |s| is the empty string - - */ - var S = s? s : '(?:)'; - - AddTestCase( re + ".toString()", - "/" + S +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), - re.toString() ); - - AddTestCase( re + ".global", - g, - re.global ); - - AddTestCase( re + ".ignoreCase", - i, - re.ignoreCase ); - - AddTestCase( re + ".multiline", - m, - re.multiline); - - AddTestCase( re + ".lastIndex", - l, - re.lastIndex ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/properties-002.binjs b/js/src/jsapi-tests/binast/parser/tester/properties-002.binjs deleted file mode 100644 index e657089d33e6..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/properties-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/properties-002.js b/js/src/jsapi-tests/binast/parser/tester/properties-002.js deleted file mode 100644 index 330fe4bd54da..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/properties-002.js +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: RegExp/properties-002.js - * ECMA Section: 15.7.6.js - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -//----------------------------------------------------------------------------- -var SECTION = "RegExp/properties-002.js"; -var VERSION = "ECMA_2"; -var TITLE = "Properties of RegExp Instances"; -var BUGNUMBER ="124339"; - -startTest(); - -re_1 = /\cA?/g; -re_1.lastIndex = Math.pow(2,31); -AddRegExpCases( re_1, "\\cA?", true, false, false, Math.pow(2,31) ); - -re_2 = /\w*/i; -re_2.lastIndex = Math.pow(2,32) -1; -AddRegExpCases( re_2, "\\w*", false, true, false, Math.pow(2,32)-1 ); - -re_3 = /\*{0,80}/m; -re_3.lastIndex = Math.pow(2,31) -1; -AddRegExpCases( re_3, "\\*{0,80}", false, false, true, Math.pow(2,31) -1 ); - -re_4 = /^./gim; -re_4.lastIndex = Math.pow(2,30) -1; -AddRegExpCases( re_4, "^.", true, true, true, Math.pow(2,30) -1 ); - -re_5 = /\B/; -re_5.lastIndex = Math.pow(2,30); -AddRegExpCases( re_5, "\\B", false, false, false, Math.pow(2,30) ); - -/* - * Brendan: "need to test cases Math.pow(2,32) and greater to see - * whether they round-trip." Reason: thanks to the work done in - * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, lastIndex - * is now stored as a double instead of a uint32_t (unsigned integer). - * - * Note 2^32 -1 is the upper bound for uint32's, but doubles can go - * all the way up to Number.MAX_VALUE. So that's why we need cases - * between those two numbers. - * - */ -re_6 = /\B/; -re_6.lastIndex = Math.pow(2,32); -AddRegExpCases( re_6, "\\B", false, false, false, Math.pow(2,32) ); - -re_7 = /\B/; -re_7.lastIndex = Math.pow(2,32) + 1; -AddRegExpCases( re_7, "\\B", false, false, false, Math.pow(2,32) + 1 ); - -re_8 = /\B/; -re_8.lastIndex = Math.pow(2,32) * 2; -AddRegExpCases( re_8, "\\B", false, false, false, Math.pow(2,32) * 2 ); - -re_9 = /\B/; -re_9.lastIndex = Math.pow(2,40); -AddRegExpCases( re_9, "\\B", false, false, false, Math.pow(2,40) ); - -re_10 = /\B/; -re_10.lastIndex = Number.MAX_VALUE; -AddRegExpCases( re_10, "\\B", false, false, false, Number.MAX_VALUE ); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function AddRegExpCases( re, s, g, i, m, l ){ - - AddTestCase( re + ".test == RegExp.prototype.test", - true, - re.test == RegExp.prototype.test ); - - AddTestCase( re + ".toString == RegExp.prototype.toString", - true, - re.toString == RegExp.prototype.toString ); - - AddTestCase( re + ".contructor == RegExp.prototype.constructor", - true, - re.constructor == RegExp.prototype.constructor ); - - AddTestCase( re + ".compile == RegExp.prototype.compile", - true, - re.compile == RegExp.prototype.compile ); - - AddTestCase( re + ".exec == RegExp.prototype.exec", - true, - re.exec == RegExp.prototype.exec ); - - // properties - - AddTestCase( re + ".source", - s, - re.source ); - - AddTestCase( re + ".toString()", - "/" + s +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), - re.toString() ); - - AddTestCase( re + ".global", - g, - re.global ); - - AddTestCase( re + ".ignoreCase", - i, - re.ignoreCase ); - - AddTestCase( re + ".multiline", - m, - re.multiline); - - AddTestCase( re + ".lastIndex", - l, - re.lastIndex ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/regexp-enumerate-001.binjs b/js/src/jsapi-tests/binast/parser/tester/regexp-enumerate-001.binjs deleted file mode 100644 index d598f086e8c8..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/regexp-enumerate-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/regexp-enumerate-001.js b/js/src/jsapi-tests/binast/parser/tester/regexp-enumerate-001.js deleted file mode 100644 index d1f3f213e59f..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/regexp-enumerate-001.js +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: regexp-enumerate-001.js - ECMA V2 Section: - Description: Regression Test. - - If instance Native Object have properties that are enumerable, - JavaScript enumerated through the properties twice. This only - happened if objects had been instantiated, but their properties - had not been enumerated. ie, the object inherited properties - from its prototype that are enumerated. - - In the core JavaScript, this is only a problem with RegExp - objects, since the inherited properties of most core JavaScript - objects are not enumerated. - - Author: christine@netscape.com, pschwartau@netscape.com - Date: 12 November 1997 - Modified: 14 July 2002 - Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155291 - ECMA-262 Ed.3 Sections 15.10.7.1 through 15.10.7.5 - RegExp properties should be DontEnum - * - */ -// onerror = err; - -var SECTION = "regexp-enumerate-001"; -var VERSION = "ECMA_2"; -var TITLE = "Regression Test for Enumerating Properties"; - -var BUGNUMBER="339403"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -/* - * This test expects RegExp instances to have four enumerated properties: - * source, global, ignoreCase, and lastIndex - * - * 99.01.25: now they also have a multiLine instance property. - * - */ - - -var r = new RegExp(); - -var e = new Array(); - -var t = new TestRegExp(); - -for ( p in r ) { e[e.length] = { property:p, value:r[p] }; t.addProperty( p, r[p]) }; - -new TestCase( SECTION, - "r = new RegExp(); e = new Array(); "+ - "for ( p in r ) { e[e.length] = { property:p, value:r[p] }; e.length", - 0, - e.length ); - -test(); - -function TestRegExp() { - this.addProperty = addProperty; -} -function addProperty(name, value) { - var pass = false; - - if ( eval("this."+name) != void 0 ) { - pass = true; - } else { - eval( "this."+ name+" = "+ false ); - } - - new TestCase( SECTION, - "Property: " + name +" already enumerated?", - false, - pass ); - - if ( gTestcases[ gTestcases.length-1].passed == false ) { - gTestcases[gTestcases.length-1].reason = "property already enumerated"; - - } - -} diff --git a/js/src/jsapi-tests/binast/parser/tester/regexp-literals-001.binjs b/js/src/jsapi-tests/binast/parser/tester/regexp-literals-001.binjs deleted file mode 100644 index ed112879b606..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/regexp-literals-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/regexp-literals-001.js b/js/src/jsapi-tests/binast/parser/tester/regexp-literals-001.js deleted file mode 100644 index cb2448d1ec59..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/regexp-literals-001.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: LexicalConventions/regexp-literals-001.js - * ECMA Section: 7.8.5 - * Description: - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "LexicalConventions/regexp-literals-001.js"; -var VERSION = "ECMA_2"; -var TITLE = "Regular Expression Literals"; - -startTest(); - -// Regular Expression Literals may not be empty; // should be regarded -// as a comment, not a RegExp literal. - -s = //; - - "passed"; - -AddTestCase( - "// should be a comment, not a regular expression literal", - "passed", - String(s)); - -AddTestCase( - "// typeof object should be type of object declared on following line", - "passed", - (typeof s) == "string" ? "passed" : "failed" ); - -AddTestCase( - "// should not return an object of the type RegExp", - "passed", - (typeof s == "object") ? "failed" : "passed" ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/regexp-literals-002.binjs b/js/src/jsapi-tests/binast/parser/tester/regexp-literals-002.binjs deleted file mode 100644 index a3ccf7cc93a6..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/regexp-literals-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/regexp-literals-002.js b/js/src/jsapi-tests/binast/parser/tester/regexp-literals-002.js deleted file mode 100644 index 5b256dd22d9f..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/regexp-literals-002.js +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: LexicalConventions/regexp-literals-002.js - * ECMA Section: 7.8.5 - * Description: Based on ECMA 2 Draft 8 October 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "LexicalConventions/regexp-literals-002.js"; -var VERSION = "ECMA_2"; -var TITLE = "Regular Expression Literals"; - -startTest(); - -// A regular expression literal represents an object of type RegExp. - -AddTestCase( - "// A regular expression literal represents an object of type RegExp.", - "true", - (/x*/ instanceof RegExp).toString() ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/regress-001.binjs b/js/src/jsapi-tests/binast/parser/tester/regress-001.binjs deleted file mode 100644 index c013b642ee7c..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/regress-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/regress-001.js b/js/src/jsapi-tests/binast/parser/tester/regress-001.js deleted file mode 100644 index 9282cd806175..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/regress-001.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: RegExp/regress-001.js - * ECMA Section: N/A - * Description: Regression test case: - * JS regexp anchoring on empty match bug - * http://bugzilla.mozilla.org/show_bug.cgi?id=2157 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/hex-001.js"; -var VERSION = "ECMA_2"; -var TITLE = "JS regexp anchoring on empty match bug"; -var BUGNUMBER = "2157"; - -startTest(); - -AddRegExpCases( /a||b/.exec(''), - "/a||b/.exec('')", - 1, - [''] ); - -test(); - -function AddRegExpCases( regexp, str_regexp, length, matches_array ) { - - AddTestCase( - "( " + str_regexp + " ).length", - regexp.length, - regexp.length ); - - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - "( " + str_regexp + " )[" + matches +"]", - matches_array[matches], - regexp[matches] ); - } -} diff --git a/js/src/jsapi-tests/binast/parser/tester/regress-7635.binjs b/js/src/jsapi-tests/binast/parser/tester/regress-7635.binjs deleted file mode 100644 index 87be12f962e3..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/regress-7635.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/regress-7635.js b/js/src/jsapi-tests/binast/parser/tester/regress-7635.js deleted file mode 100644 index 7ea94e037ae9..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/regress-7635.js +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: regress-7635.js - * Reference: http://bugzilla.mozilla.org/show_bug.cgi?id=7635 - * Description: instanceof tweaks - * Author: - */ - -var SECTION = "instanceof"; // provide a document reference (ie, ECMA section) -var VERSION = "ECMA_2"; // Version of JavaScript or ECMA -var TITLE = "Regression test for Bugzilla #7635"; // Provide ECMA section title or a description -var BUGNUMBER = "7635"; // Provide URL to bugsplat or bugzilla report - -startTest(); // leave this alone - -/* - * Calls to AddTestCase here. AddTestCase is a function that is defined - * in shell.js and takes three arguments: - * - a string representation of what is being tested - * - the expected result - * - the actual result - * - * For example, a test might look like this: - * - * var zip = /[\d]{5}$/; - * - * AddTestCase( - * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test - * "02134", // expected result - * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result - * - */ - -function Foo() {} -theproto = {}; -Foo.prototype = theproto - theproto instanceof Foo - - - AddTestCase( "function Foo() {}; theproto = {}; Foo.prototype = theproto; theproto instanceof Foo", - false, - theproto instanceof Foo ); - -var f = new Function(); - -AddTestCase( "var f = new Function(); f instanceof f", false, f instanceof f ); - - -test(); // leave this alone. this executes the test cases and -// displays results. diff --git a/js/src/jsapi-tests/binast/parser/tester/split-001.binjs b/js/src/jsapi-tests/binast/parser/tester/split-001.binjs deleted file mode 100644 index c9118cc73707..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/split-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/split-001.js b/js/src/jsapi-tests/binast/parser/tester/split-001.js deleted file mode 100644 index f8e2c762a20b..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/split-001.js +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: String/split-001.js - * ECMA Section: 15.6.4.9 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ - -/* - * Since regular expressions have been part of JavaScript since 1.2, there - * are already tests for regular expressions in the js1_2/regexp folder. - * - * These new tests try to supplement the existing tests, and verify that - * our implementation of RegExp conforms to the ECMA specification, but - * does not try to be as exhaustive as in previous tests. - * - * The [,limit] argument to String.split is new, and not covered in any - * existing tests. - * - * String.split cases are covered in ecma/String/15.5.4.8-*.js. - * String.split where separator is a RegExp are in - * js1_2/regexp/string_split.js - * - */ - -var SECTION = "ecma_2/String/split-001.js"; -var VERSION = "ECMA_2"; -var TITLE = "String.prototype.split( regexp, [,limit] )"; - -startTest(); - -// the separator is not supplied -// separator is undefined -// separator is an empty string - -AddSplitCases( "splitme", "", "''", ["s", "p", "l", "i", "t", "m", "e"] ); -AddSplitCases( "splitme", new RegExp(), "new RegExp()", ["s", "p", "l", "i", "t", "m", "e"] ); - -// separartor is a regexp -// separator regexp value global setting is set -// string is an empty string -// if separator is an empty string, split each by character - -// this is not a String object - -// limit is not a number -// limit is undefined -// limit is larger than 2^32-1 -// limit is a negative number - -test(); - -function AddSplitCases( string, separator, str_sep, split_array ) { - - // verify that the result of split is an object of type Array - AddTestCase( - "( " + string + " ).split(" + str_sep +").constructor == Array", - true, - string.split(separator).constructor == Array ); - - // check the number of items in the array - AddTestCase( - "( " + string + " ).split(" + str_sep +").length", - split_array.length, - string.split(separator).length ); - - // check the value of each array item - var limit = (split_array.length > string.split(separator).length ) - ? split_array.length : string.split(separator).length; - - for ( var matches = 0; matches < split_array.length; matches++ ) { - AddTestCase( - "( " + string + " ).split(" + str_sep +")[" + matches +"]", - split_array[matches], - string.split( separator )[matches] ); - } -} - -function AddLimitedSplitCases( - string, separator, str_sep, limit, str_limit, split_array ) { - - // verify that the result of split is an object of type Array - - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + str_limit + - " ).constructor == Array", - true, - string.split(separator, limit).constructor == Array ); - - // check the length of the array - - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + str_limit + " ).length", - length, - string.split(separator).length ); - - // check the value of each array item - - for ( var matches = 0; matches < split_array.length; matches++ ) { - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + str_limit + " )[" + matches +"]", - split_array[matches], - string.split( separator )[matches] ); - } -} diff --git a/js/src/jsapi-tests/binast/parser/tester/split-002.binjs b/js/src/jsapi-tests/binast/parser/tester/split-002.binjs deleted file mode 100644 index 918343cc2e06..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/split-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/split-002.js b/js/src/jsapi-tests/binast/parser/tester/split-002.js deleted file mode 100644 index 8f14e4facbd5..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/split-002.js +++ /dev/null @@ -1,270 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: String/split-002.js - * ECMA Section: 15.6.4.9 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ - -/* - * Since regular expressions have been part of JavaScript since 1.2, there - * are already tests for regular expressions in the js1_2/regexp folder. - * - * These new tests try to supplement the existing tests, and verify that - * our implementation of RegExp conforms to the ECMA specification, but - * does not try to be as exhaustive as in previous tests. - * - * The [,limit] argument to String.split is new, and not covered in any - * existing tests. - * - * String.split cases are covered in ecma/String/15.5.4.8-*.js. - * String.split where separator is a RegExp are in - * js1_2/regexp/string_split.js - * - */ - -var SECTION = "ecma_2/String/split-002.js"; -var VERSION = "ECMA_2"; -var TITLE = "String.prototype.split( regexp, [,limit] )"; - -startTest(); - -// the separator is not supplied -// separator is undefined -// separator is an empty string - -// AddSplitCases( "splitme", "", "''", ["s", "p", "l", "i", "t", "m", "e"] ); -// AddSplitCases( "splitme", new RegExp(), "new RegExp()", ["s", "p", "l", "i", "t", "m", "e"] ); - -// separator is an empty regexp -// separator is not supplied - -CompareSplit( "hello", "ll" ); - -CompareSplit( "hello", "l" ); -CompareSplit( "hello", "x" ); -CompareSplit( "hello", "h" ); -CompareSplit( "hello", "o" ); -CompareSplit( "hello", "hello" ); -CompareSplit( "hello", undefined ); - -CompareSplit( "hello", ""); -CompareSplit( "hello", "hellothere" ); - -CompareSplit( new String("hello" ) ); - - -Number.prototype.split = String.prototype.split; - -CompareSplit( new Number(100111122133144155), 1 ); -CompareSplitWithLimit(new Number(100111122133144155), 1, 1 ); - -CompareSplitWithLimit(new Number(100111122133144155), 1, 2 ); -CompareSplitWithLimit(new Number(100111122133144155), 1, 0 ); -CompareSplitWithLimit(new Number(100111122133144155), 1, 100 ); -CompareSplitWithLimit(new Number(100111122133144155), 1, void 0 ); -CompareSplitWithLimit(new Number(100111122133144155), 1, Math.pow(2,32)-1 ); -CompareSplitWithLimit(new Number(100111122133144155), 1, "boo" ); -CompareSplitWithLimit(new Number(100111122133144155), 1, -(Math.pow(2,32)-1) ); -CompareSplitWithLimit( "hello", "l", NaN ); -CompareSplitWithLimit( "hello", "l", 0 ); -CompareSplitWithLimit( "hello", "l", 1 ); -CompareSplitWithLimit( "hello", "l", 2 ); -CompareSplitWithLimit( "hello", "l", 3 ); -CompareSplitWithLimit( "hello", "l", 4 ); - - -/* - CompareSplitWithLimit( "hello", "ll", 0 ); - CompareSplitWithLimit( "hello", "ll", 1 ); - CompareSplitWithLimit( "hello", "ll", 2 ); - CompareSplit( "", " " ); - CompareSplit( "" ); -*/ - -// separartor is a regexp -// separator regexp value global setting is set -// string is an empty string -// if separator is an empty string, split each by character - -// this is not a String object - -// limit is not a number -// limit is undefined -// limit is larger than 2^32-1 -// limit is a negative number - -test(); - -function CompareSplit( string, separator ) { - split_1 = string.split( separator ); - split_2 = string_split( string, separator ); - - AddTestCase( - "( " + string +".split(" + separator + ") ).length" , - split_2.length, - split_1.length ); - - var limit = split_1.length > split_2.length ? - split_1.length : split_2.length; - - for ( var split_item = 0; split_item < limit; split_item++ ) { - AddTestCase( - string + ".split(" + separator + ")["+split_item+"]", - split_2[split_item], - split_1[split_item] ); - } -} - -function CompareSplitWithLimit( string, separator, splitlimit ) { - split_1 = string.split( separator, splitlimit ); - split_2 = string_split( string, separator, splitlimit ); - - AddTestCase( - "( " + string +".split(" + separator + ", " + splitlimit+") ).length" , - split_2.length, - split_1.length ); - - var limit = split_1.length > split_2.length ? - split_1.length : split_2.length; - - for ( var split_item = 0; split_item < limit; split_item++ ) { - AddTestCase( - string + ".split(" + separator + ", " + splitlimit+")["+split_item+"]", - split_2[split_item], - split_1[split_item] ); - } -} - -function string_split ( __this, separator, limit ) { - var S = String(__this ); // 1 - - var A = new Array(); // 2 - - if ( limit == undefined ) { // 3 - lim = Math.pow(2, 31 ) -1; - } else { - lim = ToUint32( limit ); - } - - var s = S.length; // 4 - var p = 0; // 5 - - if ( separator == undefined ) { // 8 - A[0] = S; - return A; - } - - if ( separator.constructor == RegExp ) // 6 - R = separator; - else - R = separator.toString(); - - if (lim == 0) return A; // 7 - - if ( separator == undefined ) { // 8 - A[0] = S; - return A; - } - - if (s == 0) { // 9 - z = SplitMatch(R, S, 0); - if (z != false) return A; - A[0] = S; - return A; - } - - var q = p; // 10 -loop: - while (true ) { - - if ( q == s ) break; // 11 - - z = SplitMatch(R, S, q); // 12 - -//print("Returned ", z); - - if (z != false) { // 13 - e = z.endIndex; // 14 - cap = z.captures; // 14 - if (e != p) { // 15 -//print("S = ", S, ", p = ", p, ", q = ", q); - T = S.slice(p, q); // 16 -//print("T = ", T); - A[A.length] = T; // 17 - if (A.length == lim) return A; // 18 - p = e; // 19 - i = 0; // 20 - while (true) { // 25 - if (i == cap.length) { // 21 - q = p; // 10 - continue loop; - } - i = i + 1; // 22 - A[A.length] = cap[i] // 23 - if (A.length == lim) return A; // 24 - } - } - } - - q = q + 1; // 26 - } - - T = S.slice(p, q); - A[A.length] = T; - return A; -} - -function SplitMatch(R, S, q) -{ - if (R.constructor == RegExp) { // 1 - var reResult = R.match(S, q); // 8 - if (reResult == undefined) - return false; - else { - a = new Array(reResult.length - 1); - for (var i = 1; i < reResult.length; i++) - a[a.length] = reResult[i]; - return { endIndex : reResult.index + reResult[0].length, captures : cap }; - } - } - else { - var r = R.length; // 2 - s = S.length; // 3 - if ((q + r) > s) return false; // 4 - for (var i = 0; i < r; i++) { -//print("S.charAt(", q + i, ") = ", S.charAt(q + i), ", R.charAt(", i, ") = ", R.charAt(i)); - if (S.charAt(q + i) != R.charAt(i)) // 5 - return false; - } - cap = new Array(); // 6 - return { endIndex : q + r, captures : cap }; // 7 - } -} - -function ToUint32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; - - if ( Math.abs( n ) == 0 - || Math.abs( n ) == Number.POSITIVE_INFINITY - || n != n) { - return 0; - } - n = sign * Math.floor( Math.abs(n) ) - - n = n % Math.pow(2,32); - - if ( n < 0 ){ - n += Math.pow(2,32); - } - - return ( n ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/split-003.binjs b/js/src/jsapi-tests/binast/parser/tester/split-003.binjs deleted file mode 100644 index ce86209d718a..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/split-003.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/split-003.js b/js/src/jsapi-tests/binast/parser/tester/split-003.js deleted file mode 100644 index e887dbe0e917..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/split-003.js +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: String/split-003.js - * ECMA Section: 15.6.4.9 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ - -/* - * Since regular expressions have been part of JavaScript since 1.2, there - * are already tests for regular expressions in the js1_2/regexp folder. - * - * These new tests try to supplement the existing tests, and verify that - * our implementation of RegExp conforms to the ECMA specification, but - * does not try to be as exhaustive as in previous tests. - * - * The [,limit] argument to String.split is new, and not covered in any - * existing tests. - * - * String.split cases are covered in ecma/String/15.5.4.8-*.js. - * String.split where separator is a RegExp are in - * js1_2/regexp/string_split.js - * - */ - -var SECTION = "ecma_2/String/split-003.js"; -var VERSION = "ECMA_2"; -var TITLE = "String.prototype.split( regexp, [,limit] )"; - -startTest(); - -// separator is a regexp -// separator regexp value global setting is set -// string is an empty string -// if separator is an empty string, split each by character - - -AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] ); - -AddSplitCases( "hello", /l/, "/l/", ["he","","o"] ); -AddLimitedSplitCases( "hello", /l/, "/l/", 0, [] ); -AddLimitedSplitCases( "hello", /l/, "/l/", 1, ["he"] ); -AddLimitedSplitCases( "hello", /l/, "/l/", 2, ["he",""] ); -AddLimitedSplitCases( "hello", /l/, "/l/", 3, ["he","","o"] ); -AddLimitedSplitCases( "hello", /l/, "/l/", 4, ["he","","o"] ); -AddLimitedSplitCases( "hello", /l/, "/l/", void 0, ["he","","o"] ); -AddLimitedSplitCases( "hello", /l/, "/l/", "hi", [] ); -AddLimitedSplitCases( "hello", /l/, "/l/", undefined, ["he","","o"] ); - -AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 0, [] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 1, ["h"] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 2, ["h","e"] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 3, ["h","e","l"] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 4, ["h","e","l","l"] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", void 0, ["h","e","l","l","o"] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", "hi", [] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", undefined, ["h","e","l","l","o"] ); - -test(); - -function AddSplitCases( string, separator, str_sep, split_array ) { - // verify that the result of split is an object of type Array - AddTestCase( - "( " + string + " ).split(" + str_sep +").constructor == Array", - true, - string.split(separator).constructor == Array ); - - // check the number of items in the array - AddTestCase( - "( " + string + " ).split(" + str_sep +").length", - split_array.length, - string.split(separator).length ); - - // check the value of each array item - var limit = (split_array.length > string.split(separator).length ) - ? split_array.length : string.split(separator).length; - - for ( var matches = 0; matches < split_array.length; matches++ ) { - AddTestCase( - "( " + string + " ).split(" + str_sep +")[" + matches +"]", - split_array[matches], - string.split( separator )[matches] ); - } -} - -function AddLimitedSplitCases( - string, separator, str_sep, limit, split_array ) { - - // verify that the result of split is an object of type Array - - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + limit + - " ).constructor == Array", - true, - string.split(separator, limit).constructor == Array ); - - // check the length of the array - - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + limit + " ).length", - split_array.length, - string.split(separator, limit).length ); - - // check the value of each array item - - var slimit = (split_array.length > string.split(separator).length ) - ? split_array.length : string.split(separator, limit).length; - - for ( var matches = 0; matches < slimit; matches++ ) { - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + limit + " )[" + matches +"]", - split_array[matches], - string.split( separator, limit )[matches] ); - } -} diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-001.binjs b/js/src/jsapi-tests/binast/parser/tester/statement-001.binjs deleted file mode 100644 index 6b06c09c1264..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/statement-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-001.js b/js/src/jsapi-tests/binast/parser/tester/statement-001.js deleted file mode 100644 index 087f3f74d8cd..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/statement-001.js +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: statement-001.js - Corresponds To: 12.6.2-9-n.js - ECMA Section: 12.6.2 The for Statement - - 1. first expression is not present. - 2. second expression is not present - 3. third expression is not present - - - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "statement-001.js"; -// var SECTION = "12.6.2-9-n"; -var VERSION = "ECMA_1"; -var TITLE = "The for statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("for (i) {\n}"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "for(i) {}" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-002.binjs b/js/src/jsapi-tests/binast/parser/tester/statement-002.binjs deleted file mode 100644 index cfc1b8b7e748..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/statement-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-002.js b/js/src/jsapi-tests/binast/parser/tester/statement-002.js deleted file mode 100644 index 7ac633058bd5..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/statement-002.js +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: statement-002.js - Corresponds To: 12.6.3-1.js - ECMA Section: 12.6.3 The for...in Statement - Description: - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: - - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "statement-002"; -var VERSION = "JS1_4"; -var TITLE = "The for..in statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval(" for ( var i, p in this) { result += this[p]; }"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "more than one member expression" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-003.binjs b/js/src/jsapi-tests/binast/parser/tester/statement-003.binjs deleted file mode 100644 index c77fa4f7e1e8..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/statement-003.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-003.js b/js/src/jsapi-tests/binast/parser/tester/statement-003.js deleted file mode 100644 index 7e257675c4ec..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/statement-003.js +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: statement-003 - Corresponds To: 12.6.3-7-n.js - ECMA Section: 12.6.3 The for...in Statement - Description: - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: - - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "statement-003"; -var VERSION = "JS1_4"; -var TITLE = "The for..in statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var o = new MyObject(); - var result = 0; - - eval("for ( this in o) {\n" - + "result += this[p];\n" - + "}\n"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "bad left-hand side expression" + - " (threw " + exception +")", - expect, - result ); - -test(); - -function MyObject() { - this.value = 2; - this[0] = 4; - return this; -} diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-004.binjs b/js/src/jsapi-tests/binast/parser/tester/statement-004.binjs deleted file mode 100644 index f91dfd20bc69..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/statement-004.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-004.js b/js/src/jsapi-tests/binast/parser/tester/statement-004.js deleted file mode 100644 index 056e0452ede3..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/statement-004.js +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: statement-004.js - Corresponds To: 12.6.3-1.js - ECMA Section: 12.6.3 The for...in Statement - Description: - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "statement-004"; -var VERSION = "JS1_4"; -var TITLE = "The for..in statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var o = new MyObject(); - - eval("for ( \"a\" in o) {\n" - + "result += this[p];\n" - + "}"); - -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "bad left-hand side expression" + - " (threw " + exception +")", - expect, - result ); - -test(); - - -function MyObject() { - this.value = 2; - this[0] = 4; - return this; -} diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-005.binjs b/js/src/jsapi-tests/binast/parser/tester/statement-005.binjs deleted file mode 100644 index 165dcc1a1139..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/statement-005.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-005.js b/js/src/jsapi-tests/binast/parser/tester/statement-005.js deleted file mode 100644 index 404a157e98e8..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/statement-005.js +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: statement-005.js - Corresponds To: 12.6.3-8-n.js - ECMA Section: 12.6.3 The for...in Statement - Description: - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "statement-005"; -var VERSION = "JS1_4"; -var TITLE = "The for..in statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var o = new MyObject(); - result = 0; - - eval("for (1 in o) {\n" - + "result += this[p];" - + "}\n"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "bad left-hand side expression" + - " (threw " + exception +")", - expect, - result ); - -test(); - -function MyObject() { - this.value = 2; - this[0] = 4; - return this; -} diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-006.binjs b/js/src/jsapi-tests/binast/parser/tester/statement-006.binjs deleted file mode 100644 index f5bc9952a0ec..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/statement-006.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-006.js b/js/src/jsapi-tests/binast/parser/tester/statement-006.js deleted file mode 100644 index 24839d847a9e..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/statement-006.js +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: statement-006.js - Corresponds To: 12.6.3-9-n.js - ECMA Section: 12.6.3 The for...in Statement - Description: - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "statement-006"; -var VERSION = "JS1_4"; -var TITLE = "The for..in statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var o = new MyObject(); - var result = 0; - for ( var o in foo) { - result += this[o]; - } -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "object is not defined" + - " (threw " + exception +")", - expect, - result ); - -test(); - -function MyObject() { - this.value = 2; - this[0] = 4; - return this; -} diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-007.binjs b/js/src/jsapi-tests/binast/parser/tester/statement-007.binjs deleted file mode 100644 index f873474cbea4..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/statement-007.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-007.js b/js/src/jsapi-tests/binast/parser/tester/statement-007.js deleted file mode 100644 index bb561b691a5e..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/statement-007.js +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: statement-007.js - Corresponds To: 12.7-1-n.js - ECMA Section: 12.7 The continue statement - Description: - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "statement-007"; -var VERSION = "JS1_4"; -var TITLE = "The continue statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("continue;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "continue outside of an iteration statement" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-008.binjs b/js/src/jsapi-tests/binast/parser/tester/statement-008.binjs deleted file mode 100644 index a2b521f49855..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/statement-008.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-008.js b/js/src/jsapi-tests/binast/parser/tester/statement-008.js deleted file mode 100644 index a71fc266da37..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/statement-008.js +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: statement-008.js - Corresponds To: 12.8-1-n.js - ECMA Section: 12.8 The break statement - Description: - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "statement-008"; -var VERSION = "JS1_4"; -var TITLE = "The break in statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("break;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "break outside of an iteration statement" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-009.binjs b/js/src/jsapi-tests/binast/parser/tester/statement-009.binjs deleted file mode 100644 index 1b521624dfe9..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/statement-009.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/statement-009.js b/js/src/jsapi-tests/binast/parser/tester/statement-009.js deleted file mode 100644 index 9be1de747d75..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/statement-009.js +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: 12.9-1-n.js - ECMA Section: 12.9 The return statement - Description: - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "12.9-1-n"; -var VERSION = "ECMA_1"; -var TITLE = "The return statement"; - -startTest(); -writeHeaderToLog( SECTION + " The return statement"); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("return;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "return outside of a function" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/string-001.binjs b/js/src/jsapi-tests/binast/parser/tester/string-001.binjs deleted file mode 100644 index 47330264d8ad..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/string-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/string-001.js b/js/src/jsapi-tests/binast/parser/tester/string-001.js deleted file mode 100644 index 68bfe181c9c7..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/string-001.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: string-001.js - Corresponds To: 15.5.4.2-2-n.js - ECMA Section: 15.5.4.2 String.prototype.toString() - - Description: Returns this string value. Note that, for a String - object, the toString() method happens to return the same - thing as the valueOf() method. - - The toString function is not generic; it generates a - runtime error if its this value is not a String object. - Therefore it connot be transferred to the other kinds of - objects for use as a method. - - Author: christine@netscape.com - Date: 1 october 1997 -*/ -var SECTION = "string-001"; -var VERSION = "JS1_4"; -var TITLE = "String.prototype.toString"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - OBJECT = new Object(); - OBJECT.toString = String.prototype.toString(); - result = OBJECT.toString(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "OBJECT = new Object; "+ - " OBJECT.toString = String.prototype.toString; OBJECT.toString()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/js/src/jsapi-tests/binast/parser/tester/string-002.binjs b/js/src/jsapi-tests/binast/parser/tester/string-002.binjs deleted file mode 100644 index 732b8e6cf1fb..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/string-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/string-002.js b/js/src/jsapi-tests/binast/parser/tester/string-002.js deleted file mode 100644 index b68f2a156a95..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/string-002.js +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- 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/. */ - - -/** - File Name: string-002.js - Corresponds To: 15.5.4.3-3-n.js - ECMA Section: 15.5.4.3 String.prototype.valueOf() - - Description: Returns this string value. - - The valueOf function is not generic; it generates a - runtime error if its this value is not a String object. - Therefore it connot be transferred to the other kinds of - objects for use as a method. - - Author: christine@netscape.com - Date: 1 october 1997 -*/ -var SECTION = "string-002"; -var VERSION = "JS1_4"; -var TITLE = "String.prototype.valueOf"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var OBJECT =new Object(); - OBJECT.valueOf = String.prototype.valueOf; - result = OBJECT.valueOf(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "OBJECT = new Object; OBJECT.valueOf = String.prototype.valueOf;"+ - "result = OBJECT.valueOf();" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/js/src/jsapi-tests/binast/parser/tester/switch-001.binjs b/js/src/jsapi-tests/binast/parser/tester/switch-001.binjs deleted file mode 100644 index 8fb0718c1197..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/switch-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/switch-001.js b/js/src/jsapi-tests/binast/parser/tester/switch-001.js deleted file mode 100644 index 44e72985dae4..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/switch-001.js +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: switch-001.js - * ECMA Section: - * Description: The switch Statement - * - * A simple switch test with no abrupt completions. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - * - */ -var SECTION = "switch-001"; -var VERSION = "ECMA_2"; -var TITLE = "The switch statement"; - -var BUGNUMBER="315767"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -SwitchTest( 0, 126 ); -SwitchTest( 1, 124 ); -SwitchTest( 2, 120 ); -SwitchTest( 3, 112 ); -SwitchTest( 4, 64 ); -SwitchTest( 5, 96 ); -SwitchTest( true, 96 ); -SwitchTest( false, 96 ); -SwitchTest( null, 96 ); -SwitchTest( void 0, 96 ); -SwitchTest( "0", 96 ); - -test(); - -function SwitchTest( input, expect ) { - var result = 0; - - switch ( input ) { - case 0: - result += 2; - case 1: - result += 4; - case 2: - result += 8; - case 3: - result += 16; - default: - result += 32; - case 4: - result +=64; - } - - new TestCase( - SECTION, - "switch with no breaks, case expressions are numbers. input is "+ - input, - expect, - result ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/switch-002.binjs b/js/src/jsapi-tests/binast/parser/tester/switch-002.binjs deleted file mode 100644 index 1906560b1d9b..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/switch-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/switch-002.js b/js/src/jsapi-tests/binast/parser/tester/switch-002.js deleted file mode 100644 index 3e08630bebaf..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/switch-002.js +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: switch-002.js - * ECMA Section: - * Description: The switch Statement - * - * A simple switch test with no abrupt completions. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - * - */ -var SECTION = "switch-002"; -var VERSION = "ECMA_2"; -var TITLE = "The switch statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -SwitchTest( 0, 6 ); -SwitchTest( 1, 4 ); -SwitchTest( 2, 56 ); -SwitchTest( 3, 48 ); -SwitchTest( 4, 64 ); -SwitchTest( true, 32 ); -SwitchTest( false, 32 ); -SwitchTest( null, 32 ); -SwitchTest( void 0, 32 ); -SwitchTest( "0", 32 ); - -test(); - -function SwitchTest( input, expect ) { - var result = 0; - - switch ( input ) { - case 0: - result += 2; - case 1: - result += 4; - break; - case 2: - result += 8; - case 3: - result += 16; - default: - result += 32; - break; - case 4: - result += 64; - } - - new TestCase( - SECTION, - "switch with no breaks: input is " + input, - expect, - result ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/switch-003.binjs b/js/src/jsapi-tests/binast/parser/tester/switch-003.binjs deleted file mode 100644 index 21fd56d2cc4a..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/switch-003.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/switch-003.js b/js/src/jsapi-tests/binast/parser/tester/switch-003.js deleted file mode 100644 index 5ceaade69884..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/switch-003.js +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: switch-003.js - * ECMA Section: - * Description: The switch Statement - * - * Attempt to verify that case statements are evaluated in source order - * - * Author: christine@netscape.com - * Date: 11 August 1998 - * - */ -var SECTION = "switch-003"; -var VERSION = "ECMA_2"; -var TITLE = "The switch statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -SwitchTest( "a", "abc" ); -SwitchTest( "b", "bc" ); -SwitchTest( "c", "c" ); -SwitchTest( "d", "*abc" ); -SwitchTest( "v", "*abc" ); -SwitchTest( "w", "w*abc" ); -SwitchTest( "x", "xw*abc" ); -SwitchTest( "y", "yxw*abc" ); -SwitchTest( "z", "zyxw*abc" ); -// SwitchTest( new java.lang.String("z"), "*abc" ); - -test(); - -function SwitchTest( input, expect ) { - var result = ""; - - switch ( input ) { - case "z": result += "z"; - case "y": result += "y"; - case "x": result += "x"; - case "w": result += "w"; - default: result += "*"; - case "a": result += "a"; - case "b": result += "b"; - case "c": result += "c"; - } - - new TestCase( - SECTION, - "switch with no breaks: input is " + input, - expect, - result ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/switch-004.binjs b/js/src/jsapi-tests/binast/parser/tester/switch-004.binjs deleted file mode 100644 index cc3af70a4571..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/switch-004.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/switch-004.js b/js/src/jsapi-tests/binast/parser/tester/switch-004.js deleted file mode 100644 index 0572874a6b47..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/switch-004.js +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: switch-003.js - * ECMA Section: - * Description: The switch Statement - * - * This uses variables and objects as case expressions in switch statements. - * This verifies a bunch of bugs: - * - * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315988 - * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315975 - * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315954 - * - * Author: christine@netscape.com - * Date: 11 August 1998 - * - */ -var SECTION = "switch-003"; -var VERSION = "ECMA_2"; -var TITLE = "The switch statement"; -var BUGNUMBER= "315988"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -ONE = new Number(1); -ZERO = new Number(0); -var A = new String("A"); -var B = new String("B"); -TRUE = new Boolean( true ); -FALSE = new Boolean( false ); -UNDEFINED = void 0; -NULL = null; - -SwitchTest( ZERO, "ZERO" ); -SwitchTest( NULL, "NULL" ); -SwitchTest( UNDEFINED, "UNDEFINED" ); -SwitchTest( FALSE, "FALSE" ); -SwitchTest( false, "false" ); -SwitchTest( 0, "0" ); - -SwitchTest ( TRUE, "TRUE" ); -SwitchTest( 1, "1" ); -SwitchTest( ONE, "ONE" ); -SwitchTest( true, "true" ); - -SwitchTest( "a", "a" ); -SwitchTest( A, "A" ); -SwitchTest( "b", "b" ); -SwitchTest( B, "B" ); - -SwitchTest( new Boolean( true ), "default" ); -SwitchTest( new Boolean(false ), "default" ); -SwitchTest( new String( "A" ), "default" ); -SwitchTest( new Number( 0 ), "default" ); - -test(); - -function SwitchTest( input, expect ) { - var result = ""; - - switch ( input ) { - default: result += "default"; break; - case "a": result += "a"; break; - case "b": result += "b"; break; - case A: result += "A"; break; - case B: result += "B"; break; - case new Boolean(true): result += "new TRUE"; break; - case new Boolean(false): result += "new FALSE"; break; - case NULL: result += "NULL"; break; - case UNDEFINED: result += "UNDEFINED"; break; - case true: result += "true"; break; - case false: result += "false"; break; - case TRUE: result += "TRUE"; break; - case FALSE: result += "FALSE"; break; - case 0: result += "0"; break; - case 1: result += "1"; break; - case new Number(0) : result += "new ZERO"; break; - case new Number(1) : result += "new ONE"; break; - case ONE: result += "ONE"; break; - case ZERO: result += "ZERO"; break; - } - - new TestCase( - SECTION, - "switch with no breaks: input is " + input, - expect, - result ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/try-001.binjs b/js/src/jsapi-tests/binast/parser/tester/try-001.binjs deleted file mode 100644 index 6f46fa057197..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/try-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/try-001.js b/js/src/jsapi-tests/binast/parser/tester/try-001.js deleted file mode 100644 index 931837cd3f00..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/try-001.js +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: try-001.js - * ECMA Section: - * Description: The try statement - * - * This test contains try, catch, and finally blocks. An exception is - * sometimes thrown by a function called from within the try block. - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = ""; -var VERSION = "ECMA_2"; -var TITLE = "The try statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var INVALID_JAVA_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor"; - -TryNewJavaInteger( "3.14159", INVALID_JAVA_INTEGER_VALUE ); -TryNewJavaInteger( NaN, INVALID_JAVA_INTEGER_VALUE ); -TryNewJavaInteger( 0, 0 ); -TryNewJavaInteger( -1, -1 ); -TryNewJavaInteger( 1, 1 ); -TryNewJavaInteger( Infinity, Infinity ); - -test(); - -/** - * Check to see if the input is valid for java.lang.Integer. If it is - * not valid, throw INVALID_JAVA_INTEGER_VALUE. If input is valid, - * return Number( v ) - * - */ - -function newJavaInteger( v ) { - value = Number( v ); - if ( Math.floor(value) != value || isNaN(value) ) { - throw ( INVALID_JAVA_INTEGER_VALUE ); - } else { - return value; - } -} - -/** - * Call newJavaInteger( value ) from within a try block. Catch any - * exception, and store it in result. Verify that we got the right - * return value from newJavaInteger in cases in which we do not expect - * exceptions, and that we got the exception in cases where an exception - * was expected. - */ -function TryNewJavaInteger( value, expect ) { - var finalTest = false; - - try { - result = newJavaInteger( value ); - } catch ( e ) { - result = String( e ); - } finally { - finalTest = true; - } - new TestCase( - SECTION, - "newJavaValue( " + value +" )", - expect, - result); - - new TestCase( - SECTION, - "newJavaValue( " + value +" ) hit finally block", - true, - finalTest); - -} - diff --git a/js/src/jsapi-tests/binast/parser/tester/try-003.binjs b/js/src/jsapi-tests/binast/parser/tester/try-003.binjs deleted file mode 100644 index 22050d00b2cc..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/try-003.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/try-003.js b/js/src/jsapi-tests/binast/parser/tester/try-003.js deleted file mode 100644 index 9244fcb5d9a5..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/try-003.js +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: try-003.js - * ECMA Section: - * Description: The try statement - * - * This test has a try with no catch, and a finally. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-003"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement"; -var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=313585"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -// Tests start here. - -TrySomething( "x = \"hi\"", false ); -TrySomething( "throw \"boo\"", true ); -TrySomething( "throw 3", true ); - -test(); - -/** - * This function contains a try block with no catch block, - * but it does have a finally block. Try to evaluate expressions - * that do and do not throw exceptions. - */ - -function TrySomething( expression, throwing ) { - innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK"; - if (throwing) { - outerCatch = "FAILED: NO EXCEPTION CAUGHT"; - } else { - outerCatch = "PASS"; - } - outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK"; - - try { - try { - eval( expression ); - } finally { - innerFinally = "PASS"; - } - } catch ( e ) { - if (throwing) { - outerCatch = "PASS"; - } else { - outerCatch = "FAIL: HIT OUTER CATCH BLOCK"; - } - } finally { - outerFinally = "PASS"; - } - - - new TestCase( - SECTION, - "eval( " + expression +" )", - "PASS", - innerFinally ); - new TestCase( - SECTION, - "eval( " + expression +" )", - "PASS", - outerCatch ); - new TestCase( - SECTION, - "eval( " + expression +" )", - "PASS", - outerFinally ); - - -} diff --git a/js/src/jsapi-tests/binast/parser/tester/try-004.binjs b/js/src/jsapi-tests/binast/parser/tester/try-004.binjs deleted file mode 100644 index aad744afd13e..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/try-004.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/try-004.js b/js/src/jsapi-tests/binast/parser/tester/try-004.js deleted file mode 100644 index dbc5545596d5..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/try-004.js +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: try-004.js - * ECMA Section: - * Description: The try statement - * - * This test has a try with one catch block but no finally. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-004"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -TryToCatch( "Math.PI", Math.PI ); -TryToCatch( "Thrower(5)", "Caught 5" ); -TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" ); - -test(); - -function Thrower( v ) { - throw "Caught " + v; -} - -/** - * Evaluate a string. Catch any exceptions thrown. If no exception is - * expected, verify the result of the evaluation. If an exception is - * expected, verify that we got the right exception. - */ - -function TryToCatch( value, expect ) { - try { - result = eval( value ); - } catch ( e ) { - result = e; - } - - new TestCase( - SECTION, - "eval( " + value +" )", - expect, - result ); -} - - diff --git a/js/src/jsapi-tests/binast/parser/tester/try-005.binjs b/js/src/jsapi-tests/binast/parser/tester/try-005.binjs deleted file mode 100644 index e1320df37a93..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/try-005.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/try-005.js b/js/src/jsapi-tests/binast/parser/tester/try-005.js deleted file mode 100644 index b50c5bf53665..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/try-005.js +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: try-005.js - * ECMA Section: - * Description: The try statement - * - * This test has a try with one catch block but no finally. Same - * as try-004, but the eval statement is called from a function, not - * directly from within the try block. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-005"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -TryToCatch( "Math.PI", Math.PI ); -TryToCatch( "Thrower(5)", "Caught 5" ); -TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" ); - -test(); - -function Thrower( v ) { - throw "Caught " + v; -} -function Eval( v ) { - return eval( v ); -} - -/** - * Evaluate a string. Catch any exceptions thrown. If no exception is - * expected, verify the result of the evaluation. If an exception is - * expected, verify that we got the right exception. - */ - -function TryToCatch( value, expect ) { - try { - result = Eval( value ); - } catch ( e ) { - result = e; - } - - new TestCase( - SECTION, - "eval( " + value +" )", - expect, - result ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/try-006.binjs b/js/src/jsapi-tests/binast/parser/tester/try-006.binjs deleted file mode 100644 index 237641e6393b..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/try-006.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/try-006.js b/js/src/jsapi-tests/binast/parser/tester/try-006.js deleted file mode 100644 index 0a85200a1522..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/try-006.js +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: try-006.js - * ECMA Section: - * Description: The try statement - * - * Throw an exception from within a With block in a try block. Verify - * that any expected exceptions are caught. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-006"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -/** - * This is the "check" function for test objects that will - * throw an exception. - */ -function throwException() { - throw EXCEPTION_STRING +": " + this.valueOf(); -} -var EXCEPTION_STRING = "Exception thrown:"; - -/** - * This is the "check" function for test objects that do not - * throw an exception - */ -function noException() { - return this.valueOf(); -} - -/** - * Add test cases here - */ -TryWith( new TryObject( "hello", throwException, true )); -TryWith( new TryObject( "hola", noException, false )); - -/** - * Run the test. - */ - -test(); - -/** - * This is the object that will be the "this" in a with block. - */ -function TryObject( value, fun, exception ) { - this.value = value; - this.exception = exception; - - this.valueOf = new Function ( "return this.value" ); - this.check = fun; -} - -/** - * This function has the try block that has a with block within it. - * Test cases are added in this function. Within the with block, the - * object's "check" function is called. If the test object's exception - * property is true, we expect the result to be the exception value. - * If exception is false, then we expect the result to be the value of - * the object. - */ -function TryWith( object ) { - try { - with ( object ) { - result = check(); - } - } catch ( e ) { - result = e; - } - - new TestCase( - SECTION, - "TryWith( " + object.value +" )", - (object.exception ? EXCEPTION_STRING +": " + object.valueOf() : object.valueOf()), - result ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/try-007.binjs b/js/src/jsapi-tests/binast/parser/tester/try-007.binjs deleted file mode 100644 index 1a7d5b74195d..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/try-007.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/try-007.js b/js/src/jsapi-tests/binast/parser/tester/try-007.js deleted file mode 100644 index 93e08a0a1765..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/try-007.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: try-007.js - * ECMA Section: - * Description: The try statement - * - * This test has a for-in statement within a try block. - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-007"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement: for-in"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -/** - * This is the "check" function for test objects that will - * throw an exception. - */ -function throwException() { - throw EXCEPTION_STRING +": " + this.valueOf(); -} -var EXCEPTION_STRING = "Exception thrown:"; - -/** - * This is the "check" function for test objects that do not - * throw an exception - */ -function noException() { - return this.valueOf(); -} - -/** - * Add test cases here - */ -TryForIn( new TryObject( "hello", throwException, true )); -TryForIn( new TryObject( "hola", noException, false )); - -/** - * Run the test. - */ - -test(); - -/** - * This is the object that will be the "this" in a with block. - * The check function is either throwException() or noException(). - * See above. - * - */ -function TryObject( value, fun, exception ) { - this.value = value; - this.exception = exception; - - this.check = fun; - this.valueOf = function () { return this.value; } -} - -/** - * This function has a for-in statement within a try block. Test cases - * are added after the try-catch-finally statement. Within the for-in - * block, call a function that can throw an exception. Verify that any - * exceptions are properly caught. - */ - -function TryForIn( object ) { - try { - for ( p in object ) { - if ( typeof object[p] == "function" ) { - result = object[p](); - } - } - } catch ( e ) { - result = e; - } - - new TestCase( - SECTION, - "TryForIn( " + object+ " )", - (object.exception ? EXCEPTION_STRING +": " + object.value : object.value), - result ); - -} diff --git a/js/src/jsapi-tests/binast/parser/tester/try-008.binjs b/js/src/jsapi-tests/binast/parser/tester/try-008.binjs deleted file mode 100644 index 0c3174f12fef..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/try-008.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/try-008.js b/js/src/jsapi-tests/binast/parser/tester/try-008.js deleted file mode 100644 index d47ced0ae331..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/try-008.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: try-008.js - * ECMA Section: - * Description: The try statement - * - * This test has a try block in a constructor. - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-008"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement: try in a constructor"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -function Integer( value, exception ) { - try { - this.value = checkValue( value ); - } catch ( e ) { - this.value = e.toString(); - } - - new TestCase( - SECTION, - "Integer( " + value +" )", - (exception ? INVALID_INTEGER_VALUE +": " + value : this.value), - this.value ); -} - -var INVALID_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor"; - -function checkValue( value ) { - if ( Math.floor(value) != value || isNaN(value) ) { - throw ( INVALID_INTEGER_VALUE +": " + value ); - } else { - return value; - } -} - -// add test cases - -new Integer( 3, false ); -new Integer( NaN, true ); -new Integer( 0, false ); -new Integer( Infinity, false ); -new Integer( -2.12, true ); -new Integer( Math.LN2, true ); - - -test(); diff --git a/js/src/jsapi-tests/binast/parser/tester/try-009.binjs b/js/src/jsapi-tests/binast/parser/tester/try-009.binjs deleted file mode 100644 index de1e54faa003..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/try-009.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/try-009.js b/js/src/jsapi-tests/binast/parser/tester/try-009.js deleted file mode 100644 index d3e0ebaa23b0..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/try-009.js +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: try-009.js - * ECMA Section: - * Description: The try statement - * - * This test has a try block within a while block. Verify that an exception - * breaks out of the while. I don't really know why this is an interesting - * test case but Mike Shaver had two of these so what the hey. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-009"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement: try in a while block"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var EXCEPTION_STRING = "Exception thrown: "; -var NO_EXCEPTION_STRING = "No exception thrown: "; - - -TryInWhile( new TryObject( "hello", ThrowException, true ) ); -TryInWhile( new TryObject( "aloha", NoException, false )); - -test(); - -function TryObject( value, throwFunction, result ) { - this.value = value; - this.thrower = throwFunction; - this.result = result; -} -function ThrowException() { - throw EXCEPTION_STRING + this.value; -} -function NoException() { - return NO_EXCEPTION_STRING + this.value; -} -function TryInWhile( object ) { - result = null; - while ( true ) { - try { - object.thrower(); - result = NO_EXCEPTION_STRING + object.value; - break; - } catch ( e ) { - result = e; - break; - } - } - - new TestCase( - SECTION, - "( "+ object +".thrower() )", - (object.result - ? EXCEPTION_STRING + object.value : - NO_EXCEPTION_STRING + object.value), - result ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/try-010.binjs b/js/src/jsapi-tests/binast/parser/tester/try-010.binjs deleted file mode 100644 index 182f449ab696..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/try-010.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/try-010.js b/js/src/jsapi-tests/binast/parser/tester/try-010.js deleted file mode 100644 index 5ee472c3b73e..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/try-010.js +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: try-010.js - * ECMA Section: - * Description: The try statement - * - * This has a try block nested in the try block. Verify that the - * exception is caught by the right try block, and all finally blocks - * are executed. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-010"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement: try in a tryblock"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var EXCEPTION_STRING = "Exception thrown: "; -var NO_EXCEPTION_STRING = "No exception thrown: "; - - -NestedTry( new TryObject( "No Exceptions Thrown", NoException, NoException, 43 ) ); -NestedTry( new TryObject( "Throw Exception in Outer Try", ThrowException, NoException, 48 )); -NestedTry( new TryObject( "Throw Exception in Inner Try", NoException, ThrowException, 45 )); -NestedTry( new TryObject( "Throw Exception in Both Trys", ThrowException, ThrowException, 48 )); - -test(); - -function TryObject( description, tryOne, tryTwo, result ) { - this.description = description; - this.tryOne = tryOne; - this.tryTwo = tryTwo; - this.result = result; -} -function ThrowException() { - throw EXCEPTION_STRING + this.value; -} -function NoException() { - return NO_EXCEPTION_STRING + this.value; -} -function NestedTry( object ) { - result = 0; - try { - object.tryOne(); - result += 1; - try { - object.tryTwo(); - result += 2; - } catch ( e ) { - result +=4; - } finally { - result += 8; - } - } catch ( e ) { - result += 16; - } finally { - result += 32; - } - - new TestCase( - SECTION, - object.description, - object.result, - result ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/try-012.binjs b/js/src/jsapi-tests/binast/parser/tester/try-012.binjs deleted file mode 100644 index 7974cc3db15e..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/try-012.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/try-012.js b/js/src/jsapi-tests/binast/parser/tester/try-012.js deleted file mode 100644 index 3ee7d10266ba..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/try-012.js +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: try-012.js - * ECMA Section: - * Description: The try statement - * - * This test has a try with no catch, and a finally. This is like try-003, - * but throws from a finally block, not the try block. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-012"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement"; -var BUGNUMBER="336872"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -// Tests start here. - -TrySomething( "x = \"hi\"", true ); -TrySomething( "throw \"boo\"", true ); -TrySomething( "throw 3", true ); - -test(); - -/** - * This function contains a try block with no catch block, - * but it does have a finally block. Try to evaluate expressions - * that do and do not throw exceptions. - * - * The productioni TryStatement Block Finally is evaluated as follows: - * 1. Evaluate Block - * 2. Evaluate Finally - * 3. If Result(2).type is normal return result 1 (in the test case, result 1 has - * the completion type throw) - * 4. return result 2 (does not get hit in this case) - * - */ - -function TrySomething( expression, throwing ) { - innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK"; - if (throwing) { - outerCatch = "FAILED: NO EXCEPTION CAUGHT"; - } else { - outerCatch = "PASS"; - } - outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK"; - - - // If the inner finally does not throw an exception, the result - // of the try block should be returned. (Type of inner return - // value should be throw if finally executes correctly - - try { - try { - throw 0; - } finally { - innerFinally = "PASS"; - eval( expression ); - } - } catch ( e ) { - if (throwing) { - outerCatch = "PASS"; - } else { - outerCatch = "FAIL: HIT OUTER CATCH BLOCK"; - } - } finally { - outerFinally = "PASS"; - } - - - new TestCase( - SECTION, - "eval( " + expression +" ): evaluated inner finally block", - "PASS", - innerFinally ); - new TestCase( - SECTION, - "eval( " + expression +" ): evaluated outer catch block ", - "PASS", - outerCatch ); - new TestCase( - SECTION, - "eval( " + expression +" ): evaluated outer finally block", - "PASS", - outerFinally ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/unicode-001.binjs b/js/src/jsapi-tests/binast/parser/tester/unicode-001.binjs deleted file mode 100644 index 537e8e34c2bb..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/unicode-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/unicode-001.js b/js/src/jsapi-tests/binast/parser/tester/unicode-001.js deleted file mode 100644 index ab6fbd372ee9..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/unicode-001.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: RegExp/unicode-001.js - * ECMA Section: 15.7.3.1 - * Description: Based on ECMA 2 Draft 7 February 1999 - * Positive test cases for constructing a RegExp object - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/unicode-001.js"; -var VERSION = "ECMA_2"; -var TITLE = "new RegExp( pattern, flags )"; - -startTest(); - -// These examples come from 15.7.1, UnicodeEscapeSequence - -AddRegExpCases( /\u0041/, "/\\u0041/", "A", "A", 1, 0, ["A"] ); -AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); -AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); -AddRegExpCases( /\u001g/, "/\\u001g/", "u001g", "u001g", 1, 0, ["u001g"] ); - -AddRegExpCases( /A/, "/A/", "\u0041", "\\u0041", 1, 0, ["A"] ); -AddRegExpCases( /A/, "/A/", "\u00412", "\\u00412", 1, 0, ["A"] ); -AddRegExpCases( /A2/, "/A2/", "\u00412", "\\u00412", 1, 0, ["A2"]); -AddRegExpCases( /A/, "/A/", "A2", "A2", 1, 0, ["A"] ); - -test(); - -function AddRegExpCases( - regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { - - AddTestCase( - str_regexp + " .exec(" + str_pattern +").length", - length, - regexp.exec(pattern).length ); - - AddTestCase( - str_regexp + " .exec(" + str_pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - str_regexp + " .exec(" + str_pattern +").input", - pattern, - regexp.exec(pattern).input ); - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - str_regexp + " .exec(" + str_pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } -} diff --git a/js/src/jsapi-tests/binast/parser/tester/while-001.binjs b/js/src/jsapi-tests/binast/parser/tester/while-001.binjs deleted file mode 100644 index 8ca95ad2805f..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/while-001.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/while-001.js b/js/src/jsapi-tests/binast/parser/tester/while-001.js deleted file mode 100644 index 88fd8dfe840f..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/while-001.js +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: while-001 - * ECMA Section: - * Description: while statement - * - * Verify that the while statement is not executed if the while expression is - * false - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "while-001"; -var VERSION = "ECMA_2"; -var TITLE = "while statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile(); -test(); - -function DoWhile() { - result = "pass"; - - while (false) { - result = "fail"; - break; - } - - new TestCase( - SECTION, - "while statement: don't evaluate statement is expression is false", - "pass", - result ); - -} diff --git a/js/src/jsapi-tests/binast/parser/tester/while-002.binjs b/js/src/jsapi-tests/binast/parser/tester/while-002.binjs deleted file mode 100644 index 19ca8c9db45f..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/while-002.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/while-002.js b/js/src/jsapi-tests/binast/parser/tester/while-002.js deleted file mode 100644 index a3c315bf2064..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/while-002.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: while-002 - * ECMA Section: - * Description: while statement - * - * Verify that the while statement is not executed if the while expression is - * false - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "while-002"; -var VERSION = "ECMA_2"; -var TITLE = "while statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile( new DoWhileObject( - "while expression is null", - null, - "result = \"fail: should not have evaluated statements in while block;break" - ) ); - -DoWhile( new DoWhileObject( - "while expression is undefined", - void 0, - "result = \"fail: should not have evaluated statements in while block; break" - )); - -DoWhile( new DoWhileObject( - "while expression is 0", - 0, - "result = \"fail: should not have evaluated statements in while block; break;" - )); - -DoWhile( new DoWhileObject( - "while expression is eval(\"\")", - eval(""), - "result = \"fail: should not have evaluated statements in while block; break" - )); - -DoWhile( new DoWhileObject( - "while expression is NaN", - NaN, - "result = \"fail: should not have evaluated statements in while block; break" - )); - -test(); - -function DoWhileObject( d, e, s ) { - this.description = d; - this.whileExpression = e; - this.statements = s; -} - -function DoWhile( object ) { - result = "pass"; - - while ( expression = object.whileExpression ) { - eval( object.statements ); - } - - // verify that the while expression was evaluated - - new TestCase( - SECTION, - "verify that while expression was evaluated (should be "+ - object.whileExpression +")", - "pass", - (object.whileExpression == expression || - ( isNaN(object.whileExpression) && isNaN(expression) ) - ) ? "pass" : "fail" ); - - new TestCase( - SECTION, - object.description, - "pass", - result ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/while-003.binjs b/js/src/jsapi-tests/binast/parser/tester/while-003.binjs deleted file mode 100644 index accc07368888..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/while-003.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/while-003.js b/js/src/jsapi-tests/binast/parser/tester/while-003.js deleted file mode 100644 index b47d09a7a0a9..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/while-003.js +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: while-003 - * ECMA Section: - * Description: while statement - * - * The while expression evaluates to true, Statement returns abrupt completion. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "while-003"; -var VERSION = "ECMA_2"; -var TITLE = "while statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile( new DoWhileObject( - "while expression is true", - true, - "result = \"pass\";" )); - -DoWhile( new DoWhileObject( - "while expression is 1", - 1, - "result = \"pass\";" )); - -DoWhile( new DoWhileObject( - "while expression is new Boolean(false)", - new Boolean(false), - "result = \"pass\";" )); - -DoWhile( new DoWhileObject( - "while expression is new Object()", - new Object(), - "result = \"pass\";" )); - -DoWhile( new DoWhileObject( - "while expression is \"hi\"", - "hi", - "result = \"pass\";" )); -/* - DoWhile( new DoWhileObject( - "while expression has a continue in it", - "true", - "if ( i == void 0 ) i = 0; result=\"pass\"; if ( ++i == 1 ) {continue;} else {break;} result=\"fail\";" - )); -*/ -test(); - -function DoWhileObject( d, e, s ) { - this.description = d; - this.whileExpression = e; - this.statements = s; -} - -function DoWhile( object ) { - result = "fail: statements in while block were not evaluated"; - - while ( expression = object.whileExpression ) { - eval( object.statements ); - break; - } - - // verify that the while expression was evaluated - - new TestCase( - SECTION, - "verify that while expression was evaluated (should be "+ - object.whileExpression +")", - "pass", - (object.whileExpression == expression || - ( isNaN(object.whileExpression) && isNaN(expression) ) - ) ? "pass" : "fail" ); - - new TestCase( - SECTION, - object.description, - "pass", - result ); -} diff --git a/js/src/jsapi-tests/binast/parser/tester/while-004.binjs b/js/src/jsapi-tests/binast/parser/tester/while-004.binjs deleted file mode 100644 index 81253bbc76fe..000000000000 Binary files a/js/src/jsapi-tests/binast/parser/tester/while-004.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/parser/tester/while-004.js b/js/src/jsapi-tests/binast/parser/tester/while-004.js deleted file mode 100644 index 393e680e518b..000000000000 --- a/js/src/jsapi-tests/binast/parser/tester/while-004.js +++ /dev/null @@ -1,217 +0,0 @@ -/* -*- 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/. */ - - -/** - * File Name: while-004 - * ECMA Section: - * Description: while statement - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "while-004"; -var VERSION = "ECMA_2"; -var TITLE = "while statement"; -var BUGNUMBER="316725"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile_1(); -DoWhile_2(); -DoWhile_3(); -DoWhile_4(); -DoWhile_5(); - -test(); - -/** - * Break out of a while by calling return. - * - * Tests: 12.6.2 step 6. - */ -function dowhile() { - result = "pass"; - - while (true) { - return result; - result = "fail: hit code after return statement"; - break; - } -} - -function DoWhile_1() { - description = "return statement in a while block"; - - result = dowhile(); - - new TestCase( - SECTION, - "DoWhile_1" + description, - "pass", - result ); -} - -/** - * While with a labeled continue statement. Verify that statements - * after the continue statement are not evaluated. - * - * Tests: 12.6.2 step 8. - * - */ -function DoWhile_2() { - var description = "while with a labeled continue statement"; - var result1 = "pass"; - var result2 = "fail: did not execute code after loop, but inside label"; - var i = 0; - var j = 0; - -theloop: - while( i++ < 10 ) { - j++; - continue theloop; - result1 = "failed: hit code after continue statement"; - } - result2 = "pass"; - - new TestCase( - SECTION, - "DoWhile_2: " +description + " - code inside the loop, before the continue should be executed ("+j+")", - true, - j == 10 ); - - new TestCase( - SECTION, - "DoWhile_2: " +description +" - code after labeled continue should not be executed", - "pass", - result1 ); - - new TestCase( - SECTION, - "DoWhile_2: " +description +" - code after loop but inside label should be executed", - "pass", - result2 ); -} - -/** - * While with a labeled break. - * - */ -function DoWhile_3() { - var description = "while with a labeled break statement"; - var result1 = "pass"; - var result2 = "pass"; - var result3 = "fail: did not get to code after label"; - -woohoo: { - while( true ) { - break woohoo; - result1 = "fail: got to code after a break"; - } - result2 = "fail: got to code outside of loop but inside label"; - } - - result3 = "pass"; - - new TestCase( - SECTION, - "DoWhile_3: " +description +" - verify break out of loop", - "pass", - result1 ); - - - new TestCase( - SECTION, - "DoWhile_3: " +description +" - verify break out of label", - "pass", - result2 ); - - new TestCase( - SECTION, - "DoWhile_3: " +description + " - verify correct exit from label", - "pass", - result3 ); -} - - -/** - * Labled while with an unlabeled break - * - */ -function DoWhile_4() { - var description = "labeled while with an unlabeled break"; - var result1 = "pass"; - var result2 = "pass"; - var result3 = "fail: did not evaluate statement after label"; - -woohooboy: { - while( true ) { - break woohooboy; - result1 = "fail: got to code after the break"; - } - result2 = "fail: broke out of while, but not out of label"; - } - result3 = "pass"; - - new TestCase( - SECTION, - "DoWhile_4: " +description +" - verify break out of while loop", - "pass", - result1 ); - - new TestCase( - SECTION, - "DoWhile_4: " +description + " - verify break out of label", - "pass", - result2 ); - - new TestCase( - SECTION, - "DoWhile_4: " +description +" - verify that statements after label are evaluated", - "pass", - result3 ); -} - -/** - * in this case, should behave the same way as - * - * - */ -function DoWhile_5() { - var description = "while with a labeled continue statement"; - var result1 = "pass"; - var result2 = "fail: did not execute code after loop, but inside label"; - var i = 0; - var j = 0; - -theloop: { - j++; - while( i++ < 10 ) { - continue; - result1 = "failed: hit code after continue statement"; - } - result2 = "pass"; - } - - new TestCase( - SECTION, - "DoWhile_5: " +description + " - continue should not execute statements above the loop", - true, - ( j == 1 ) ); - - new TestCase( - SECTION, - "DoWhile_5: " +description +" - code after labeled continue should not be executed", - "pass", - result1 ); - - new TestCase( - SECTION, - "DoWhile_5: " +description +" - code after loop but inside label should be executed", - "pass", - result2 ); -} - diff --git a/js/src/jsapi-tests/binast/tokenizer/tester/test-empty-list.binjs b/js/src/jsapi-tests/binast/tokenizer/tester/test-empty-list.binjs deleted file mode 100644 index da01d11ad0fa..000000000000 Binary files a/js/src/jsapi-tests/binast/tokenizer/tester/test-empty-list.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/tokenizer/tester/test-empty-untagged-tuple.binjs b/js/src/jsapi-tests/binast/tokenizer/tester/test-empty-untagged-tuple.binjs deleted file mode 100644 index a4386f1d20cd..000000000000 --- a/js/src/jsapi-tests/binast/tokenizer/tester/test-empty-untagged-tuple.binjs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/js/src/jsapi-tests/binast/tokenizer/tester/test-nested-lists.binjs b/js/src/jsapi-tests/binast/tokenizer/tester/test-nested-lists.binjs deleted file mode 100644 index d20681c3cc1d..000000000000 Binary files a/js/src/jsapi-tests/binast/tokenizer/tester/test-nested-lists.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/tokenizer/tester/test-simple-string.binjs b/js/src/jsapi-tests/binast/tokenizer/tester/test-simple-string.binjs deleted file mode 100644 index 4dd9869685eb..000000000000 Binary files a/js/src/jsapi-tests/binast/tokenizer/tester/test-simple-string.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/tokenizer/tester/test-simple-tagged-tuple.binjs b/js/src/jsapi-tests/binast/tokenizer/tester/test-simple-tagged-tuple.binjs deleted file mode 100644 index 395fdb4476b5..000000000000 Binary files a/js/src/jsapi-tests/binast/tokenizer/tester/test-simple-tagged-tuple.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/tokenizer/tester/test-string-with-escapes.binjs b/js/src/jsapi-tests/binast/tokenizer/tester/test-string-with-escapes.binjs deleted file mode 100644 index b895cf16b7e0..000000000000 Binary files a/js/src/jsapi-tests/binast/tokenizer/tester/test-string-with-escapes.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/tokenizer/tester/test-trivial-list.binjs b/js/src/jsapi-tests/binast/tokenizer/tester/test-trivial-list.binjs deleted file mode 100644 index b92d59df5ea3..000000000000 Binary files a/js/src/jsapi-tests/binast/tokenizer/tester/test-trivial-list.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/binast/tokenizer/tester/test-trivial-untagged-tuple.binjs b/js/src/jsapi-tests/binast/tokenizer/tester/test-trivial-untagged-tuple.binjs deleted file mode 100644 index 7100fae76b62..000000000000 Binary files a/js/src/jsapi-tests/binast/tokenizer/tester/test-trivial-untagged-tuple.binjs and /dev/null differ diff --git a/js/src/jsapi-tests/moz.build b/js/src/jsapi-tests/moz.build index 3033d4804397..531fe083fa0d 100644 --- a/js/src/jsapi-tests/moz.build +++ b/js/src/jsapi-tests/moz.build @@ -137,17 +137,6 @@ if CONFIG['ENABLE_STREAMS']: 'testReadableStream.cpp', ] -if CONFIG['JS_BUILD_BINAST'] and CONFIG['JS_STANDALONE']: - # Standalone builds leave the source directory untouched, - # which lets us run tests with the data files intact. - # Otherwise, in the current state of the build system, - # we can't have data files in js/src tests. - UNIFIED_SOURCES += [ - 'testBinASTReader.cpp', - 'testBinTokenReaderTester.cpp' - ] - - DEFINES['EXPORT_JS_API'] = True LOCAL_INCLUDES += [ diff --git a/js/src/jsapi-tests/testBinASTReader.cpp b/js/src/jsapi-tests/testBinASTReader.cpp deleted file mode 100644 index 0a8200988e0d..000000000000 --- a/js/src/jsapi-tests/testBinASTReader.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - */ -/* 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/. */ - - -#if defined(XP_UNIX) - -#include -#include - -#elif defined(XP_WIN) - -#include - -#endif - -#include "jsapi.h" - - -#include "frontend/BinSource.h" -#include "frontend/FullParseHandler.h" -#include "frontend/ParseContext.h" -#include "frontend/Parser.h" -#include "gc/Zone.h" -#include "js/Vector.h" - -#include "jsapi-tests/tests.h" - -#include "vm/Interpreter.h" - -using UsedNameTracker = js::frontend::UsedNameTracker; -using namespace JS; -using namespace js; - -extern void enterJsDirectory(); -extern void exitJsDirectory(); -extern void readFull(const char* path, js::Vector& buf); - -void -readFull(JSContext* cx, const char* path, js::Vector& buf) -{ - buf.shrinkTo(0); - - js::Vector intermediate(cx); - readFull(path, intermediate); - - if (!buf.appendAll(intermediate)) - MOZ_CRASH("Couldn't read data"); -} - -BEGIN_TEST(testBinASTReaderECMAScript2) -{ - const char BIN_SUFFIX[] = ".binjs"; - const char TXT_SUFFIX[] = ".js"; - - CompileOptions options(cx); - options.setIntroductionType("unit test parse") - .setFileAndLine("", 1); - -#if defined(XP_UNIX) - - const char PATH[] = "jsapi-tests/binast/parser/tester/"; - - // Read the list of files in the directory. - enterJsDirectory(); - DIR* dir = opendir(PATH); - exitJsDirectory(); - if (!dir) - MOZ_CRASH("Couldn't open directory"); - - - while (auto entry = readdir(dir)) { - // Find files whose name ends with ".binjs". - const char* d_name = entry->d_name; - -#elif defined(XP_WIN) - - const char PATH[] = "jsapi-tests\\binast\\parser\\tester\\*.binjs"; - - WIN32_FIND_DATA FindFileData; - enterJsDirectory(); - HANDLE hFind = FindFirstFile(PATH, &FindFileData); - exitJsDirectory(); - for (bool found = (hFind != INVALID_HANDLE_VALUE); - found; - found = FindNextFile(hFind, &FindFileData)) - { - const char* d_name = FindFileData.cFileName; - -#endif // defined(XP_UNIX) || defined(XP_WIN) - - const size_t namlen = strlen(d_name); - if (namlen < sizeof(BIN_SUFFIX)) - continue; - if (strncmp(d_name + namlen - (sizeof(BIN_SUFFIX) - 1), BIN_SUFFIX, sizeof(BIN_SUFFIX)) != 0) - continue; - - // Find text file. - UniqueChars txtPath(static_cast(js_malloc(namlen + sizeof(PATH) + 1))); - strncpy(txtPath.get(), PATH, sizeof(PATH)); - strncpy(txtPath.get() + sizeof(PATH) - 1, d_name, namlen); - strncpy(txtPath.get() + sizeof(PATH) + namlen - sizeof(BIN_SUFFIX), TXT_SUFFIX, sizeof(TXT_SUFFIX)); - txtPath[sizeof(PATH) + namlen - sizeof(BIN_SUFFIX) + sizeof(TXT_SUFFIX) - 1] = 0; - fprintf(stderr, "Testing %s\n", txtPath.get()); - - // Read text file. - js::Vector txtSource(cx); - readFull(cx, txtPath.get(), txtSource); - - // Parse text file. - UsedNameTracker txtUsedNames(cx); - if (!txtUsedNames.init()) - MOZ_CRASH("Couldn't initialize used names"); - js::frontend::Parser parser(cx, cx->tempLifoAlloc(), options, txtSource.begin(), txtSource.length(), - /* foldConstants = */ false, txtUsedNames, nullptr, - nullptr); - if (!parser.checkOptions()) - MOZ_CRASH("Bad options"); - - auto txtParsed = parser.parse(); // Will be deallocated once `parser` goes out of scope. - RootedValue txtExn(cx); - if (!txtParsed) { - // Save exception for more detailed error message, if necessary. - if (!js::GetAndClearException(cx, &txtExn)) - MOZ_CRASH("Couldn't clear exception"); - } - - // Read binary file. - UniqueChars binPath(static_cast(js_malloc(namlen + sizeof(PATH) + 1))); - strncpy(binPath.get(), PATH, sizeof(PATH)); - strncpy(binPath.get() + sizeof(PATH) - 1, d_name, namlen); - binPath[namlen + sizeof(PATH) - 1] = 0; - - js::Vector binSource(cx); - readFull(binPath.get(), binSource); - - // Parse binary file. - js::frontend::UsedNameTracker binUsedNames(cx); - if (!binUsedNames.init()) - MOZ_CRASH("Couldn't initialized binUsedNames"); - - js::frontend::BinASTParser reader(cx, cx->tempLifoAlloc(), binUsedNames, options); - - auto binParsed = reader.parse(binSource); // Will be deallocated once `reader` goes out of scope. - RootedValue binExn(cx); - if (binParsed.isErr()) { - // Save exception for more detailed error message, if necessary. - if (!js::GetAndClearException(cx, &binExn)) - MOZ_CRASH("Couldn't clear binExn"); - } - - // The binary parser should accept the file iff the text parser has. - if (binParsed.isOk() && !txtParsed) { - fprintf(stderr, "Text file parsing failed: "); - - js::ErrorReport report(cx); - if (!report.init(cx, txtExn, js::ErrorReport::WithSideEffects)) - MOZ_CRASH("Couldn't report txtExn"); - - PrintError(cx, stderr, report.toStringResult(), report.report(), /* reportWarnings */ true); - MOZ_CRASH("Binary parser accepted a file that text parser rejected"); - } - - if (binParsed.isErr() && txtParsed) { - fprintf(stderr, "Binary file parsing failed: "); - - js::ErrorReport report(cx); - if (!report.init(cx, binExn, js::ErrorReport::WithSideEffects)) - MOZ_CRASH("Couldn't report binExn"); - - PrintError(cx, stderr, report.toStringResult(), report.report(), /* reportWarnings */ true); - MOZ_CRASH("Binary parser rejected a file that text parser accepted"); - } - - if (binParsed.isErr()) { - fprintf(stderr, "Binary parser and text parser agree that %s is invalid\n", txtPath.get()); - continue; - } - -#if defined(DEBUG) // Dumping an AST is only defined in DEBUG builds - // Compare ASTs. - Sprinter binPrinter(cx); - if (!binPrinter.init()) - MOZ_CRASH("Couldn't display binParsed"); - DumpParseTree(binParsed.unwrap(), binPrinter); - - Sprinter txtPrinter(cx); - if (!txtPrinter.init()) - MOZ_CRASH("Couldn't display txtParsed"); - DumpParseTree(txtParsed, txtPrinter); - - if (strcmp(binPrinter.string(), txtPrinter.string()) != 0) { - fprintf(stderr, "Got distinct ASTs when parsing %s:\n\tBINARY\n%s\n\n\tTEXT\n%s\n", txtPath.get(), binPrinter.string(), txtPrinter.string()); - MOZ_CRASH("Got distinct ASTs"); - } - fprintf(stderr, "Got the same AST when parsing %s\n", txtPath.get()); - -#endif // defined(DEBUG) - } - -#if defined(XP_WIN) - if (!FindClose(hFind)) - MOZ_CRASH("Could not close Find"); -#elif defined(XP_UNIX) - if (closedir(dir) != 0) - MOZ_CRASH("Could not close dir"); -#endif // defined(XP_WIN) - - return true; -} -END_TEST(testBinASTReaderECMAScript2) - diff --git a/js/src/jsapi-tests/testBinTokenReaderTester.cpp b/js/src/jsapi-tests/testBinTokenReaderTester.cpp deleted file mode 100644 index 0ebc09d685bd..000000000000 --- a/js/src/jsapi-tests/testBinTokenReaderTester.cpp +++ /dev/null @@ -1,321 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - */ -/* 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/. */ - -#include -#include - -#if defined (XP_WIN) -#include -#elif defined(XP_UNIX) -#include -#include -#endif // defined (XP_WIN) || defined (XP_UNIX) - -#include "frontend/BinTokenReaderTester.h" -#include "gc/Zone.h" - -#include "js/Vector.h" - -#include "jsapi-tests/tests.h" - -using Tokenizer = js::frontend::BinTokenReaderTester; -using Chars = Tokenizer::Chars; - -// Hack: These tests need access to resources, which are present in the source dir -// but not copied by our build system. To simplify things, we chdir to the source -// dir at the start of each test and return to the previous directory afterwards. - -#if defined(XP_UNIX) - -#include - -static int gJsDirectory(0); -void enterJsDirectory() { -// Save current directory. - MOZ_ASSERT(gJsDirectory == 0); - gJsDirectory = open(".", O_RDONLY); - MOZ_ASSERT(gJsDirectory != 0, "Could not open directory '.'"); -// Go to the directory provided by the test harness, if any. - const char* destination = getenv("CPP_UNIT_TESTS_DIR_JS_SRC"); - if (destination) { - if (chdir(destination) == -1) - MOZ_CRASH_UNSAFE_PRINTF("Could not chdir to %s", destination); - } -} - -void exitJsDirectory() { - MOZ_ASSERT(gJsDirectory); - if (fchdir(gJsDirectory) == -1) - MOZ_CRASH("Could not return to original directory"); - if (close(gJsDirectory) != 0) - MOZ_CRASH("Could not close js directory"); - gJsDirectory = 0; -} - -#else - -char gJsDirectory[MAX_PATH] = { 0 }; - -void enterJsDirectory() { - // Save current directory. - MOZ_ASSERT(strlen(gJsDirectory) == 0); - auto result = GetCurrentDirectory(MAX_PATH, gJsDirectory); - if (result <= 0) - MOZ_CRASH("Could not get current directory"); - if (result > MAX_PATH) - MOZ_CRASH_UNSAFE_PRINTF("Could not get current directory: needed %ld bytes, got %ld\n", result, MAX_PATH); - - // Find destination directory, if any. - char destination[MAX_PATH]; - if (!GetEnvironmentVariable("CPP_UNIT_TESTS_DIR_JS_SRC", destination, MAX_PATH)) { - if (GetLastError() != ERROR_ENVVAR_NOT_FOUND) - MOZ_CRASH("Could not get CPP_UNIT_TESTS_DIR_JS_SRC"); - else - return; - } - - // Go to the directory. - if (SetCurrentDirectory(destination) != 0) - MOZ_CRASH_UNSAFE_PRINTF("Could not chdir to %s", destination); -} - -void exitJsDirectory() { - MOZ_ASSERT(strlen(gJsDirectory) > 0); - if (SetCurrentDirectory(gJsDirectory) != 0) - MOZ_CRASH("Could not return to original directory"); - gJsDirectory[0] = 0; -} - -#endif // defined(XP_UNIX) || defined(XP_WIN) - -void readFull(const char* path, js::Vector& buf) { - enterJsDirectory(); - buf.shrinkTo(0); - FILE* in = fopen(path, "r"); - if (!in) - MOZ_CRASH_UNSAFE_PRINTF("Could not open %s: %s", path, strerror(errno)); - - struct stat info; - if (stat(path, &info) < 0) - MOZ_CRASH_UNSAFE_PRINTF("Could not get stat on %s", path); - - if (!buf.growBy(info.st_size)) - MOZ_CRASH("OOM"); - - int result = fread(buf.begin(), 1, info.st_size, in); - if (fclose(in) != 0) - MOZ_CRASH("Could not close input file"); - if (result != info.st_size) - MOZ_CRASH("Read error"); - exitJsDirectory(); -} - - -// Reading a simple string. -BEGIN_TEST(testBinTokenReaderTesterSimpleString) -{ - js::Vector contents(cx); - readFull("jsapi-tests/binast/tokenizer/tester/test-simple-string.binjs", contents); - Tokenizer tokenizer(cx, contents); - - Maybe found; - CHECK(tokenizer.readMaybeChars(found)); - - CHECK(Tokenizer::equals(*found, "simple string")); // FIXME: Find a way to make CHECK_EQUAL use `Tokenizer::equals`. - - return true; -} -END_TEST(testBinTokenReaderTesterSimpleString) - -// Reading a string with embedded 0. -BEGIN_TEST(testBinTokenReaderTesterStringWithEscapes) -{ - js::Vector contents(cx); - readFull("jsapi-tests/binast/tokenizer/tester/test-string-with-escapes.binjs", contents); - Tokenizer tokenizer(cx, contents); - - Maybe found; - CHECK(tokenizer.readMaybeChars(found)); - - CHECK(Tokenizer::equals(*found, "string with escapes \0\1\0")); // FIXME: Find a way to make CHECK_EQUAL use `Tokenizer::equals`. - - return true; -} -END_TEST(testBinTokenReaderTesterStringWithEscapes) - -// Reading an empty untagged tuple -BEGIN_TEST(testBinTokenReaderTesterEmptyUntaggedTuple) -{ - js::Vector contents(cx); - readFull("jsapi-tests/binast/tokenizer/tester/test-empty-untagged-tuple.binjs", contents); - Tokenizer tokenizer(cx, contents); - - { - Tokenizer::AutoTuple guard(tokenizer); - CHECK(tokenizer.enterUntaggedTuple(guard)); - CHECK(guard.done()); - } - - return true; -} -END_TEST(testBinTokenReaderTesterEmptyUntaggedTuple) - -// Reading a untagged tuple with two strings -BEGIN_TEST(testBinTokenReaderTesterTwoStringsInTuple) -{ - js::Vector contents(cx); - readFull("jsapi-tests/binast/tokenizer/tester/test-trivial-untagged-tuple.binjs", contents); - Tokenizer tokenizer(cx, contents); - - { - Tokenizer::AutoTuple guard(tokenizer); - CHECK(tokenizer.enterUntaggedTuple(guard)); - - Maybe found_0; - CHECK(tokenizer.readMaybeChars(found_0)); - CHECK(Tokenizer::equals(*found_0, "foo")); // FIXME: Find a way to make CHECK_EQUAL use `Tokenizer::equals`. - - Maybe found_1; - CHECK(tokenizer.readMaybeChars(found_1)); - CHECK(Tokenizer::equals(*found_1, "bar")); // FIXME: Find a way to make CHECK_EQUAL use `Tokenizer::equals`. - - CHECK(guard.done()); - } - - return true; -} -END_TEST(testBinTokenReaderTesterTwoStringsInTuple) - -// Reading a tagged tuple `Pattern { id: "foo", value: 3.1415}` -BEGIN_TEST(testBinTokenReaderTesterSimpleTaggedTuple) -{ - js::Vector contents(cx); - readFull("jsapi-tests/binast/tokenizer/tester/test-simple-tagged-tuple.binjs", contents); - Tokenizer tokenizer(cx, contents); - - { - js::frontend::BinKind tag; - Tokenizer::BinFields fields(cx); - Tokenizer::AutoTaggedTuple guard(tokenizer); - CHECK(tokenizer.enterTaggedTuple(tag, fields, guard)); - - CHECK(tag == js::frontend::BinKind::Pattern); - - Maybe found_id; - const double EXPECTED_value = 3.1415; - Maybe found_value; - - // Order of fields is not deterministic in the encoder (we could make - // it deterministic for the test, though, since we already know the binary). - if (fields[0] == js::frontend::BinField::Id) { - CHECK(fields[1] == js::frontend::BinField::Value); - CHECK(tokenizer.readMaybeChars(found_id)); - CHECK(tokenizer.readMaybeDouble(found_value)); - } else if (fields[0] == js::frontend::BinField::Value) { - CHECK(fields[1] == js::frontend::BinField::Id); - CHECK(tokenizer.readMaybeDouble(found_value)); - CHECK(tokenizer.readMaybeChars(found_id)); - } else { - CHECK(false); - } - - CHECK(EXPECTED_value == *found_value); // Apparently, CHECK_EQUAL doesn't work on `double`. - CHECK(Tokenizer::equals(*found_id, "foo")); - CHECK(guard.done()); - } - - return true; -} -END_TEST(testBinTokenReaderTesterSimpleTaggedTuple) - - -// Reading an empty list -BEGIN_TEST(testBinTokenReaderTesterEmptyList) -{ - js::Vector contents(cx); - readFull("jsapi-tests/binast/tokenizer/tester/test-empty-list.binjs", contents); - Tokenizer tokenizer(cx, contents); - - { - uint32_t length; - Tokenizer::AutoList guard(tokenizer); - CHECK(tokenizer.enterList(length, guard)); - - CHECK(length == 0); - CHECK(guard.done()); - } - - return true; -} -END_TEST(testBinTokenReaderTesterEmptyList) - -// Reading `["foo", "bar"]` -BEGIN_TEST(testBinTokenReaderTesterSimpleList) -{ - js::Vector contents(cx); - readFull("jsapi-tests/binast/tokenizer/tester/test-trivial-list.binjs", contents); - Tokenizer tokenizer(cx, contents); - - { - uint32_t length; - Tokenizer::AutoList guard(tokenizer); - CHECK(tokenizer.enterList(length, guard)); - - CHECK(length == 2); - - Maybe found_0; - CHECK(tokenizer.readMaybeChars(found_0)); - CHECK(Tokenizer::equals(*found_0, "foo")); - - Maybe found_1; - CHECK(tokenizer.readMaybeChars(found_1)); - CHECK(Tokenizer::equals(*found_1, "bar")); - - CHECK(guard.done()); - } - - return true; -} -END_TEST(testBinTokenReaderTesterSimpleList) - - -// Reading `[["foo", "bar"]]` -BEGIN_TEST(testBinTokenReaderTesterNestedList) -{ - js::Vector contents(cx); - readFull("jsapi-tests/binast/tokenizer/tester/test-nested-lists.binjs", contents); - Tokenizer tokenizer(cx, contents); - - { - uint32_t outerLength; - Tokenizer::AutoList outerGuard(tokenizer); - CHECK(tokenizer.enterList(outerLength, outerGuard)); - CHECK(outerLength == 1); - - { - uint32_t innerLength; - Tokenizer::AutoList innerGuard(tokenizer); - CHECK(tokenizer.enterList(innerLength, innerGuard)); - CHECK(innerLength == 2); - - Maybe found_0; - CHECK(tokenizer.readMaybeChars(found_0)); - CHECK(Tokenizer::equals(*found_0, "foo")); - - Maybe found_1; - CHECK(tokenizer.readMaybeChars(found_1)); - CHECK(Tokenizer::equals(*found_1, "bar")); - - CHECK(innerGuard.done()); - } - - CHECK(outerGuard.done()); - } - - return true; -} -END_TEST(testBinTokenReaderTesterNestedList) diff --git a/js/src/moz.build b/js/src/moz.build index 8dfe8db474f8..91aa05ea0484 100755 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -642,16 +642,6 @@ if CONFIG['NIGHTLY_BUILD']: DEFINES['ENABLE_SIMD'] = True DEFINES['ENABLE_WASM_THREAD_OPS'] = True -if CONFIG['JS_BUILD_BINAST']: - # Some parts of BinAST are designed only to test evolutions of the - # specification: - UNIFIED_SOURCES += ['frontend/BinTokenReaderTester.cpp'] - # The rest of BinAST should eventually move to release. - UNIFIED_SOURCES += [ - 'frontend/BinSource.cpp', - 'frontend/BinToken.cpp' - ] - # Wasm code should use WASM_HUGE_MEMORY instead of JS_CODEGEN_X64 # so that it is easy to use the huge-mapping optimization for other # 64-bit platforms in the future. diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 8794f40880a2..649352ed3b54 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -74,11 +74,6 @@ #include "builtin/ModuleObject.h" #include "builtin/RegExp.h" #include "builtin/TestingFunctions.h" - -#if defined(JS_BUILD_BINAST) -#include "frontend/BinSource.h" -#endif // defined(JS_BUILD_BINAST) - #include "frontend/Parser.h" #include "gc/GCInternals.h" #include "jit/arm/Simulator-arm.h" @@ -4397,64 +4392,6 @@ GetModuleLoadPath(JSContext* cx, unsigned argc, Value* vp) return true; } -#if defined(JS_BUILD_BINAST) - -static bool -BinParse(JSContext* cx, unsigned argc, Value* vp) -{ - using namespace js::frontend; - - CallArgs args = CallArgsFromVp(argc, vp); - - if (args.length() < 1) { - JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, - "parse", "0", "s"); - return false; - } - if (!args[0].isObject()) { - const char* typeName = InformalValueTypeName(args[0]); - JS_ReportErrorASCII(cx, "expected object (typed array) to parse, got %s", typeName); - return false; - } - - RootedObject obj(cx, &args[0].toObject()); - if (!JS_IsTypedArrayObject(obj)) { - const char* typeName = InformalValueTypeName(args[0]); - JS_ReportErrorASCII(cx, "expected typed array to parse, got %s", typeName); - return false; - } - - uint32_t buf_length = 0; - bool buf_isSharedMemory = false; - uint8_t* buf_data = nullptr; - GetArrayBufferViewLengthAndData(obj, &buf_length, &buf_isSharedMemory, &buf_data); - MOZ_ASSERT(buf_data); - - CompileOptions options(cx); - options.setIntroductionType("js shell bin parse") - .setFileAndLine("", 1); - - UsedNameTracker usedNames(cx); - if (!usedNames.init()) - return false; - - BinASTParser reader(cx, cx->tempLifoAlloc(), usedNames, options); - - JS::Result parsed = reader.parse(buf_data, buf_length); - if (parsed.isErr()) - return false; - -#ifdef DEBUG - Fprinter out(stderr); - DumpParseTree(parsed.unwrap(), out); -#endif - - args.rval().setUndefined(); - return true; -} - -#endif // defined(JS_BUILD_BINAST) - static bool Parse(JSContext* cx, unsigned argc, Value* vp) { @@ -4487,22 +4424,22 @@ Parse(JSContext* cx, unsigned argc, Value* vp) CompileOptions options(cx); options.setIntroductionType("js shell parse") .setFileAndLine("", 1); - UsedNameTracker usedNames(cx); if (!usedNames.init()) return false; Parser parser(cx, cx->tempLifoAlloc(), options, chars, length, - /* foldConstants = */ false, usedNames, nullptr, + /* foldConstants = */ true, usedNames, nullptr, nullptr); if (!parser.checkOptions()) return false; - ParseNode* pn = parser.parse(); // Deallocated once `parser` goes out of scope. + ParseNode* pn = parser.parse(); if (!pn) return false; #ifdef DEBUG js::Fprinter out(stderr); DumpParseTree(pn, out); + out.putChar('\n'); #endif args.rval().setUndefined(); return true; @@ -6809,14 +6746,6 @@ static const JSFunctionSpecWithHelp shell_functions[] = { " Return any --module-load-path argument passed to the shell. Used by the\n" " module loader.\n"), -#if defined(JS_BUILD_BINAST) - -JS_FN_HELP("parseBin", BinParse, 1, 0, -"parseBin(arraybuffer)", -" Parses a Binary AST, potentially throwing."), - -#endif // defined(JS_BUILD_BINAST) - JS_FN_HELP("parse", Parse, 1, 0, "parse(code)", " Parses a string, potentially throwing."), diff --git a/testing/runcppunittests.py b/testing/runcppunittests.py index 573da30d24a5..d9e4f01c4a58 100755 --- a/testing/runcppunittests.py +++ b/testing/runcppunittests.py @@ -8,7 +8,6 @@ from __future__ import with_statement import sys import os from optparse import OptionParser -from os import environ as env import manifestparser import mozprocess import mozinfo @@ -18,9 +17,6 @@ import mozlog SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(__file__))) -# Export directory js/src for tests that need it. -env['CPP_UNIT_TESTS_DIR_JS_SRC'] = os.path.abspath(os.path.join(SCRIPT_DIR, "..", "..")) - class CPPUnitTests(object): # Time (seconds) to wait for test process to complete