MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / test_compiler

Function test_compiler

modules/gdscript/tests/test_gdscript.cpp:264–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262}
263
264static void test_compiler(const String &p_code, const String &p_script_path, const Vector<String> &p_lines) {
265 GDScriptParser parser;
266 Error err = parser.parse(p_code, p_script_path, false);
267
268 if (err != OK) {
269 print_line("Error in parser:");
270 const List<GDScriptParser::ParserError> &errors = parser.get_errors();
271 for (const GDScriptParser::ParserError &error : errors) {
272 print_line(vformat("%02d:%02d: %s", error.line, error.column, error.message));
273 }
274 return;
275 }
276
277 GDScriptAnalyzer analyzer(&parser);
278 err = analyzer.analyze();
279
280 if (err != OK) {
281 print_line("Error in analyzer:");
282 const List<GDScriptParser::ParserError> &errors = parser.get_errors();
283 for (const GDScriptParser::ParserError &error : errors) {
284 print_line(vformat("%02d:%02d: %s", error.line, error.column, error.message));
285 }
286 return;
287 }
288
289 GDScriptCompiler compiler;
290 Ref<GDScript> script;
291 script.instantiate();
292 script->set_path(p_script_path);
293
294 err = compiler.compile(&parser, script.ptr(), false);
295
296 if (err) {
297 print_line("Error in compiler:");
298 print_line(vformat("%02d:%02d: %s", compiler.get_error_line(), compiler.get_error_column(), compiler.get_error()));
299 return;
300 }
301
302 recursively_disassemble_functions(script, p_lines);
303}
304
305void test(TestType p_type) {
306 List<String> cmdlargs = OS::get_singleton()->get_cmdline_args();

Callers 1

testFunction · 0.70

Calls 12

print_lineFunction · 0.85
vformatFunction · 0.85
analyzeMethod · 0.80
get_error_columnMethod · 0.80
parseMethod · 0.45
instantiateMethod · 0.45
set_pathMethod · 0.45
compileMethod · 0.45
ptrMethod · 0.45
get_error_lineMethod · 0.45
get_errorMethod · 0.45

Tested by

no test coverage detected