mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:27:43 +00:00
LibJS: Remove fallback value for get_offset_nanoseconds_for
This is a normative change in the Temporal spec.
See: 664f02d
Note that the tests are not comprehensive.
This commit is contained in:
parent
f1784c9c87
commit
3666d2132b
20 changed files with 140 additions and 15 deletions
|
@ -275,7 +275,6 @@ void GlobalObject::initialize_global_object()
|
|||
|
||||
m_array_prototype_values_function = &m_array_prototype->get_without_side_effects(vm.names.values).as_function();
|
||||
m_eval_function = &get_without_side_effects(vm.names.eval).as_function();
|
||||
m_temporal_time_zone_prototype_get_offset_nanoseconds_for_function = &m_temporal_time_zone_prototype->get_without_side_effects(vm.names.getOffsetNanosecondsFor).as_function();
|
||||
}
|
||||
|
||||
GlobalObject::~GlobalObject()
|
||||
|
@ -293,7 +292,6 @@ void GlobalObject::visit_edges(Visitor& visitor)
|
|||
visitor.visit(m_generator_object_prototype);
|
||||
visitor.visit(m_array_prototype_values_function);
|
||||
visitor.visit(m_eval_function);
|
||||
visitor.visit(m_temporal_time_zone_prototype_get_offset_nanoseconds_for_function);
|
||||
visitor.visit(m_throw_type_error_function);
|
||||
|
||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
|
||||
|
|
|
@ -39,7 +39,6 @@ public:
|
|||
|
||||
FunctionObject* array_prototype_values_function() const { return m_array_prototype_values_function; }
|
||||
FunctionObject* eval_function() const { return m_eval_function; }
|
||||
FunctionObject* temporal_time_zone_prototype_get_offset_nanoseconds_for_function() const { return m_temporal_time_zone_prototype_get_offset_nanoseconds_for_function; }
|
||||
FunctionObject* throw_type_error_function() const { return m_throw_type_error_function; }
|
||||
|
||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
|
||||
|
@ -105,7 +104,6 @@ private:
|
|||
|
||||
FunctionObject* m_array_prototype_values_function { nullptr };
|
||||
FunctionObject* m_eval_function { nullptr };
|
||||
FunctionObject* m_temporal_time_zone_prototype_get_offset_nanoseconds_for_function { nullptr };
|
||||
FunctionObject* m_throw_type_error_function { nullptr };
|
||||
|
||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
|
||||
|
|
|
@ -420,29 +420,25 @@ ThrowCompletionOr<double> get_offset_nanoseconds_for(GlobalObject& global_object
|
|||
// 1. Let getOffsetNanosecondsFor be ? GetMethod(timeZone, "getOffsetNanosecondsFor").
|
||||
auto* get_offset_nanoseconds_for = TRY(time_zone.get_method(global_object, vm.names.getOffsetNanosecondsFor));
|
||||
|
||||
// 2. If getOffsetNanosecondsFor is undefined, set getOffsetNanosecondsFor to %Temporal.TimeZone.prototype.getOffsetNanosecondsFor%.
|
||||
if (!get_offset_nanoseconds_for)
|
||||
get_offset_nanoseconds_for = global_object.temporal_time_zone_prototype_get_offset_nanoseconds_for_function();
|
||||
// 2. Let offsetNanoseconds be ? Call(getOffsetNanosecondsFor, timeZone, « instant »).
|
||||
auto offset_nanoseconds_value = TRY(call(global_object, get_offset_nanoseconds_for, time_zone, &instant));
|
||||
|
||||
// 3. Let offsetNanoseconds be ? Call(getOffsetNanosecondsFor, timeZone, « instant »).
|
||||
auto offset_nanoseconds_value = TRY(vm.call(*get_offset_nanoseconds_for, time_zone, &instant));
|
||||
|
||||
// 4. If Type(offsetNanoseconds) is not Number, throw a TypeError exception.
|
||||
// 3. If Type(offsetNanoseconds) is not Number, throw a TypeError exception.
|
||||
if (!offset_nanoseconds_value.is_number())
|
||||
return vm.throw_completion<TypeError>(global_object, ErrorType::IsNotA, "Offset nanoseconds value", "number");
|
||||
|
||||
// 5. If ! IsIntegralNumber(offsetNanoseconds) is false, throw a RangeError exception.
|
||||
// 4. If ! IsIntegralNumber(offsetNanoseconds) is false, throw a RangeError exception.
|
||||
if (!offset_nanoseconds_value.is_integral_number())
|
||||
return vm.throw_completion<RangeError>(global_object, ErrorType::IsNotAn, "Offset nanoseconds value", "integral number");
|
||||
|
||||
// 6. Set offsetNanoseconds to ℝ(offsetNanoseconds).
|
||||
// 5. Set offsetNanoseconds to ℝ(offsetNanoseconds).
|
||||
auto offset_nanoseconds = offset_nanoseconds_value.as_double();
|
||||
|
||||
// 7. If abs(offsetNanoseconds) > 86400 × 10^9, throw a RangeError exception.
|
||||
// 6. If abs(offsetNanoseconds) > 86400 × 10^9, throw a RangeError exception.
|
||||
if (fabs(offset_nanoseconds) > 86400000000000.0)
|
||||
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidOffsetNanosecondsValue);
|
||||
|
||||
// 8. Return offsetNanoseconds.
|
||||
// 7. Return offsetNanoseconds.
|
||||
return offset_nanoseconds;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue