summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-08-21 14:00:56 +0100
committerLinus Groh <mail@linusgroh.de>2022-08-23 13:58:30 +0100
commita022e548b808df91c471cb55f0245e15957e89c4 (patch)
treed6a7d452eae1d06e537a2fd77348ecaab278614f /Tests
parentf6c4a0f5d00a6a03a5165f1618516acb320f13a4 (diff)
downloadserenity-a022e548b808df91c471cb55f0245e15957e89c4.zip
LibJS: Replace GlobalObject with VM in Value AOs [Part 4/19]
This is where the fun begins. :^)
Diffstat (limited to 'Tests')
-rw-r--r--Tests/LibJS/test-bytecode-js.cpp4
-rw-r--r--Tests/LibJS/test-js.cpp6
-rw-r--r--Tests/LibWasm/test-wasm.cpp18
3 files changed, 14 insertions, 14 deletions
diff --git a/Tests/LibJS/test-bytecode-js.cpp b/Tests/LibJS/test-bytecode-js.cpp
index 56a997565d..07f27b2808 100644
--- a/Tests/LibJS/test-bytecode-js.cpp
+++ b/Tests/LibJS/test-bytecode-js.cpp
@@ -27,7 +27,7 @@
auto result = bytecode_interpreter.run(*executable); \
EXPECT(!result.is_error()); \
if (result.is_error()) \
- dbgln("Error: {}", MUST(result.throw_completion().value()->to_string(bytecode_interpreter.global_object())));
+ dbgln("Error: {}", MUST(result.throw_completion().value()->to_string(vm)));
#define EXPECT_NO_EXCEPTION_WITH_OPTIMIZATIONS(executable) \
auto& passes = JS::Bytecode::Interpreter::optimization_pipeline(); \
@@ -37,7 +37,7 @@
\
EXPECT(!result_with_optimizations.is_error()); \
if (result_with_optimizations.is_error()) \
- dbgln("Error: {}", MUST(result_with_optimizations.throw_completion().value()->to_string(bytecode_interpreter.global_object())));
+ dbgln("Error: {}", MUST(result_with_optimizations.throw_completion().value()->to_string(vm)));
#define EXPECT_NO_EXCEPTION_ALL(source) \
SETUP_AND_PARSE("(() => {\n" source "\n})()") \
diff --git a/Tests/LibJS/test-js.cpp b/Tests/LibJS/test-js.cpp
index ae22bddaf8..0780590ae8 100644
--- a/Tests/LibJS/test-js.cpp
+++ b/Tests/LibJS/test-js.cpp
@@ -19,7 +19,7 @@ TESTJS_GLOBAL_FUNCTION(is_strict_mode, isStrictMode, 0)
TESTJS_GLOBAL_FUNCTION(can_parse_source, canParseSource)
{
- auto source = TRY(vm.argument(0).to_string(global_object));
+ auto source = TRY(vm.argument(0).to_string(vm));
auto parser = JS::Parser(JS::Lexer(source));
(void)parser.parse_program();
return JS::Value(!parser.has_errors());
@@ -33,7 +33,7 @@ TESTJS_GLOBAL_FUNCTION(run_queued_promise_jobs, runQueuedPromiseJobs)
TESTJS_GLOBAL_FUNCTION(get_weak_set_size, getWeakSetSize)
{
- auto* object = TRY(vm.argument(0).to_object(global_object));
+ auto* object = TRY(vm.argument(0).to_object(vm));
if (!is<JS::WeakSet>(object))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "WeakSet");
auto* weak_set = static_cast<JS::WeakSet*>(object);
@@ -42,7 +42,7 @@ TESTJS_GLOBAL_FUNCTION(get_weak_set_size, getWeakSetSize)
TESTJS_GLOBAL_FUNCTION(get_weak_map_size, getWeakMapSize)
{
- auto* object = TRY(vm.argument(0).to_object(global_object));
+ auto* object = TRY(vm.argument(0).to_object(vm));
if (!is<JS::WeakMap>(object))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "WeakMap");
auto* weak_map = static_cast<JS::WeakMap*>(object);
diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp
index c6cd5837d8..300d0f84f0 100644
--- a/Tests/LibWasm/test-wasm.cpp
+++ b/Tests/LibWasm/test-wasm.cpp
@@ -15,7 +15,7 @@ TEST_ROOT("Userland/Libraries/LibWasm/Tests");
TESTJS_GLOBAL_FUNCTION(read_binary_wasm_file, readBinaryWasmFile)
{
auto& realm = *global_object.associated_realm();
- auto filename = TRY(vm.argument(0).to_string(global_object));
+ auto filename = TRY(vm.argument(0).to_string(vm));
auto file = Core::Stream::File::open(filename, Core::Stream::OpenMode::Read);
if (file.is_error())
return vm.throw_completion<JS::TypeError>(strerror(file.error().code()));
@@ -101,7 +101,7 @@ HashMap<Wasm::Linker::Name, Wasm::ExternValue> WebAssemblyModule::s_spec_test_na
TESTJS_GLOBAL_FUNCTION(parse_webassembly_module, parseWebAssemblyModule)
{
auto& realm = *global_object.associated_realm();
- auto* object = TRY(vm.argument(0).to_object(global_object));
+ auto* object = TRY(vm.argument(0).to_object(vm));
if (!is<JS::Uint8Array>(object))
return vm.throw_completion<JS::TypeError>("Expected a Uint8Array argument to parse_webassembly_module");
auto& array = static_cast<JS::Uint8Array&>(*object);
@@ -139,11 +139,11 @@ TESTJS_GLOBAL_FUNCTION(parse_webassembly_module, parseWebAssemblyModule)
TESTJS_GLOBAL_FUNCTION(compare_typed_arrays, compareTypedArrays)
{
- auto* lhs = TRY(vm.argument(0).to_object(global_object));
+ auto* lhs = TRY(vm.argument(0).to_object(vm));
if (!is<JS::TypedArrayBase>(lhs))
return vm.throw_completion<JS::TypeError>("Expected a TypedArray");
auto& lhs_array = static_cast<JS::TypedArrayBase&>(*lhs);
- auto* rhs = TRY(vm.argument(1).to_object(global_object));
+ auto* rhs = TRY(vm.argument(1).to_object(vm));
if (!is<JS::TypedArrayBase>(rhs))
return vm.throw_completion<JS::TypeError>("Expected a TypedArray");
auto& rhs_array = static_cast<JS::TypedArrayBase&>(*rhs);
@@ -159,9 +159,9 @@ void WebAssemblyModule::initialize(JS::Realm& realm)
JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::get_export)
{
- auto name = TRY(vm.argument(0).to_string(global_object));
+ auto name = TRY(vm.argument(0).to_string(vm));
auto this_value = vm.this_value();
- auto* object = TRY(this_value.to_object(global_object));
+ auto* object = TRY(this_value.to_object(vm));
if (!is<WebAssemblyModule>(object))
return vm.throw_completion<JS::TypeError>("Not a WebAssemblyModule");
auto instance = static_cast<WebAssemblyModule*>(object);
@@ -189,7 +189,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::get_export)
JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::wasm_invoke)
{
- auto address = static_cast<unsigned long>(TRY(vm.argument(0).to_double(global_object)));
+ auto address = static_cast<unsigned long>(TRY(vm.argument(0).to_double(vm)));
Wasm::FunctionAddress function_address { address };
auto function_instance = WebAssemblyModule::machine().store().get(function_address);
if (!function_instance)
@@ -208,14 +208,14 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::wasm_invoke)
auto argument = vm.argument(index++);
double double_value = 0;
if (!argument.is_bigint())
- double_value = TRY(argument.to_double(global_object));
+ double_value = TRY(argument.to_double(vm));
switch (param.kind()) {
case Wasm::ValueType::Kind::I32:
arguments.append(Wasm::Value(param, static_cast<u64>(double_value)));
break;
case Wasm::ValueType::Kind::I64:
if (argument.is_bigint()) {
- auto value = TRY(argument.to_bigint_int64(global_object));
+ auto value = TRY(argument.to_bigint_int64(vm));
arguments.append(Wasm::Value(param, bit_cast<u64>(value)));
} else {
arguments.append(Wasm::Value(param, static_cast<u64>(double_value)));