test262-runner: Make more use of Value::as_if

This commit is contained in:
Shannon Booth 2026-02-28 12:54:07 +01:00 committed by Tim Flynn
parent 2d6aba424d
commit 1811679ceb

View file

@ -80,22 +80,20 @@ static ErrorOr<void, TestError> run_program(InterpreterT& interpreter, ScriptOrM
auto error_value = result.throw_completion().value();
TestError error;
error.phase = NegativePhase::Runtime;
if (error_value.is_object()) {
auto& object = error_value.as_object();
auto name = object.get_without_side_effects("name"_utf16_fly_string);
if (auto object = error_value.template as_if<JS::Object>()) {
auto name = object->get_without_side_effects("name"_utf16_fly_string);
if (!name.is_undefined() && !name.is_accessor()) {
error.type = name.to_string_without_side_effects();
} else {
auto constructor = object.get_without_side_effects("constructor"_utf16_fly_string);
if (constructor.is_object()) {
name = constructor.as_object().get_without_side_effects("name"_utf16_fly_string);
auto constructor_value = object->get_without_side_effects("constructor"_utf16_fly_string);
if (auto constructor = constructor_value.template as_if<JS::Object>()) {
name = constructor->get_without_side_effects("name"_utf16_fly_string);
if (!name.is_undefined())
error.type = name.to_string_without_side_effects();
}
}
auto message = object.get_without_side_effects("message"_utf16_fly_string);
auto message = object->get_without_side_effects("message"_utf16_fly_string);
if (!message.is_undefined() && !message.is_accessor())
error.details = message.to_string_without_side_effects();
}