diff options
author | Brian Gianforcaro <b.gianfo@gmail.com> | 2020-04-13 10:31:13 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-14 12:55:31 +0200 |
commit | d74ad81402c27113b2ed5586bc369703d6be61c4 (patch) | |
tree | 43aaf62b9467d55f7ad3002d049c7f050930475a /Userland | |
parent | 9477efe97032f15438b51bf01e2958cc76c554be (diff) | |
download | serenity-d74ad81402c27113b2ed5586bc369703d6be61c4.zip |
js/LibJS: Move test functions to pure javascript.
The addition of assert functions to Userland/js
was done before we had load(..) implemented. Now
that it exists, it seems like the right move the
test helper functions to pure javascript instead
of poluting js with random global functions.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/js.cpp | 19 |
1 files changed, 0 insertions, 19 deletions
diff --git a/Userland/js.cpp b/Userland/js.cpp index a31b932792..bb09165b17 100644 --- a/Userland/js.cpp +++ b/Userland/js.cpp @@ -372,28 +372,9 @@ void repl(JS::Interpreter& interpreter) } } -JS::Value assert_impl(JS::Interpreter& interpreter) -{ - if (!interpreter.argument_count()) - return interpreter.throw_exception<JS::TypeError>("No arguments specified"); - - auto assertion_value = interpreter.argument(0).to_boolean(); - if (!assertion_value) - return interpreter.throw_exception<JS::Error>("AssertionError", "The assertion failed!"); - - return JS::Value(assertion_value); -} - -JS::Value assert_not_reached(JS::Interpreter& interpreter) -{ - return interpreter.throw_exception<JS::Error>("AssertionError", "assertNotReached() was reached!"); -} - void enable_test_mode(JS::Interpreter& interpreter) { interpreter.global_object().put_native_function("load", ReplObject::load_file); - interpreter.global_object().put_native_function("assert", assert_impl); - interpreter.global_object().put_native_function("assertNotReached", assert_not_reached); } int main(int argc, char** argv) |