mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:27:45 +00:00
Everywhere: Add sv suffix to strings relying on StringView(char const*)
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.
This commit is contained in:
parent
e5f09ea170
commit
3f3f45580a
762 changed files with 8315 additions and 8316 deletions
|
@ -11,15 +11,15 @@
|
|||
#include <LibJS/Script.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#define SETUP_AND_PARSE(source) \
|
||||
auto vm = JS::VM::create(); \
|
||||
auto ast_interpreter = JS::Interpreter::create<JS::GlobalObject>(*vm); \
|
||||
\
|
||||
auto script_or_error = JS::Script::parse(source, ast_interpreter->realm()); \
|
||||
EXPECT(!script_or_error.is_error()); \
|
||||
\
|
||||
auto script = script_or_error.release_value(); \
|
||||
auto const& program = script->parse_node(); \
|
||||
#define SETUP_AND_PARSE(source) \
|
||||
auto vm = JS::VM::create(); \
|
||||
auto ast_interpreter = JS::Interpreter::create<JS::GlobalObject>(*vm); \
|
||||
\
|
||||
auto script_or_error = JS::Script::parse(source##sv, ast_interpreter->realm()); \
|
||||
EXPECT(!script_or_error.is_error()); \
|
||||
\
|
||||
auto script = script_or_error.release_value(); \
|
||||
auto const& program = script->parse_node(); \
|
||||
JS::Bytecode::Interpreter bytecode_interpreter(ast_interpreter->global_object(), ast_interpreter->realm());
|
||||
|
||||
#define EXPECT_NO_EXCEPTION(executable) \
|
||||
|
@ -110,7 +110,7 @@ TEST_CASE(loading_multiple_files)
|
|||
}
|
||||
|
||||
{
|
||||
auto test_file_script_or_error = JS::Script::parse("if (f() !== 'hello') throw new Exception('failed'); ", ast_interpreter->realm());
|
||||
auto test_file_script_or_error = JS::Script::parse("if (f() !== 'hello') throw new Exception('failed'); "sv, ast_interpreter->realm());
|
||||
EXPECT(!test_file_script_or_error.is_error());
|
||||
|
||||
auto test_file_script = test_file_script_or_error.release_value();
|
||||
|
|
|
@ -37,7 +37,7 @@ static bool triggers_immediate_unicode_fault(StringView code)
|
|||
|
||||
TEST_CASE(no_input_only_gives_eof)
|
||||
{
|
||||
char const* code = "";
|
||||
auto code = ""sv;
|
||||
auto lexer = JS::Lexer(code);
|
||||
EXPECT(produces_eof_tokens(lexer));
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ TEST_CASE(long_invalid_unicode_and_valid_code)
|
|||
|
||||
TEST_CASE(invalid_unicode_after_valid_code_and_before_eof)
|
||||
{
|
||||
char const* code = "let \xEA\xFD;";
|
||||
auto code = "let \xEA\xFD;"sv;
|
||||
auto lexer = JS::Lexer(code);
|
||||
auto let_token = lexer.next();
|
||||
EXPECT_EQ(let_token.type(), JS::TokenType::Let);
|
||||
|
|
|
@ -104,18 +104,18 @@ TESTJS_RUN_FILE_FUNCTION(String const& test_file, JS::Interpreter& interpreter,
|
|||
ExplicitPass,
|
||||
} expectation { Pass };
|
||||
|
||||
if (dirname.ends_with("early"))
|
||||
if (dirname.ends_with("early"sv))
|
||||
expectation = Early;
|
||||
else if (dirname.ends_with("fail"))
|
||||
else if (dirname.ends_with("fail"sv))
|
||||
expectation = Fail;
|
||||
else if (dirname.ends_with("pass-explicit"))
|
||||
else if (dirname.ends_with("pass-explicit"sv))
|
||||
expectation = ExplicitPass;
|
||||
else if (dirname.ends_with("pass"))
|
||||
else if (dirname.ends_with("pass"sv))
|
||||
expectation = Pass;
|
||||
else
|
||||
return Test::JS::RunFileHookResult::SkipFile;
|
||||
|
||||
auto program_type = path.basename().ends_with(".module.js") ? JS::Program::Type::Module : JS::Program::Type::Script;
|
||||
auto program_type = path.basename().ends_with(".module.js"sv) ? JS::Program::Type::Module : JS::Program::Type::Script;
|
||||
bool parse_succeeded = false;
|
||||
if (program_type == JS::Program::Type::Module)
|
||||
parse_succeeded = !Test::JS::parse_module(test_file, interpreter.realm()).is_error();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue