diff options
author | Linus Groh <mail@linusgroh.de> | 2021-10-12 17:49:01 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-13 09:55:10 +0100 |
commit | 4d8912a92b4378d34a06806b3126c8463bdbdcf5 (patch) | |
tree | 9d9ed3594c1512756d1c9337794a29a3d5965b5c /Tests | |
parent | 5d38cf497331ba9a533d2da64d91f7044b3ee87f (diff) | |
download | serenity-4d8912a92b4378d34a06806b3126c8463bdbdcf5.zip |
LibJS: Convert to_string() to ThrowCompletionOr
Also update get_function_name() to use ThrowCompletionOr, but this is
not a standard AO and should be refactored out of existence eventually.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/LibJS/test-js.cpp | 4 | ||||
-rw-r--r-- | Tests/LibWasm/test-wasm.cpp | 8 | ||||
-rw-r--r-- | Tests/LibWeb/test-web.cpp | 4 |
3 files changed, 4 insertions, 12 deletions
diff --git a/Tests/LibJS/test-js.cpp b/Tests/LibJS/test-js.cpp index 6909de1617..de7b53156f 100644 --- a/Tests/LibJS/test-js.cpp +++ b/Tests/LibJS/test-js.cpp @@ -18,9 +18,7 @@ TESTJS_GLOBAL_FUNCTION(is_strict_mode, isStrictMode, 0) TESTJS_GLOBAL_FUNCTION(can_parse_source, canParseSource) { - auto source = vm.argument(0).to_string(global_object); - if (vm.exception()) - return {}; + auto source = TRY_OR_DISCARD(vm.argument(0).to_string(global_object)); auto parser = JS::Parser(JS::Lexer(source)); parser.parse_program(); return JS::Value(!parser.has_errors()); diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp index 14ee45e604..8daf451312 100644 --- a/Tests/LibWasm/test-wasm.cpp +++ b/Tests/LibWasm/test-wasm.cpp @@ -13,9 +13,7 @@ TEST_ROOT("Userland/Libraries/LibWasm/Tests"); TESTJS_GLOBAL_FUNCTION(read_binary_wasm_file, readBinaryWasmFile) { - auto filename = vm.argument(0).to_string(global_object); - if (vm.exception()) - return {}; + auto filename = TRY_OR_DISCARD(vm.argument(0).to_string(global_object)); auto file = Core::File::open(filename, Core::OpenMode::ReadOnly); if (file.is_error()) { vm.throw_exception<JS::TypeError>(global_object, file.error().string()); @@ -169,9 +167,7 @@ void WebAssemblyModule::initialize(JS::GlobalObject& global_object) JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::get_export) { - auto name = vm.argument(0).to_string(global_object); - if (vm.exception()) - return {}; + auto name = TRY_OR_DISCARD(vm.argument(0).to_string(global_object)); auto this_value = vm.this_value(global_object); auto object = this_value.to_object(global_object); if (vm.exception()) diff --git a/Tests/LibWeb/test-web.cpp b/Tests/LibWeb/test-web.cpp index 531f009421..893adab262 100644 --- a/Tests/LibWeb/test-web.cpp +++ b/Tests/LibWeb/test-web.cpp @@ -40,9 +40,7 @@ TESTJS_MAIN_HOOK() TESTJS_GLOBAL_FUNCTION(load_local_page, loadLocalPage) { - auto name = vm.argument(0).to_string(global_object); - if (vm.exception()) - return {}; + auto name = TRY_OR_DISCARD(vm.argument(0).to_string(global_object)); // Clear the hooks before_initial_load_hooks.clear(); |