mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
js: Add assertNotReached() function in test mode
This commit is contained in:
parent
94647fa4ab
commit
0040d6bf2d
Notes:
sideshowbarker
2024-07-19 07:38:00 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/0040d6bf2d5 Pull-request: https://github.com/SerenityOS/serenity/pull/1782
1 changed files with 9 additions and 0 deletions
|
@ -279,6 +279,7 @@ ReplObject::ReplObject()
|
|||
ReplObject::~ReplObject()
|
||||
{
|
||||
}
|
||||
|
||||
JS::Value ReplObject::save_to_file(JS::Interpreter& interpreter)
|
||||
{
|
||||
if (!interpreter.argument_count())
|
||||
|
@ -290,6 +291,7 @@ JS::Value ReplObject::save_to_file(JS::Interpreter& interpreter)
|
|||
}
|
||||
return JS::Value(false);
|
||||
}
|
||||
|
||||
JS::Value ReplObject::exit_interpreter(JS::Interpreter& interpreter)
|
||||
{
|
||||
if (!interpreter.argument_count())
|
||||
|
@ -298,6 +300,7 @@ JS::Value ReplObject::exit_interpreter(JS::Interpreter& interpreter)
|
|||
exit(exit_code);
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
JS::Value ReplObject::repl_help(JS::Interpreter& interpreter)
|
||||
{
|
||||
StringBuilder help_text;
|
||||
|
@ -383,10 +386,16 @@ JS::Value assert_impl(JS::Interpreter& interpreter)
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue