test262-runner: Make more use of Value::as_if
This commit is contained in:
parent
2d6aba424d
commit
1811679ceb
1 changed files with 6 additions and 8 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue