summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibTest
AgeCommit message (Collapse)Author
2022-11-17LibTest: Fail if the top-level result of running a JS file is an errordavidot
Before putting `throw 1;` in a test file did not fail the file, and it ignored the rest of the file. Now we check the resulting completion from run and fail if that is an error.
2022-11-01Everywhere: Explicitly link all binaries against the LibC targetTim Schumacher
Even though the toolchain implicitly links against -lc, it does not know where it should get LibC from except for the sysroot. In the case of Clang this causes it to pick up the LibC stub instead, which might be slightly outdated and feature missing symbols. This is currently not an issue that manifests because we pass through the dependency on LibC and other libraries by accident, which causes CMake to link against the LibC target (instead of just the library), and thus points the linker at the build output directory. Since we are looking to fix that in the upcoming commits, let's make sure that everything will still be able to find the proper LibC first.
2022-10-24AK+Everywhere: Turn bool keep_empty to an enum in split* functionsdemostanis
2022-10-10Everywhere: Replace uses of __serenity__ with AK_OS_SERENITYAndrew Kaster
Now that we have OS macros for essentially every supported OS, let's try to use them everywhere.
2022-09-11LibTest: Extract some useful functions from TestRunner.hdavidot
This allows other test like programs to use these without needing to link to LibTest.
2022-09-06LibJS: Make Script and Module GC-allocatedAndreas Kling
This ensures that code currently in any active or saved execution stack always stays alive.
2022-08-28LibJS: Turn initialize_global_object() into a regular initialize()Linus Groh
There's nothing special about global object initialization anymore, this can just work the same way as for any other object now.
2022-08-23LibJS: Remove {Bytecode::,}Interpreter::global_object()Linus Groh
The basic idea is that a global object cannot just come out of nowhere, it must be associated to a realm - so get it from there, if needed. This is to enforce the changes from all the previous commits by not handing out global objects unless you actually have an initialized realm (either stored somewhere, or the VM's current realm).
2022-08-23LibJS+LibWeb: Reduce use of GlobalObject as an intermediaryLinus Groh
- Prefer VM::current_realm() over GlobalObject::associated_realm() - Prefer VM::heap() over GlobalObject::heap() - Prefer Cell::vm() over Cell::global_object() - Prefer Wrapper::vm() over Wrapper::global_object() - Inline Realm::global_object() calls used to access intrinsics as they will later perform a direct lookup without going through the global object
2022-08-23LibJS: Pass Realm to define_native_{accessor,function}()Linus Groh
This is needed so that the allocated NativeFunction receives the correct realm, usually forwarded from the Object's initialize() function, rather than using the current realm.
2022-08-23LibJS: Pass Realm to GlobalObject::initialize_global_object()Linus Groh
Global object initialization is tightly coupled to realm creation, so simply pass it to the function instead of relying on the non-standard 'associated realm' concept, which I'd like to remove later. This works essentially the same way as regular Object::initialize() now. Additionally this allows us to forward the realm to GlobalObject's add_constructor() / initialize_constructor() helpers, so they set the correct realm on the allocated constructor function object.
2022-08-23LibJS: Remove GlobalObject parameter from native functionsLinus Groh
2022-08-23LibJS: Replace GlobalObject with VM in JSON AOs [Part 13/19]Linus Groh
2022-08-23LibJS: Replace GlobalObject with VM in Value AOs [Part 4/19]Linus Groh
This is where the fun begins. :^)
2022-08-05LibJS: Let Shape store a Realm instead of a GlobalObjectAndreas Kling
This is a cautious first step towards being able to create JS objects before a global object has been instantiated.
2022-07-14LibCore: Replace the ArgsParser option argument setting with an enumTim Schumacher
Replacement conditions for `requires_argument` have been chosen based on what would be most convenient for implementing an eventual optional argument mode.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-20Everywhere: Move js/web/wasm tests under /home/anon/TestsBrian Gianforcaro
2022-03-18LibJS: Add infallible variant of VM::push_execution_context()Linus Groh
It makes no sense to require passing a global object and doing a stack space check in some cases where running out of stack is highly unlikely, we can't recover from errors, and currently ignore the result anyway. This is most commonly in constructors and when setting things up, rather than regular function calls.
2022-03-16LibTest: Provide detailed per-file JSON output with --per-fileAli Mohammad Pur
This makes test-js style runners dump out output in the same format as libjs-test262's per-file output.
2022-03-10LibTest: Port JavaScriptTestRunner to Core::StreamSam Atkins
2022-02-23LibTest+Spreadsheet: Add some basic spreadsheet runtime behaviour testsAli Mohammad Pur
As there's a somewhat active development going on, let's keep the expected behaviour under tests to make sure nothing blows up :^)
2022-02-13LibJS: Make ASTNode::generate_bytecode() fallibleAli Mohammad Pur
Instead of crashing on the spot, return a descriptive error that will eventually continue its days as a javascript "InternalError" exception. This should make random crashes with BC less likely.
2022-02-08LibWeb: Introduce the Environment Settings ObjectLuke Wilde
The environment settings object is effectively the context a piece of script is running under, for example, it contains the origin, responsible document, realm, global object and event loop for the current context. This effectively replaces ScriptExecutionContext, but it cannot be removed in this commit as EventTarget still depends on it. https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object
2022-02-08LibJS+Everywhere: Remove VM::exception() and most related functionsdavidot
This commit removes all exception related code: Remove VM::exception(), VM::throw_exception() etc. Any leftover throw_exception calls are moved to throw_completion. The one method left is clear_exception() which is now a no-op. Most of these calls are just to clear whatever exception might have been thrown when handling a Completion. So to have a cleaner commit this will be removed in a next commit. It also removes the actual Exception and TemporaryClearException classes since these are no longer used. In any spot where the exception was actually used an attempt was made to preserve that behavior. However since it is no longer tracked by the VM we cannot access exceptions which were thrown in previous calls. There are two such cases which might have different behavior: - In Web::DOM::Document::interpreter() the on_call_stack_emptied hook used to print any uncaught exception but this is now no longer possible as the VM does not store uncaught exceptions. - In js the code used to be interruptable by throwing an exception on the VM. This is no longer possible but was already somewhat fragile before as you could happen to throw an exception just before a VERIFY.
2022-02-05LibJS: Remove the JS_TRACK_ZOMBIE_CELLS optiondavidot
This feature had bitrotted somewhat and would trigger errors because PrimitiveStrings were "destroyed" but because of this mode they were not removed from the string cache. Even fixing that case running test-js with the options still failed in more places.
2022-01-31LibJS: Store ECMAScriptFunctionObject bytecode in an OwnPtrAndreas Kling
Using an Optional was extremely wasteful for function objects that don't even have a bytecode executable. This allows ECMAScriptFunctionObject to fit in a smaller size class.
2022-01-22LibJS: Implement ImportCall and HostImportModuleDynamicallydavidot
This allows us to load modules from scripts. This can be dangerous as it can load arbitrary files. Because of that it fails and throws by default. Currently, only js and JavaScriptTestRunner enable the default hook. This also adds tests to test-js which test module code. Because we form a spec perspective can't "enter" a module this is the easiest way to run tests without having to modify test-js to have special cases for modules. To specify modules in test-js we use the extension '.mjs' this is to ensure the files are not executed. We do still want to lint these files so the prettier scripts have changed to look for '.mjs' files as well.
2022-01-22LibJS: Refactor interpreter to use Script and Source Text ModulesLuke Wilde
This also refactors interpreter creation to follow InitializeHostDefinedRealm, but I couldn't fit it in the title :^) This allows us to follow the spec much more closely rather than being completely ad-hoc with just the parse node instead of having all the surrounding data such as the realm of the parse node. The interpreter creation refactor creates the global execution context once and doesn't take it off the stack. This allows LibWeb to take the global execution context and manually handle it, following the HTML spec. The HTML spec calls this the "realm execution context" of the environment settings object. It also allows us to specify the globalThis type, as it can be different from the global object type. For example, on the web, Window global objects use a WindowProxy global this value to enforce the same origin policy on operations like [[GetOwnProperty]]. Finally, it allows us to directly call Program::execute in perform_eval and perform_shadow_realm_eval as this moves global_declaration_instantiation into Interpreter::run (ScriptEvaluation) as per the spec. Note that this doesn't evalulate Source Text Modules yet or refactor the bytecode interpreter, that's work for future us :^) This patch was originally build by Luke for the environment settings object change but was also needed for modules. So I (davidot) have modified it with the new completion changes and setup for that. Co-authored-by: davidot <davidot@serenityos.org>
2022-01-08LibJS: Convert Interpreter::run() to ThrowCompletionOr<Value>Linus Groh
Instead of making it a void function, checking for an exception, and then receiving the relevant result via VM::last_value(), we can consolidate all of this by using completions. This allows us to remove more uses of VM::exception(), and all uses of VM::last_value().
2022-01-07LibTest: Use Array instead of fold expression in __testjs_last()Andrew Kaster
This avoids a -Wunused-value warning with clang-14.
2022-01-04LibTest: Remove uses of TRY_OR_DISCARD() from JavaScriptTestRunnerLinus Groh
In one case we can replace it with MUST() and accept the crash (we also VERIFY() that there wasn't an exception); in the other case we don't need to return after a throw completion.
2022-01-04LibTest: Convert JavaScriptTestRunner's get_test_results() to ErrorOrLinus Groh
2021-12-19LibTest: Add `EXPECT_NO_CRASH`Michel Hermier
2021-12-19LibTest: Add `EXPECT_CRASH_WITH_SIGNAL`Michel Hermier
2021-12-19LibTest: Handle test reporting in the a unique pathMichel Hermier
2021-12-19LibTest: Change `Crash` forked process communicationMichel Hermier
Now it returns `Failure` value via `exit`, and the caller is responsible of reporting errors to the user.
2021-12-19LibTest: Handle Crash printing in a private methodMichel Hermier
2021-11-17AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)Andreas Kling
Also add slightly richer parse errors now that we can include a string literal with returned errors. This will allow us to use TRY() when working with JSON data.
2021-11-12LibJS+LibTest+js: Convert BC::Interpreter::run to ThrowCompletionOr<>Ali Mohammad Pur
Note that this is just a shallow API change.
2021-11-01Everywhere: Remove unused ArgsParser headerBen Wiederhake
Found while trying to enumerate all programs that use ArgsParser.
2021-10-29LibJS: Convert JSONObject functions to ThrowCompletionOrIdan Horowitz
2021-10-24LibTest: Introduce a macro to only compare truthinessTim Schumacher
2021-10-24LibJS: Include executable name in bytecode dumpsAndreas Kling
2021-10-24LibJS: Move global "should dump bytecode" flag into LibJSAndreas Kling
This will allow us to trigger bytecode executable dumps when generating bytecode inside LibJS as well, not just in clients like js and test-js.
2021-10-24LibJS: Add Bytecode::Executable::dump()Andreas Kling
Let's have a helper for producing a consistent executable dump instead of repeating the logic in multiple places.
2021-10-20LibJS: Convert test-js/test-web/test-wasm to ThrowCompletionOrIdan Horowitz
2021-10-20LibJS: Rename define_native_function => define_old_native_functionIdan Horowitz
This method will eventually be removed once all native functions are converted to ThrowCompletionOr
2021-10-20LibJS: Add ThrowCompletionOr versions of the JS native function macrosIdan Horowitz
The old versions were renamed to JS_DECLARE_OLD_NATIVE_FUNCTION and JS_DEFINE_OLD_NATIVE_FUNCTION, and will be eventually removed once all native functions were converted to the new format.