Skip to content

Commit

Permalink
Intro enum for categories of not supported reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnaldo authored and doehyunbaek committed Dec 13, 2022
1 parent f0d4ce6 commit 1d467c1
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 103 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"negative-errors": [
"negative": [
"built-ins/AsyncGeneratorFunction/instance-await-expr-in-param",
"built-ins/AsyncGeneratorFunction/instance-yield-expr-in-param",
"built-ins/Function/StrictFunction_reservedwords_with",
Expand Down Expand Up @@ -181,65 +181,6 @@
"language/statements/with/12.10.1-16-s",
"language/statements/with/12.10.1-7-s"
],
"long-tests": [
"built-ins/Array/length/S15.4.5.2_A3_T4",
"built-ins/Array/prototype/Symbol.unscopables/value",
"built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-sparse-object",
"built-ins/Array/prototype/every/15.4.4.16-7-c-ii-2",
"built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-1",
"built-ins/Array/prototype/flatMap/array-like-objects",
"built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-1",
"built-ins/Array/prototype/indexOf/15.4.4.14-10-1",
"built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-1",
"built-ins/Array/prototype/map/15.4.4.19-8-c-ii-1",
"built-ins/Array/prototype/some/15.4.4.17-7-c-ii-2",
"built-ins/RegExp/S15.10.2.8_A3_T15",
"built-ins/RegExp/S15.10.2.8_A3_T16",
"built-ins/RegExp/property-escapes/generated/Changes_When_NFKC_Casefolded",
"built-ins/RegExp/property-escapes/generated/General_Category_-_Letter",
"built-ins/RegExp/property-escapes/generated/General_Category_-_Other",
"built-ins/RegExp/property-escapes/generated/General_Category_-_Unassigned",
"built-ins/RegExp/property-escapes/generated/ID_Continue",
"built-ins/RegExp/property-escapes/generated/ID_Start",
"language/expressions/call/tco-call-args",
"language/expressions/call/tco-member-args",
"language/expressions/class/async-gen-method-static/yield-star-async-throw",
"language/expressions/coalesce/tco-pos-null",
"language/expressions/coalesce/tco-pos-undefined",
"language/expressions/comma/tco-final",
"language/expressions/conditional/tco-cond",
"language/expressions/conditional/tco-pos",
"language/expressions/logical-and/tco-right",
"language/expressions/logical-or/tco-right",
"language/expressions/tco-pos",
"language/reserved-words/ident-name-keyword-accessor",
"language/reserved-words/ident-name-keyword-prop-name",
"language/statements/block/tco-stmt",
"language/statements/block/tco-stmt-list",
"language/statements/do-while/tco-body",
"language/statements/for/tco-const-body",
"language/statements/for/tco-let-body",
"language/statements/for/tco-lhs-body",
"language/statements/for/tco-var-body",
"language/statements/function/S13.2.1_A1_T1",
"language/statements/if/tco-else-body",
"language/statements/if/tco-if-body",
"language/statements/labeled/tco",
"language/statements/return/tco",
"language/statements/switch/tco-case-body",
"language/statements/switch/tco-case-body-dflt",
"language/statements/switch/tco-dftl-body",
"language/statements/try/tco-catch",
"language/statements/try/tco-catch-finally",
"language/statements/try/tco-finally",
"language/statements/while/tco-body",
"language/types/number/8.5.1"
],
"non-tests": [
"built-ins/ShadowRealm/prototype/importValue/import-value_FIXTURE",
"built-ins/ShadowRealm/prototype/importValue/import-value_syntax_error_FIXTURE",
"built-ins/ShadowRealm/prototype/importValue/import-value_throws_FIXTURE"
],
"non-strict": [
"built-ins/Function/S15.3.2.1_A3_T8",
"built-ins/Function/S15.3.5_A2_T1",
Expand Down Expand Up @@ -300,7 +241,61 @@
"language/statements/variable/12.2.1-17-s",
"language/statements/variable/12.2.1-21-s"
],
"wrong-tests": [
"long": [
"built-ins/Array/length/S15.4.5.2_A3_T4",
"built-ins/Array/prototype/Symbol.unscopables/value",
"built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-sparse-object",
"built-ins/Array/prototype/every/15.4.4.16-7-c-ii-2",
"built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-1",
"built-ins/Array/prototype/flatMap/array-like-objects",
"built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-1",
"built-ins/Array/prototype/indexOf/15.4.4.14-10-1",
"built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-1",
"built-ins/Array/prototype/map/15.4.4.19-8-c-ii-1",
"built-ins/Array/prototype/some/15.4.4.17-7-c-ii-2",
"built-ins/RegExp/S15.10.2.8_A3_T15",
"built-ins/RegExp/S15.10.2.8_A3_T16",
"built-ins/RegExp/property-escapes/generated/Changes_When_NFKC_Casefolded",
"built-ins/RegExp/property-escapes/generated/General_Category_-_Letter",
"built-ins/RegExp/property-escapes/generated/General_Category_-_Other",
"built-ins/RegExp/property-escapes/generated/General_Category_-_Unassigned",
"built-ins/RegExp/property-escapes/generated/ID_Continue",
"built-ins/RegExp/property-escapes/generated/ID_Start",
"language/expressions/call/tco-call-args",
"language/expressions/call/tco-member-args",
"language/expressions/class/async-gen-method-static/yield-star-async-throw",
"language/expressions/coalesce/tco-pos-null",
"language/expressions/coalesce/tco-pos-undefined",
"language/expressions/comma/tco-final",
"language/expressions/conditional/tco-cond",
"language/expressions/conditional/tco-pos",
"language/expressions/logical-and/tco-right",
"language/expressions/logical-or/tco-right",
"language/expressions/tco-pos",
"language/reserved-words/ident-name-keyword-accessor",
"language/reserved-words/ident-name-keyword-prop-name",
"language/statements/block/tco-stmt",
"language/statements/block/tco-stmt-list",
"language/statements/do-while/tco-body",
"language/statements/for/tco-const-body",
"language/statements/for/tco-let-body",
"language/statements/for/tco-lhs-body",
"language/statements/for/tco-var-body",
"language/statements/function/S13.2.1_A1_T1",
"language/statements/if/tco-else-body",
"language/statements/if/tco-if-body",
"language/statements/labeled/tco",
"language/statements/return/tco",
"language/statements/switch/tco-case-body",
"language/statements/switch/tco-case-body-dflt",
"language/statements/switch/tco-dftl-body",
"language/statements/try/tco-catch",
"language/statements/try/tco-catch-finally",
"language/statements/try/tco-finally",
"language/statements/while/tco-body",
"language/types/number/8.5.1"
],
"wrong": [
"built-ins/AsyncGeneratorPrototype/return/return-state-completed-broken-promise",
"built-ins/AsyncGeneratorPrototype/return/return-suspendedStart-broken-promise"
]
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/esmeta/analyzer/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import esmeta.analyzer.domain.*
import esmeta.analyzer.util.*
import esmeta.cfg.{CFG, Node}
import esmeta.error.*
import esmeta.error.NotSupported.given
import esmeta.es.Initialize
import esmeta.ir.*
import esmeta.state.*
Expand Down
23 changes: 22 additions & 1 deletion src/main/scala/esmeta/error/NotSupported.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,25 @@ case class NotSupported(reasonPath: NotSupported.ReasonPath)
object NotSupported:
type Reason = String
type ReasonPath = List[Reason]
def apply(reason: Reason): NotSupported = NotSupported(List(reason))
def unapply(ns: NotSupported): Option[ReasonPath] = Some(ns.reasonPath)
def apply(category: Category)(reasonPath: ReasonPath): NotSupported =
NotSupported(category.name :: reasonPath)

/** implicit conversion from reasons to reason paths */
given Conversion[Reason, ReasonPath] = List(_)

/** constants for categories of not supported features */
enum Category(val name: String) {
case Harness extends Category("harness")
case Internationalisation extends Category("internationalisation")
case Annex extends Category("annex")
case Negative extends Category("negative")
case NonStrict extends Category("non-strict")
case Module extends Category("module")
case Fixture extends Category("fixture")
case Feature extends Category("feature")
case Metalanguage extends Category("metalanguage")
case Long extends Category("long")
case Wrong extends Category("wrong")
case YetCategorized extends Category("yet-categorized")
}
19 changes: 12 additions & 7 deletions src/main/scala/esmeta/interpreter/Interpreter.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package esmeta.interpreter

import esmeta.{EVAL_LOG_DIR, LINE_SEP, NOT_SUPPORTED_FEATURES}
import esmeta.{EVAL_LOG_DIR, LINE_SEP}
import esmeta.analyzer.*
import esmeta.cfg.*
import esmeta.error.*
import esmeta.error.NotSupported.{*, given}
import esmeta.error.NotSupported.Category.*
import esmeta.ir.{Func => IRFunc, *}
import esmeta.es.*
import esmeta.parser.{ESParser, ESValueParser}
Expand Down Expand Up @@ -245,7 +247,7 @@ class Interpreter(
case v => throw NoNt(nt, v)
st.allocList(eval(ast).asAst.getItems(name).map(AstValue(_)))
case EYet(msg) =>
throw NotSupported(List("metalanguage", msg))
throw NotSupported(Metalanguage)(List(msg))
case EContains(list, elem, field) =>
val l = eval(list).getList(list, st)
val e = eval(elem)
Expand Down Expand Up @@ -666,7 +668,7 @@ object Interpreter {
Str(ESValueParser.parseTRVTemplateTail(str))
case (_, "Contains") => Bool(false)
case ("RegularExpressionLiteral", name) =>
throw NotSupported(List(NOT_SUPPORTED_FEATURES, "RegExp", sdoName))
throw NotSupported(Feature)(List("RegExp"))
case _ =>
throw InvalidAstProp(lex, Str(sdoName))
}
Expand Down Expand Up @@ -810,10 +812,13 @@ object Interpreter {
case (MOp.Sinh, List(Math(x))) => Math(sinh(x.toDouble))
case (MOp.Tanh, List(Math(x))) => Math(tanh(x.toDouble))
case (MOp.Acos, List(Math(x))) => Math(acos(x.toDouble))
case (MOp.Acosh, List(Math(x))) => throw NotSupported("acosh")
case (MOp.Asinh, List(Math(x))) => throw NotSupported("asinh")
case (MOp.Atanh, List(Math(x))) => throw NotSupported("atanh")
case (MOp.Asin, List(Math(x))) => Math(asin(x.toDouble))
case (MOp.Acosh, List(Math(x))) =>
throw NotSupported(Metalanguage)("acosh")
case (MOp.Asinh, List(Math(x))) =>
throw NotSupported(Metalanguage)("asinh")
case (MOp.Atanh, List(Math(x))) =>
throw NotSupported(Metalanguage)("atanh")
case (MOp.Asin, List(Math(x))) => Math(asin(x.toDouble))
case (MOp.Atan2, List(Math(x), Math(y))) =>
Math(atan2(x.toDouble, y.toDouble))
case (MOp.Atan, List(Math(x))) => Math(atan(x.toDouble))
Expand Down
3 changes: 0 additions & 3 deletions src/main/scala/esmeta/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ var STATUS_MODE = false
var TEST262_DIR = s"$TEST_DIR/test262"
def TEST262_TEST_DIR = s"$TEST262_DIR/test"

/** constant string for not supported features */
val NOT_SUPPORTED_FEATURES = "not-supported-features"

// -----------------------------------------------------------------------------
// Mutable Global Options
// -----------------------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/esmeta/state/Heap.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package esmeta.state

import esmeta.{NOT_SUPPORTED_FEATURES}
import esmeta.cfg.*
import esmeta.error.*
import esmeta.error.NotSupported.{*, given}
import esmeta.error.NotSupported.Category.*
import esmeta.ir.{Func => IRFunc, *}
import esmeta.es.builtin.*
import esmeta.util.BaseUtils.*
Expand All @@ -17,15 +18,14 @@ case class Heap(
/** getters */
def apply(addr: Addr): Obj =
map.getOrElse(addr, throw UnknownAddr(addr)) match
case YetObj(_, msg) =>
throw NotSupported(List(NOT_SUPPORTED_FEATURES, msg))
case obj => obj
case YetObj(_, msg) => throw NotSupported(Feature)(msg)
case obj => obj
def apply(addr: Addr, key: PureValue): Value = apply(addr) match
case _ if addr == NamedAddr(INTRINSICS) => Heap.getIntrinsics(key)
case (s: SymbolObj) => s(key)
case (m: MapObj) => m(key)
case (l: ListObj) => l(key)
case YetObj(_, msg) => throw NotSupported(List(NOT_SUPPORTED_FEATURES, msg))
case YetObj(_, msg) => throw NotSupported(Feature)(msg)

/** setters */
def update(addr: Addr, prop: PureValue, value: Value): this.type =
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/esmeta/test262/util/ManualConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object ManualConfig {
if jsonFilter(file.getName)
} yield file.getName -> file.toString).toMap
val filtered = fileMap
.get("filtered.json")
.get("categorized.json")
.fold(Map())(readJson[Map[String, List[String]]])
val yetCategorized = fileMap
.get("yet-categorized.json")
Expand Down
52 changes: 27 additions & 25 deletions src/main/scala/esmeta/test262/util/TestFilter.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package esmeta.test262.util

import esmeta.*
import esmeta.spec.Spec
import esmeta.util.*
import esmeta.util.BaseUtils.*
import esmeta.util.SystemUtils.*
import esmeta.error.NotSupported.*
import esmeta.error.NotSupported.Category.*
import esmeta.test262.{*, given}
import io.circe.*, io.circe.syntax.*
import java.io.*
Expand Down Expand Up @@ -35,54 +35,56 @@ case class TestFilter(spec: Spec) {
withYet: Boolean,
features: Set[String],
): List[Test => Option[ReasonPath]] = List(
"harness" -> ((test: Test) => test.relName.startsWith("harness")),
"internationalisation" -> ((test: Test) => test.relName.startsWith("intl")),
"annex" -> ((test: Test) =>
// harness files
Harness -> ((test: Test) => test.relName.startsWith("harness")),
// tests for internationalisation
Internationalisation -> ((test: Test) => test.relName.startsWith("intl")),
// tests for appendices, including web browsers
Annex -> ((test: Test) =>
test.relName.startsWith("annex") ||
test.relName.contains("__proto__"),
),
NOT_SUPPORTED_FEATURES -> ((test: Test) =>
test.features.find(!features.contains(_)),
),
"non-strict" -> ((test: Test) =>
// tests for negative result, including parsing errors
Negative -> ((test: Test) => test.negative.isDefined),
// tests for non-strict mode
NonStrict -> ((test: Test) =>
test.flags.contains("noStrict") ||
test.flags.contains("raw"),
),
"module" -> ((test: Test) =>
// tests for modules
Module -> ((test: Test) =>
test.flags.contains("module") ||
test.relName.startsWith("language/module-code/") ||
test.relName.startsWith("language/import/") ||
test.relName.startsWith("language/expressions/dynamic-import/") ||
test.relName.startsWith("language/expressions/import.meta/"),
),
"negative-errors" -> ((test: Test) => test.negative.isDefined),
"inessential-builtin-objects" -> ((test: Test) =>
test.flags.contains("CanBlockIsFalse") ||
test.flags.contains("CanBlockIsTrue") ||
!test.locales.isEmpty,
),
// manually filter tests
test => manualFilterMap.get(removedExt(test.relName)),
// manually filter not yet categorized tests
"not-yet-categorized" -> ((test: Test) =>
// fixtures
Fixture -> ((test: Test) => removedExt(test.relName).endsWith("_FIXTURE")),
// tests for language features not supported in ESMeta
Feature -> ((test: Test) => test.features.find(!features.contains(_))),
// manually filtered tests not yet categorized based on failure reasons
YetCategorized -> ((test: Test) =>
!withYet && manualYetCategorized.contains(removedExt(test.relName)),
),
// manually filtered tests categorized based on failure reasons
test => manualFilterMap.get(removedExt(test.relName)),
)

given liftBool: Conversion[
(String, Test => Boolean),
(Category, Test => Boolean),
Test => Option[ReasonPath],
] = pair =>
val (name, filter) = pair
val lifted = (x: Test) => if (filter(x)) Some(List(name)) else None
val (category, filter) = pair
val lifted = (x: Test) => if (filter(x)) Some(List(category.name)) else None
lifted

given liftReason: Conversion[
(String, Test => Option[Reason]),
(Category, Test => Option[Reason]),
Test => Option[ReasonPath],
] = pair =>
val (name, filter) = pair
test => filter(test).map(List(name, _))
val (category, filter) = pair
test => filter(test).map(List(category.name, _))

lazy val manualConfig = spec.manualInfo.test262

Expand Down

0 comments on commit 1d467c1

Please sign in to comment.