diff --git a/boa_engine/src/builtins/error/aggregate.rs b/boa_engine/src/builtins/error/aggregate.rs index 6a7e212fe8..8bbf117384 100644 --- a/boa_engine/src/builtins/error/aggregate.rs +++ b/boa_engine/src/builtins/error/aggregate.rs @@ -56,7 +56,7 @@ impl BuiltIn for AggregateError { impl AggregateError { /// The amount of arguments this function object takes. - pub(crate) const LENGTH: usize = 1; + pub(crate) const LENGTH: usize = 2; /// Create a new aggregate error object. pub(crate) fn constructor( diff --git a/boa_engine/src/builtins/number/mod.rs b/boa_engine/src/builtins/number/mod.rs index 1c84fc27e9..2529452f3b 100644 --- a/boa_engine/src/builtins/number/mod.rs +++ b/boa_engine/src/builtins/number/mod.rs @@ -17,7 +17,8 @@ use crate::{ builtins::{string::is_trimmable_whitespace, BuiltIn, JsArgs}, context::StandardObjects, object::{ - internal_methods::get_prototype_from_constructor, ConstructorBuilder, JsObject, ObjectData, + internal_methods::get_prototype_from_constructor, ConstructorBuilder, FunctionBuilder, + JsObject, ObjectData, }, property::Attribute, value::{AbstractRelation, IntegerOrInfinity, JsValue}, @@ -49,6 +50,18 @@ impl BuiltIn for Number { fn init(context: &mut Context) -> JsValue { let _timer = Profiler::global().start_event(Self::NAME, "init"); + let parse_int = FunctionBuilder::native(context, Self::parse_int) + .name("parseInt") + .length(2) + .constructor(false) + .build(); + + let parse_float = FunctionBuilder::native(context, Self::parse_float) + .name("parseFloat") + .length(1) + .constructor(false) + .build(); + let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT; let number_object = ConstructorBuilder::with_standard_object( context, @@ -65,20 +78,39 @@ impl BuiltIn for Number { .static_property("NEGATIVE_INFINITY", f64::NEG_INFINITY, attribute) .static_property("POSITIVE_INFINITY", f64::INFINITY, attribute) .static_property("NaN", f64::NAN, attribute) + .static_property( + "parseInt", + parse_int.clone(), + Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, + ) + .static_property( + "parseFloat", + parse_float.clone(), + Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, + ) + .static_method(Self::number_is_finite, "isFinite", 1) + .static_method(Self::number_is_nan, "isNaN", 1) + .static_method(Self::is_safe_integer, "isSafeInteger", 1) + .static_method(Self::number_is_integer, "isInteger", 1) .method(Self::to_exponential, "toExponential", 1) .method(Self::to_fixed, "toFixed", 1) .method(Self::to_locale_string, "toLocaleString", 0) .method(Self::to_precision, "toPrecision", 1) .method(Self::to_string, "toString", 1) .method(Self::value_of, "valueOf", 0) - .static_method(Self::number_is_finite, "isFinite", 1) - .static_method(Self::number_is_nan, "isNaN", 1) - .static_method(Self::is_safe_integer, "isSafeInteger", 1) - .static_method(Self::number_is_integer, "isInteger", 1) .build(); - context.register_global_builtin_function("parseInt", 2, Self::parse_int); - context.register_global_builtin_function("parseFloat", 1, Self::parse_float); + context.register_global_property( + "parseInt", + parse_int, + Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, + ); + context.register_global_property( + "parseFloat", + parse_float, + Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, + ); + context.register_global_builtin_function("isFinite", 1, Self::global_is_finite); context.register_global_builtin_function("isNaN", 1, Self::global_is_nan); diff --git a/boa_engine/src/builtins/reflect/mod.rs b/boa_engine/src/builtins/reflect/mod.rs index 87cd25d043..95d5c7d657 100644 --- a/boa_engine/src/builtins/reflect/mod.rs +++ b/boa_engine/src/builtins/reflect/mod.rs @@ -56,7 +56,7 @@ impl BuiltIn for Reflect { .function(Self::own_keys, "ownKeys", 1) .function(Self::prevent_extensions, "preventExtensions", 1) .function(Self::set, "set", 3) - .function(Self::set_prototype_of, "setPrototypeOf", 3) + .function(Self::set_prototype_of, "setPrototypeOf", 2) .property( to_string_tag, Self::NAME,