1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:37:46 +00:00

LibTest+Spreadsheet: Add some basic spreadsheet runtime behaviour tests

As there's a somewhat active development going on, let's keep the
expected behaviour under tests to make sure nothing blows up :^)
This commit is contained in:
Ali Mohammad Pur 2022-02-22 07:49:04 +03:30 committed by Ali Mohammad Pur
parent 0fe97cdfe4
commit bed129a69f
13 changed files with 578 additions and 12 deletions

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2022, Ali Mohammad Pur <mpfard@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/Map.h>
#include <LibTest/JavaScriptTestRunner.h>
TEST_ROOT("Userland/Applications/Spreadsheet/Tests");
#ifdef __serenity__
static constexpr auto s_spreadsheet_runtime_path = "/res/js/Spreadsheet/runtime.js"sv;
#else
static constexpr auto s_spreadsheet_runtime_path = "../../../../Base/res/js/Spreadsheet/runtime.js"sv;
#endif
TESTJS_RUN_FILE_FUNCTION(String const&, JS::Interpreter& interpreter, JS::ExecutionContext& global_execution_context)
{
auto run_file = [&](StringView name) {
auto result = Test::JS::parse_script(name, interpreter.realm());
if (result.is_error()) {
warnln("Unable to parse {}", name);
warnln("{}", result.error().error.to_string());
warnln("{}", result.error().hint);
Test::cleanup_and_exit();
}
auto script = result.release_value();
interpreter.vm().push_execution_context(global_execution_context, interpreter.realm().global_object());
MUST(interpreter.run(*script));
interpreter.vm().pop_execution_context();
};
#ifdef __serenity__
run_file(s_spreadsheet_runtime_path);
#else
run_file(LexicalPath::join(Test::JS::g_test_root, s_spreadsheet_runtime_path).string());
#endif
run_file("mock.test-common.js");
return Test::JS::RunFileHookResult::RunAsNormal;
}