Browse Source

Cleanup 262 tester and stabilize some experimental features (#3632)

* Cleanup 262 tester and graduate some experimental features

* Fix import
pull/3633/head
José Julián Espina 10 months ago committed by GitHub
parent
commit
5628637cfb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 16
      core/engine/src/builtins/map/mod.rs
  2. 14
      core/engine/src/builtins/object/mod.rs
  3. 15
      core/engine/src/builtins/promise/mod.rs
  4. 12
      core/engine/src/context/intrinsics.rs
  5. 2
      test262_config.toml
  6. 18
      tests/tester/src/edition.rs

16
core/engine/src/builtins/map/mod.rs

@ -54,7 +54,8 @@ impl IntrinsicObject for Map {
.name(js_string!("entries")) .name(js_string!("entries"))
.build(); .build();
let obj = BuiltInBuilder::from_standard_constructor::<Self>(realm) BuiltInBuilder::from_standard_constructor::<Self>(realm)
.static_method(Self::group_by, js_string!("groupBy"), 2)
.static_accessor( .static_accessor(
JsSymbol::species(), JsSymbol::species(),
Some(get_species), Some(get_species),
@ -89,12 +90,8 @@ impl IntrinsicObject for Map {
Some(get_size), Some(get_size),
None, None,
Attribute::CONFIGURABLE, Attribute::CONFIGURABLE,
); )
.build();
#[cfg(feature = "experimental")]
let obj = { obj.static_method(Self::group_by, js_string!("groupBy"), 2) };
obj.build();
} }
fn get(intrinsics: &Intrinsics) -> JsObject { fn get(intrinsics: &Intrinsics) -> JsObject {
@ -516,8 +513,7 @@ impl Map {
/// [`Map.groupBy ( items, callbackfn )`][spec] /// [`Map.groupBy ( items, callbackfn )`][spec]
/// ///
/// [spec]: https://tc39.es/proposal-array-grouping/#sec-map.groupby /// [spec]: https://tc39.es/ecma262/#sec-map.groupby
#[cfg(feature = "experimental")]
pub(crate) fn group_by( pub(crate) fn group_by(
_: &JsValue, _: &JsValue,
args: &[JsValue], args: &[JsValue],
@ -535,7 +531,7 @@ impl Map {
// 1. Let groups be ? GroupBy(items, callbackfn, zero). // 1. Let groups be ? GroupBy(items, callbackfn, zero).
// `GroupBy` // `GroupBy`
// https://tc39.es/proposal-array-grouping/#sec-group-by // https://tc39.es/ecma262/#sec-groupby
// inlined to change the key type. // inlined to change the key type.
// 1. Perform ? RequireObjectCoercible(items). // 1. Perform ? RequireObjectCoercible(items).

14
core/engine/src/builtins/object/mod.rs

@ -60,7 +60,7 @@ impl IntrinsicObject for OrdinaryObject {
.name(js_string!("set __proto__")) .name(js_string!("set __proto__"))
.build(); .build();
let obj = BuiltInBuilder::from_standard_constructor::<Self>(realm) BuiltInBuilder::from_standard_constructor::<Self>(realm)
.inherits(None) .inherits(None)
.accessor( .accessor(
utf16!("__proto__"), utf16!("__proto__"),
@ -135,12 +135,9 @@ impl IntrinsicObject for OrdinaryObject {
1, 1,
) )
.static_method(Self::has_own, js_string!("hasOwn"), 2) .static_method(Self::has_own, js_string!("hasOwn"), 2)
.static_method(Self::from_entries, js_string!("fromEntries"), 1); .static_method(Self::from_entries, js_string!("fromEntries"), 1)
.static_method(Self::group_by, js_string!("groupBy"), 2)
#[cfg(feature = "experimental")] .build();
let obj = { obj.static_method(Self::group_by, js_string!("groupBy"), 2) };
obj.build();
} }
fn get(intrinsics: &Intrinsics) -> JsObject { fn get(intrinsics: &Intrinsics) -> JsObject {
@ -1348,8 +1345,7 @@ impl OrdinaryObject {
/// [`Object.groupBy ( items, callbackfn )`][spec] /// [`Object.groupBy ( items, callbackfn )`][spec]
/// ///
/// [spec]: https://tc39.es/proposal-array-grouping/#sec-object.groupby /// [spec]: https://tc39.es/ecma262/#sec-object.groupby
#[cfg(feature = "experimental")]
pub(crate) fn group_by( pub(crate) fn group_by(
_: &JsValue, _: &JsValue,
args: &[JsValue], args: &[JsValue],

15
core/engine/src/builtins/promise/mod.rs

@ -340,13 +340,14 @@ impl IntrinsicObject for Promise {
.name(js_string!("get [Symbol.species]")) .name(js_string!("get [Symbol.species]"))
.build(); .build();
let builder = BuiltInBuilder::from_standard_constructor::<Self>(realm) BuiltInBuilder::from_standard_constructor::<Self>(realm)
.static_method(Self::all, js_string!("all"), 1) .static_method(Self::all, js_string!("all"), 1)
.static_method(Self::all_settled, js_string!("allSettled"), 1) .static_method(Self::all_settled, js_string!("allSettled"), 1)
.static_method(Self::any, js_string!("any"), 1) .static_method(Self::any, js_string!("any"), 1)
.static_method(Self::race, js_string!("race"), 1) .static_method(Self::race, js_string!("race"), 1)
.static_method(Self::reject, js_string!("reject"), 1) .static_method(Self::reject, js_string!("reject"), 1)
.static_method(Self::resolve, js_string!("resolve"), 1) .static_method(Self::resolve, js_string!("resolve"), 1)
.static_method(Self::with_resolvers, js_string!("withResolvers"), 0)
.static_accessor( .static_accessor(
JsSymbol::species(), JsSymbol::species(),
Some(get_species), Some(get_species),
@ -361,13 +362,8 @@ impl IntrinsicObject for Promise {
JsSymbol::to_string_tag(), JsSymbol::to_string_tag(),
Self::NAME, Self::NAME,
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
); )
.build();
#[cfg(feature = "experimental")]
let builder =
builder.static_method(Self::with_resolvers, crate::js_string!("withResolvers"), 0);
builder.build();
} }
fn get(intrinsics: &Intrinsics) -> JsObject { fn get(intrinsics: &Intrinsics) -> JsObject {
@ -471,8 +467,7 @@ impl Promise {
/// Creates a new promise that is pending, and returns that promise plus the resolve and reject /// Creates a new promise that is pending, and returns that promise plus the resolve and reject
/// functions associated with it. /// functions associated with it.
/// ///
/// [spec]: https://tc39.es/proposal-promise-with-resolvers/#sec-promise.withResolvers /// [spec]: https://tc39.es/ecma262/#sec-promise.withResolvers
#[cfg(feature = "experimental")]
pub(crate) fn with_resolvers( pub(crate) fn with_resolvers(
this: &JsValue, this: &JsValue,
_args: &[JsValue], _args: &[JsValue],

12
core/engine/src/context/intrinsics.rs

@ -1350,7 +1350,6 @@ pub(crate) struct ObjectTemplates {
namespace: ObjectTemplate, namespace: ObjectTemplate,
#[cfg(feature = "experimental")]
with_resolvers: ObjectTemplate, with_resolvers: ObjectTemplate,
} }
@ -1381,10 +1380,10 @@ impl ObjectTemplates {
); );
string.set_prototype(constructors.string().prototype()); string.set_prototype(constructors.string().prototype());
let mut regexp_without_prototype = ObjectTemplate::new(root_shape); let mut regexp_without_proto = ObjectTemplate::new(root_shape);
regexp_without_prototype.property(js_string!("lastIndex").into(), Attribute::WRITABLE); regexp_without_proto.property(js_string!("lastIndex").into(), Attribute::WRITABLE);
let mut regexp = regexp_without_prototype.clone(); let mut regexp = regexp_without_proto.clone();
regexp.set_prototype(constructors.regexp().prototype()); regexp.set_prototype(constructors.regexp().prototype());
let name_property_key: PropertyKey = js_string!("name").into(); let name_property_key: PropertyKey = js_string!("name").into();
@ -1472,7 +1471,6 @@ impl ObjectTemplates {
let mut namespace = ObjectTemplate::new(root_shape); let mut namespace = ObjectTemplate::new(root_shape);
namespace.property(JsSymbol::to_string_tag().into(), Attribute::empty()); namespace.property(JsSymbol::to_string_tag().into(), Attribute::empty());
#[cfg(feature = "experimental")]
let with_resolvers = { let with_resolvers = {
let mut with_resolvers = ordinary_object.clone(); let mut with_resolvers = ordinary_object.clone();
@ -1497,7 +1495,7 @@ impl ObjectTemplates {
bigint, bigint,
boolean, boolean,
regexp, regexp,
regexp_without_proto: regexp_without_prototype, regexp_without_proto,
unmapped_arguments, unmapped_arguments,
mapped_arguments, mapped_arguments,
function_with_prototype, function_with_prototype,
@ -1509,7 +1507,6 @@ impl ObjectTemplates {
function_without_proto, function_without_proto,
function_with_prototype_without_proto, function_with_prototype_without_proto,
namespace, namespace,
#[cfg(feature = "experimental")]
with_resolvers, with_resolvers,
} }
} }
@ -1738,7 +1735,6 @@ impl ObjectTemplates {
/// 1. `"promise"`: (`WRITABLE`, `ENUMERABLE`, `CONFIGURABLE`) /// 1. `"promise"`: (`WRITABLE`, `ENUMERABLE`, `CONFIGURABLE`)
/// 2. `"resolve"`: (`WRITABLE`, `ENUMERABLE`, `CONFIGURABLE`) /// 2. `"resolve"`: (`WRITABLE`, `ENUMERABLE`, `CONFIGURABLE`)
/// 3. `"reject"`: (`WRITABLE`, `ENUMERABLE`, `CONFIGURABLE`) /// 3. `"reject"`: (`WRITABLE`, `ENUMERABLE`, `CONFIGURABLE`)
#[cfg(feature = "experimental")]
pub(crate) const fn with_resolvers(&self) -> &ObjectTemplate { pub(crate) const fn with_resolvers(&self) -> &ObjectTemplate {
&self.with_resolvers &self.with_resolvers
} }

2
test262_config.toml

@ -1,4 +1,4 @@
commit = "6cbb6da9473c56d95358d8e679c5a6d2b4574efb" commit = "e4f91b6381d7694265031caad0c71d733ac132f3"
[ignored] [ignored]
# Not implemented yet: # Not implemented yet:

18
tests/tester/src/edition.rs

@ -41,10 +41,6 @@ static FEATURE_EDITION: phf::Map<&'static str, SpecEdition> = phf::phf_map! {
// https://github.com/tc39/proposal-json-modules // https://github.com/tc39/proposal-json-modules
"json-modules" => SpecEdition::ESNext, "json-modules" => SpecEdition::ESNext,
// Resizable Arraybuffer
// https://github.com/tc39/proposal-resizablearraybuffer
"resizable-arraybuffer" => SpecEdition::ESNext,
// ArrayBuffer transfer // ArrayBuffer transfer
// https://github.com/tc39/proposal-arraybuffer-transfer // https://github.com/tc39/proposal-arraybuffer-transfer
"arraybuffer-transfer" => SpecEdition::ESNext, "arraybuffer-transfer" => SpecEdition::ESNext,
@ -57,10 +53,6 @@ static FEATURE_EDITION: phf::Map<&'static str, SpecEdition> = phf::phf_map! {
// https://github.com/tc39/proposal-realms // https://github.com/tc39/proposal-realms
"ShadowRealm" => SpecEdition::ESNext, "ShadowRealm" => SpecEdition::ESNext,
// Array.prototype.group & Array.prototype.groupToMap
// https://github.com/tc39/proposal-array-grouping
"array-grouping" => SpecEdition::ESNext,
// Intl.DurationFormat // Intl.DurationFormat
// https://github.com/tc39/proposal-intl-duration-format // https://github.com/tc39/proposal-intl-duration-format
"Intl.DurationFormat" => SpecEdition::ESNext, "Intl.DurationFormat" => SpecEdition::ESNext,
@ -73,7 +65,8 @@ static FEATURE_EDITION: phf::Map<&'static str, SpecEdition> = phf::phf_map! {
// https://github.com/tc39/proposal-duplicate-named-capturing-groups // https://github.com/tc39/proposal-duplicate-named-capturing-groups
"regexp-duplicate-named-groups" => SpecEdition::ESNext, "regexp-duplicate-named-groups" => SpecEdition::ESNext,
// https://tc39.es/proposal-array-from-async/ // Array.fromAsync
// https://github.com/tc39/proposal-array-from-async
"Array.fromAsync" => SpecEdition::ESNext, "Array.fromAsync" => SpecEdition::ESNext,
// JSON.parse with source // JSON.parse with source
@ -84,10 +77,6 @@ static FEATURE_EDITION: phf::Map<&'static str, SpecEdition> = phf::phf_map! {
// https://github.com/tc39/proposal-iterator-helpers // https://github.com/tc39/proposal-iterator-helpers
"iterator-helpers" => SpecEdition::ESNext, "iterator-helpers" => SpecEdition::ESNext,
// Promise.withResolvers
// https://github.com/tc39/proposal-promise-with-resolvers
"promise-with-resolvers" => SpecEdition::ESNext,
// Set methods // Set methods
// https://github.com/tc39/proposal-set-methods // https://github.com/tc39/proposal-set-methods
"set-methods" => SpecEdition::ESNext, "set-methods" => SpecEdition::ESNext,
@ -97,6 +86,9 @@ static FEATURE_EDITION: phf::Map<&'static str, SpecEdition> = phf::phf_map! {
"regexp-v-flag" => SpecEdition::ESNext, "regexp-v-flag" => SpecEdition::ESNext,
"String.prototype.isWellFormed" => SpecEdition::ESNext, "String.prototype.isWellFormed" => SpecEdition::ESNext,
"String.prototype.toWellFormed" => SpecEdition::ESNext, "String.prototype.toWellFormed" => SpecEdition::ESNext,
"resizable-arraybuffer" => SpecEdition::ESNext,
"promise-with-resolvers" => SpecEdition::ESNext,
"array-grouping" => SpecEdition::ESNext,
// Standard language features // Standard language features
"AggregateError" => SpecEdition::ES12, "AggregateError" => SpecEdition::ES12,

Loading…
Cancel
Save