Commit 233e3c18 authored by Tamer Tas's avatar Tamer Tas Committed by Commit Bot

[preparser] deprecate stand-alone "preparser" test-suite

"preparser" is a legacy test-suite written in Python. "cctest/test-parsing"
provides the same coverage and more for the preparser.

This CL removes "preparser" stand-alone test-suite

R=verwaest@chromium.org
CC=​machenbach@chromium.org

Bug: v8:10001
Change-Id: I1823967e654e8d6d9e42eadfd667f90074d57ba9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1926027Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Auto-Submit: Tamer Tas <tmrts@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65059}
parent 4e19e38b
......@@ -14,7 +14,6 @@ group("gn_all") {
"message:v8_message",
"mjsunit:v8_mjsunit",
"mozilla:v8_mozilla",
"preparser:v8_preparser",
"test262:v8_test262",
"wasm-js:v8_wasm_js",
"wasm-spec-tests:v8_wasm_spec_tests",
......@@ -74,7 +73,6 @@ group("v8_bot_default") {
"message:v8_message",
"mjsunit:v8_mjsunit",
"mkgrokdump:mkgrokdump",
"preparser:v8_preparser",
"unittests:unittests",
"wasm-api-tests:wasm_api_tests",
"wasm-js:v8_wasm_js",
......@@ -95,7 +93,6 @@ group("v8_default") {
"message:v8_message",
"mjsunit:v8_mjsunit",
"mkgrokdump:mkgrokdump",
"preparser:v8_preparser",
"unittests:unittests",
"wasm-api-tests:wasm_api_tests",
"wasm-js:v8_wasm_js",
......@@ -124,7 +121,6 @@ group("v8_d8_default") {
"intl:v8_intl",
"message:v8_message",
"mjsunit:v8_mjsunit",
"preparser:v8_preparser",
"webkit:v8_webkit",
]
}
......
# Copyright 2018 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
group("v8_preparser") {
testonly = true
data_deps = [
"../..:d8",
"../../tools:v8_testrunner",
]
data = [
"./",
]
}
marja@chromium.org
verwaest@chromium.org
# Copyright 2011 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Templatated tests with duplicate parameter names.
# ----------------------------------------------------------------------
# Constants and utility functions
# A template that performs the same strict-mode test in different
# scopes (global scope, function scope, and nested function scope),
# and in non-strict mode too.
def DuplicateParameterTest(name, source):
expectation = "strict_param_dupe"
non_selfstrict = {"selfstrict":"", "id":"selfnormal"}
Template(name, '"use strict";\n' + source)(non_selfstrict, expectation)
Template(name + '-infunc',
'function foo() {\n "use strict";\n' + source +'\n}\n')(
non_selfstrict, expectation)
Template(name + '-infunc2',
'function foo() {\n "use strict";\n function bar() {\n' +
source +'\n }\n}\n')(non_selfstrict, expectation)
selfstrict = {"selfstrict": "\"use strict\";", "id": "selfstrict"}
nestedstrict = {"selfstrict": "function bar(){\"use strict\";}",
"id": "nestedstrict"}
selfstrictnestedclean = {"selfstrict": """
"use strict";
function bar(){}
""", "id": "selfstrictnestedclean"}
selftest = Template(name + '-$id', source)
selftest(selfstrict, expectation)
selftest(selfstrictnestedclean, expectation)
selftest(nestedstrict, None)
selftest(non_selfstrict, None)
# ----------------------------------------------------------------------
# Test templates
DuplicateParameterTest("dups", """
function foo(a, a) { $selfstrict }
""");
DuplicateParameterTest("dups-apart", """
function foo(a, b, c, d, e, f, g, h, i, j, k, l, m, n, a) { $selfstrict }
""");
DuplicateParameterTest("dups-escaped", """
function foo(\u0061, b, c, d, e, f, g, h, i, j, k, l, m, n, a) { $selfstrict }
""");
DuplicateParameterTest("triples", """
function foo(a, b, c, d, e, f, g, h, a, i, j, k, l, m, n, a) { $selfstrict }
""");
DuplicateParameterTest("escapes", """
function foo(a, \u0061) { $selfstrict }
""");
DuplicateParameterTest("long-names", """
function foo(arglebargleglopglyfarglebargleglopglyfarglebargleglopglyfa,
arglebargleglopglyfarglebargleglopglyfarglebargleglopglyfa) {
$selfstrict
}
""");
# Copyright 2011 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[
[ALWAYS, {
}], # ALWAYS
]
# Copyright 2011 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Templatated tests with eval/arguments/future reserved words.
# ----------------------------------------------------------------------
# Constants and utility functions
reserved_words = [
'class',
'const', # Has other error message than other reserved words.
'enum',
'export',
'extends',
'import',
'super'
]
strict_reserved_words = [
'implements',
'interface',
'let',
'package',
'private',
'protected',
'public',
'static',
'yield'
]
assign_ops = {
"=": "assign",
"+=": "addeq",
"-=": "subeq",
"*=": "muleq",
"/=": "diveq",
"%=": "modeq",
"&=": "andeq",
"|=": "oreq",
"^=": "xoreq",
"<<=": "shleq",
">>=": "asreq",
">>>=": "lsreq"
}
# A template that performs the same strict-mode test in different
# scopes (global scope, function scope, and nested function scope).
def StrictTemplate(name, source):
def MakeTests(replacement, expectation):
Template(name, '"use strict";\n' + source)(replacement, expectation)
Template(name + '-infunc',
'function foo() {\n "use strict";\n' + source +'\n}\n')(
replacement, expectation)
Template(name + '-infunc2',
'function foo() {\n "use strict";\n function bar() {\n' +
source +'\n }\n}\n')(replacement, expectation)
return MakeTests
# ----------------------------------------------------------------------
# Test templates
arg_name_own = Template("argument-name-own-$id", """
function foo($id) {
"use strict";
}
""")
arg_name_nested = Template("argument-name-nested-$id", """
function foo() {
"use strict";
function bar($id) { }
}
""")
func_name_own = Template("function-name-own-$id", """
function $id(foo) {
"use strict";
}
""")
func_name_nested = Template("function-name-nested-$id", """
function foo() {
"use strict";
function $id(bar) { }
}
""")
catch_var = StrictTemplate("catch-$id", """
try { } catch ($id) { }
""")
declare_var = StrictTemplate("var-$id", """
var $id = 42;
""")
assign_var = StrictTemplate("assign-$id-$opname", """
var x = $id $op 42;
""")
prefix_var = StrictTemplate("prefix-$opname-$id", """
var x = $op$id;
""")
postfix_var = StrictTemplate("postfix-$opname-$id", """
var x = $id$op;
""")
read_var = StrictTemplate("read-reserved-$id", """
var x = $id;
""")
setter_arg = StrictTemplate("setter-param-$id", """
var x = {set foo($id) { }};
""")
label_normal = Template("label-normal-$id", """
$id: '';
""")
label_strict = StrictTemplate("label-strict-$id", """
$id: '';
""")
break_normal = Template("break-normal-$id", """
$id: for (;false;) {
break $id;
}
""")
break_strict = StrictTemplate("break-strict-$id", """
$id: for (;false;) {
break $id;
}
""")
continue_normal = Template("continue-normal-$id", """
$id: for (;false;) {
continue $id;
}
""")
continue_strict = StrictTemplate("continue-strict-$id", """
$id: for (;false;) {
continue $id;
}
""")
non_strict_use = Template("nonstrict-$id", """
var $id = 42;
$id++;
$id--;
++$id;
--$id;
$id += 10;
$id -= 10;
try {} catch ($id) { }
function $id($id) { }
var x = {$id: 42};
x = {get $id() {}, set $id(value) {}};
function foo() { "use strict;" }
var $id = 42;
$id++;
$id--;
++$id;
--$id;
$id += 10;
$id -= 10;
try {} catch ($id) { }
function $id($id) { }
x = {$id: 42};
x = {get $id() {}, set $id(value) {}};
$id: '';
""")
identifier_name_source = """
var x = {$id: 42};
x = {get $id() {}, set $id(value) {}};
x.$id = 42;
function foo() { "use strict;" }
x = {$id: 42};
x = {get $id() {}, set $id(value) {}};
x.$id = 42;
"""
identifier_name = Template("identifier_name-$id", identifier_name_source)
identifier_name_strict = StrictTemplate("identifier_name_strict-$id",
identifier_name_source)
# ----------------------------------------------------------------------
# Run tests
# eval and arguments have specific exceptions for different uses.
for id in ["eval", "arguments"]:
arg_name_own({"id": id}, "strict_param_name")
arg_name_nested({"id": id}, "strict_param_name")
func_name_own({"id": id}, "strict_function_name")
func_name_nested({"id": id}, "strict_function_name")
setter_arg({"id": id}, "strict_param_name")
for op in assign_ops.keys():
assign_var({"id": id, "op":op, "opname": assign_ops[op]},
"strict_lhs_assignment")
catch_var({"id": id}, "strict_catch_variable")
declare_var({"id": id}, "strict_var_name")
prefix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_prefix")
prefix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_prefix")
postfix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_postfix")
postfix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_postfix")
label_normal({"id": id}, None)
label_strict({"id": id}, None)
break_normal({"id": id}, None)
break_strict({"id": id}, None)
continue_normal({"id": id}, None)
continue_strict({"id": id}, None)
non_strict_use({"id": id}, None)
# Reserved words just throw the same exception in all cases
# (with "const" being special, as usual).
for reserved_word in reserved_words + strict_reserved_words:
if (reserved_word in strict_reserved_words):
message = "strict_reserved_word"
label_message = None
elif (reserved_word == "const"):
message = "unexpected_token"
label_message = message
else:
message = "reserved_word"
label_message = message
arg_name_own({"id":reserved_word}, message)
arg_name_nested({"id":reserved_word}, message)
setter_arg({"id": reserved_word}, message)
func_name_own({"id":reserved_word}, message)
func_name_nested({"id":reserved_word}, message)
for op in assign_ops.keys():
assign_var({"id":reserved_word, "op":op, "opname": assign_ops[op]}, message)
catch_var({"id":reserved_word}, message)
declare_var({"id":reserved_word}, message)
prefix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message)
prefix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message)
postfix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message)
postfix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message)
read_var({"id": reserved_word}, message)
identifier_name({"id": reserved_word}, None);
identifier_name_strict({"id": reserved_word}, None);
label_normal({"id": reserved_word}, label_message)
break_normal({"id": reserved_word}, label_message)
continue_normal({"id": reserved_word}, label_message)
if (reserved_word == "const"):
# The error message for this case is different because
# ParseLabelledStatementOrExpression will try to parse this as an expression
# first, effectively disallowing the use in ParseVariableDeclarations, i.e.
# the preparser never sees that 'const' was intended to be a label.
label_strict({"id": reserved_word}, "strict_const")
else:
label_strict({"id": reserved_word}, message)
break_strict({"id": reserved_word}, message)
continue_strict({"id": reserved_word}, message)
# Future reserved words in strict mode behave like normal identifiers
# in a non strict context.
for reserved_word in strict_reserved_words:
non_strict_use({"id": reserved_word}, None)
......@@ -106,4 +106,3 @@ sync_dir tools/profviz
sync_dir test/intl
sync_dir test/message
sync_dir test/mjsunit
sync_dir test/preparser
......@@ -52,7 +52,7 @@ DEFAULT_TARGETS = ["d8"]
# Tests that run-tests.py would run by default that can be run with
# BUILD_TARGETS_TESTS.
DEFAULT_TESTS = ["cctest", "debugger", "intl", "message", "mjsunit",
"preparser", "unittests"]
"unittests"]
# These can be suffixed to any <arch>.<mode> combo, or used standalone,
# or used as global modifiers (affecting all <arch>.<mode> combos).
ACTIONS = {
......@@ -83,7 +83,6 @@ TESTSUITES_TARGETS = {"benchmarks": "d8",
"message": "d8",
"mjsunit": "d8",
"mozilla": "d8",
"preparser": "d8",
"test262": "d8",
"unittests": "unittests",
"wasm-api-tests": "wasm_api_tests",
......
......@@ -61,7 +61,6 @@ TEST_MAP = {
"wasm-js",
"fuzzer",
"message",
"preparser",
"intl",
"unittests",
"wasm-api-tests",
......@@ -77,7 +76,6 @@ TEST_MAP = {
"wasm-js",
"fuzzer",
"message",
"preparser",
"intl",
"unittests",
"wasm-api-tests",
......@@ -88,7 +86,6 @@ TEST_MAP = {
"mjsunit",
"webkit",
"message",
"preparser",
"intl",
],
# This needs to stay in sync with "v8_optimize_for_size" in test/BUILD.gn.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment