diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 13:23:58 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 16:54:55 +0200 |
commit | 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (patch) | |
tree | a27e497da7104dd0a64f98a04fa3067668735e91 /main/tests | |
parent | 710b34b70227becdc652b4ae027fe0ac47409642 (diff) |
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to
will now be changed automatically to remove the first empty line.
This makes us lean closer to 1TBS (the one true brace style) instead
of hybridating it with some Allman-inspired spacing.
There's still the case of braces around single-statement blocks that
needs to be addressed (but clang-format can't help with that, but
clang-tidy may if we agree about it).
Part of #33027.
Diffstat (limited to 'main/tests')
-rw-r--r-- | main/tests/test_gdscript.cpp | 94 | ||||
-rw-r--r-- | main/tests/test_gui.cpp | 4 | ||||
-rw-r--r-- | main/tests/test_main.cpp | 18 | ||||
-rw-r--r-- | main/tests/test_math.cpp | 26 | ||||
-rw-r--r-- | main/tests/test_oa_hash_map.cpp | 2 | ||||
-rw-r--r-- | main/tests/test_ordered_hash_map.cpp | 1 | ||||
-rw-r--r-- | main/tests/test_physics_2d.cpp | 31 | ||||
-rw-r--r-- | main/tests/test_physics_3d.cpp | 27 | ||||
-rw-r--r-- | main/tests/test_render.cpp | 8 | ||||
-rw-r--r-- | main/tests/test_shader_lang.cpp | 24 | ||||
-rw-r--r-- | main/tests/test_string.cpp | 32 |
11 files changed, 0 insertions, 267 deletions
diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp index 971460c655..d95be7b218 100644 --- a/main/tests/test_gdscript.cpp +++ b/main/tests/test_gdscript.cpp @@ -45,7 +45,6 @@ namespace TestGDScript { static void _print_indent(int p_ident, const String &p_text) { - String txt; for (int i = 0; i < p_ident; i++) { txt += '\t'; @@ -55,7 +54,6 @@ static void _print_indent(int p_ident, const String &p_text) { } static String _parser_extends(const GDScriptParser::ClassNode *p_class) { - String txt = "extends "; if (String(p_class->extends_file) != "") { txt += "\"" + p_class->extends_file + "\""; @@ -64,7 +62,6 @@ static String _parser_extends(const GDScriptParser::ClassNode *p_class) { } for (int i = 0; i < p_class->extends_class.size(); i++) { - if (i != 0) txt += "."; @@ -75,12 +72,9 @@ static String _parser_extends(const GDScriptParser::ClassNode *p_class) { } static String _parser_expr(const GDScriptParser::Node *p_expr) { - String txt; switch (p_expr->type) { - case GDScriptParser::Node::TYPE_IDENTIFIER: { - const GDScriptParser::IdentifierNode *id_node = static_cast<const GDScriptParser::IdentifierNode *>(p_expr); txt = id_node->name; } break; @@ -99,7 +93,6 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) { const GDScriptParser::ArrayNode *arr_node = static_cast<const GDScriptParser::ArrayNode *>(p_expr); txt += "["; for (int i = 0; i < arr_node->elements.size(); i++) { - if (i > 0) txt += ", "; txt += _parser_expr(arr_node->elements[i]); @@ -110,7 +103,6 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) { const GDScriptParser::DictionaryNode *dict_node = static_cast<const GDScriptParser::DictionaryNode *>(p_expr); txt += "{"; for (int i = 0; i < dict_node->elements.size(); i++) { - if (i > 0) txt += ", "; @@ -122,31 +114,25 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) { txt += "}"; } break; case GDScriptParser::Node::TYPE_OPERATOR: { - const GDScriptParser::OperatorNode *c_node = static_cast<const GDScriptParser::OperatorNode *>(p_expr); switch (c_node->op) { - case GDScriptParser::OperatorNode::OP_PARENT_CALL: txt += "."; [[fallthrough]]; case GDScriptParser::OperatorNode::OP_CALL: { - ERR_FAIL_COND_V(c_node->arguments.size() < 1, ""); String func_name; const GDScriptParser::Node *nfunc = c_node->arguments[0]; int arg_ofs = 0; if (nfunc->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) { - const GDScriptParser::BuiltInFunctionNode *bif_node = static_cast<const GDScriptParser::BuiltInFunctionNode *>(nfunc); func_name = GDScriptFunctions::get_func_name(bif_node->function); arg_ofs = 1; } else if (nfunc->type == GDScriptParser::Node::TYPE_TYPE) { - const GDScriptParser::TypeNode *t_node = static_cast<const GDScriptParser::TypeNode *>(nfunc); func_name = Variant::get_type_name(t_node->vtype); arg_ofs = 1; } else { - ERR_FAIL_COND_V(c_node->arguments.size() < 2, ""); nfunc = c_node->arguments[1]; ERR_FAIL_COND_V(nfunc->type != GDScriptParser::Node::TYPE_IDENTIFIER, ""); @@ -161,7 +147,6 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) { txt += func_name + "("; for (int i = arg_ofs; i < c_node->arguments.size(); i++) { - const GDScriptParser::Node *arg = c_node->arguments[i]; if (i > arg_ofs) txt += ", "; @@ -172,7 +157,6 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) { } break; case GDScriptParser::OperatorNode::OP_INDEX: { - ERR_FAIL_COND_V(c_node->arguments.size() != 2, ""); //index with [] @@ -180,7 +164,6 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) { } break; case GDScriptParser::OperatorNode::OP_INDEX_NAMED: { - ERR_FAIL_COND_V(c_node->arguments.size() != 2, ""); txt = _parser_expr(c_node->arguments[0]) + "." + _parser_expr(c_node->arguments[1]); @@ -296,11 +279,9 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) { } break; case GDScriptParser::Node::TYPE_NEWLINE: { - //skippie } break; default: { - ERR_FAIL_V_MSG("", "Parser bug at " + itos(p_expr->line) + ", invalid expression type: " + itos(p_expr->type)); } } @@ -309,20 +290,14 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) { } static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_indent) { - for (int i = 0; i < p_block->statements.size(); i++) { - const GDScriptParser::Node *statement = p_block->statements[i]; switch (statement->type) { - case GDScriptParser::Node::TYPE_CONTROL_FLOW: { - const GDScriptParser::ControlFlowNode *cf_node = static_cast<const GDScriptParser::ControlFlowNode *>(statement); switch (cf_node->cf_type) { - case GDScriptParser::ControlFlowNode::CF_IF: { - ERR_FAIL_COND(cf_node->arguments.size() != 1); String txt; txt += "if "; @@ -351,7 +326,6 @@ static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_i } break; case GDScriptParser::ControlFlowNode::CF_WHILE: { - ERR_FAIL_COND(cf_node->arguments.size() != 1); String txt; txt += "while "; @@ -366,15 +340,12 @@ static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_i // FIXME: Implement } break; case GDScriptParser::ControlFlowNode::CF_CONTINUE: { - _print_indent(p_indent, "continue"); } break; case GDScriptParser::ControlFlowNode::CF_BREAK: { - _print_indent(p_indent, "break"); } break; case GDScriptParser::ControlFlowNode::CF_RETURN: { - if (cf_node->arguments.size()) _print_indent(p_indent, "return " + _parser_expr(cf_node->arguments[0])); else @@ -384,7 +355,6 @@ static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_i } break; case GDScriptParser::Node::TYPE_LOCAL_VAR: { - const GDScriptParser::LocalVarNode *lv_node = static_cast<const GDScriptParser::LocalVarNode *>(statement); _print_indent(p_indent, "var " + String(lv_node->name)); } break; @@ -397,7 +367,6 @@ static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_i } static void _parser_show_function(const GDScriptParser::FunctionNode *p_func, int p_indent, GDScriptParser::BlockNode *p_initializer = nullptr) { - String txt; if (p_func->_static) txt = "static "; @@ -409,7 +378,6 @@ static void _parser_show_function(const GDScriptParser::FunctionNode *p_func, in txt += "("; for (int i = 0; i < p_func->arguments.size(); i++) { - if (i != 0) txt += ", "; txt += "var " + String(p_func->arguments[i]); @@ -433,15 +401,12 @@ static void _parser_show_function(const GDScriptParser::FunctionNode *p_func, in } static void _parser_show_class(const GDScriptParser::ClassNode *p_class, int p_indent, const Vector<String> &p_code) { - if (p_indent == 0 && (String(p_class->extends_file) != "" || p_class->extends_class.size())) { - _print_indent(p_indent, _parser_extends(p_class)); print_line("\n"); } for (int i = 0; i < p_class->subclasses.size(); i++) { - const GDScriptParser::ClassNode *subclass = p_class->subclasses[i]; String line = "class " + subclass->name; if (String(subclass->extends_file) != "" || subclass->extends_class.size()) @@ -458,7 +423,6 @@ static void _parser_show_class(const GDScriptParser::ClassNode *p_class, int p_i } for (int i = 0; i < p_class->variables.size(); i++) { - const GDScriptParser::ClassNode::Member &m = p_class->variables[i]; _print_indent(p_indent, "var " + String(m.identifier)); @@ -467,13 +431,11 @@ static void _parser_show_class(const GDScriptParser::ClassNode *p_class, int p_i print_line("\n"); for (int i = 0; i < p_class->static_functions.size(); i++) { - _parser_show_function(p_class->static_functions[i], p_indent); print_line("\n"); } for (int i = 0; i < p_class->functions.size(); i++) { - if (String(p_class->functions[i]->name) == "_init") { _parser_show_function(p_class->functions[i], p_indent, p_class->initializer); } else @@ -485,11 +447,9 @@ static void _parser_show_class(const GDScriptParser::ClassNode *p_class, int p_i } static String _disassemble_addr(const Ref<GDScript> &p_script, const GDScriptFunction &func, int p_addr) { - int addr = p_addr & GDScriptFunction::ADDR_MASK; switch (p_addr >> GDScriptFunction::ADDR_BITS) { - case GDScriptFunction::ADDR_TYPE_SELF: { return "self"; } break; @@ -497,15 +457,12 @@ static String _disassemble_addr(const Ref<GDScript> &p_script, const GDScriptFun return "class"; } break; case GDScriptFunction::ADDR_TYPE_MEMBER: { - return "member(" + p_script->debug_get_member_by_index(addr) + ")"; } break; case GDScriptFunction::ADDR_TYPE_CLASS_CONSTANT: { - return "class_const(" + func.get_global_name(addr) + ")"; } break; case GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT: { - Variant v = func.get_constant(addr); String txt; if (v.get_type() == Variant::STRING || v.get_type() == Variant::NODE_PATH) @@ -515,15 +472,12 @@ static String _disassemble_addr(const Ref<GDScript> &p_script, const GDScriptFun return "const(" + txt + ")"; } break; case GDScriptFunction::ADDR_TYPE_STACK: { - return "stack(" + itos(addr) + ")"; } break; case GDScriptFunction::ADDR_TYPE_STACK_VARIABLE: { - return "var_stack(" + itos(addr) + ")"; } break; case GDScriptFunction::ADDR_TYPE_GLOBAL: { - return "global(" + func.get_global_name(addr) + ")"; } break; case GDScriptFunction::ADDR_TYPE_NIL: { @@ -535,11 +489,9 @@ static String _disassemble_addr(const Ref<GDScript> &p_script, const GDScriptFun } static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String> &p_code) { - const Map<StringName, GDScriptFunction *> &mf = p_class->debug_get_member_functions(); for (const Map<StringName, GDScriptFunction *>::Element *E = mf.front(); E; E = E->next()) { - const GDScriptFunction &func = *E->get(); const int *code = func.get_code(); int codelen = func.get_code_size(); @@ -547,7 +499,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String if (func.get_default_argument_count()) { defargs = "defarg at: "; for (int i = 0; i < func.get_default_argument_count(); i++) { - if (i > 0) defargs += ","; defargs += itos(func.get_default_argument_addr(i)); @@ -559,14 +510,11 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String #define DADDR(m_ip) (_disassemble_addr(p_class, func, code[ip + m_ip])) for (int ip = 0; ip < codelen;) { - int incr = 0; String txt = itos(ip) + " "; switch (code[ip]) { - case GDScriptFunction::OPCODE_OPERATOR: { - int op = code[ip + 1]; txt += " op "; @@ -581,7 +529,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_SET: { - txt += "set "; txt += DADDR(1); txt += "["; @@ -592,7 +539,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_GET: { - txt += " get "; txt += DADDR(3); txt += "="; @@ -604,7 +550,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_SET_NAMED: { - txt += " set_named "; txt += DADDR(1); txt += "[\""; @@ -615,7 +560,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_GET_NAMED: { - txt += " get_named "; txt += DADDR(3); txt += "="; @@ -627,7 +571,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_SET_MEMBER: { - txt += " set_member "; txt += "[\""; txt += func.get_global_name(code[ip + 1]); @@ -637,7 +580,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_GET_MEMBER: { - txt += " get_member "; txt += DADDR(2); txt += "="; @@ -648,7 +590,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_ASSIGN: { - txt += " assign "; txt += DADDR(1); txt += "="; @@ -657,7 +598,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_ASSIGN_TRUE: { - txt += " assign "; txt += DADDR(1); txt += "= true"; @@ -665,7 +605,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_ASSIGN_FALSE: { - txt += " assign "; txt += DADDR(1); txt += "= false"; @@ -673,7 +612,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_ASSIGN_TYPED_BUILTIN: { - txt += " assign typed builtin ("; txt += Variant::get_type_name((Variant::Type)code[ip + 1]); txt += ") "; @@ -697,7 +635,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_CAST_TO_SCRIPT: { - txt += " cast "; txt += DADDR(3); txt += "="; @@ -708,7 +645,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_CONSTRUCT: { - Variant::Type t = Variant::Type(code[ip + 1]); int argc = code[ip + 2]; @@ -718,7 +654,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String txt += Variant::get_type_name(t) + "("; for (int i = 0; i < argc; i++) { - if (i > 0) txt += ", "; txt += DADDR(i + 3); @@ -729,7 +664,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_CONSTRUCT_ARRAY: { - int argc = code[ip + 1]; txt += " make_array "; txt += DADDR(2 + argc); @@ -747,7 +681,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_CONSTRUCT_DICTIONARY: { - int argc = code[ip + 1]; txt += " make_dict "; txt += DADDR(2 + argc * 2); @@ -769,7 +702,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String case GDScriptFunction::OPCODE_CALL: case GDScriptFunction::OPCODE_CALL_RETURN: { - bool ret = code[ip] == GDScriptFunction::OPCODE_CALL_RETURN; if (ret) @@ -797,7 +729,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_CALL_BUILT_IN: { - txt += " call-built-in "; int argc = code[ip + 2]; @@ -817,7 +748,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_CALL_SELF_BASE: { - txt += " call-self-base "; int argc = code[ip + 2]; @@ -837,13 +767,11 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_YIELD: { - txt += " yield "; incr = 1; } break; case GDScriptFunction::OPCODE_YIELD_SIGNAL: { - txt += " yield_signal "; txt += DADDR(1); txt += ","; @@ -851,13 +779,11 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 3; } break; case GDScriptFunction::OPCODE_YIELD_RESUME: { - txt += " yield resume: "; txt += DADDR(1); incr = 2; } break; case GDScriptFunction::OPCODE_JUMP: { - txt += " jump "; txt += itos(code[ip + 1]); @@ -865,7 +791,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_JUMP_IF: { - txt += " jump-if "; txt += DADDR(1); txt += " to "; @@ -874,7 +799,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 3; } break; case GDScriptFunction::OPCODE_JUMP_IF_NOT: { - txt += " jump-if-not "; txt += DADDR(1); txt += " to "; @@ -883,12 +807,10 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 3; } break; case GDScriptFunction::OPCODE_JUMP_TO_DEF_ARGUMENT: { - txt += " jump-to-default-argument "; incr = 1; } break; case GDScriptFunction::OPCODE_RETURN: { - txt += " return "; txt += DADDR(1); @@ -896,19 +818,16 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; case GDScriptFunction::OPCODE_ITERATE_BEGIN: { - txt += " for-init " + DADDR(4) + " in " + DADDR(2) + " counter " + DADDR(1) + " end " + itos(code[ip + 3]); incr += 5; } break; case GDScriptFunction::OPCODE_ITERATE: { - txt += " for-loop " + DADDR(4) + " in " + DADDR(2) + " counter " + DADDR(1) + " end " + itos(code[ip + 3]); incr += 5; } break; case GDScriptFunction::OPCODE_LINE: { - int line = code[ip + 1] - 1; if (line >= 0 && line < p_code.size()) txt = "\n" + itos(line + 1) + ": " + p_code[line] + "\n"; @@ -917,12 +836,10 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 2; } break; case GDScriptFunction::OPCODE_END: { - txt += " end"; incr += 1; } break; case GDScriptFunction::OPCODE_ASSERT: { - txt += " assert "; txt += DADDR(1); incr += 2; @@ -931,7 +848,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } if (incr == 0) { - ERR_BREAK_MSG(true, "Unhandled opcode: " + itos(code[ip])); } @@ -943,7 +859,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } MainLoop *test(TestType p_type) { - List<String> cmdlargs = OS::get_singleton()->get_cmdline_args(); if (cmdlargs.empty()) { @@ -972,21 +887,17 @@ MainLoop *test(TestType p_type) { int last = 0; for (int i = 0; i <= code.length(); i++) { - if (code[i] == '\n' || code[i] == 0) { - lines.push_back(code.substr(last, i - last)); last = i + 1; } } if (p_type == TEST_TOKENIZER) { - GDScriptTokenizerText tk; tk.set_code(code); int line = -1; while (tk.get_token() != GDScriptTokenizer::TK_EOF) { - String text; if (tk.get_token() == GDScriptTokenizer::TK_IDENTIFIER) text = "'" + tk.get_token_identifier() + "' (identifier)"; @@ -1024,7 +935,6 @@ MainLoop *test(TestType p_type) { } if (p_type == TEST_PARSER) { - GDScriptParser parser; Error err = parser.parse(code); if (err) { @@ -1041,7 +951,6 @@ MainLoop *test(TestType p_type) { } if (p_type == TEST_COMPILER) { - GDScriptParser parser; Error err = parser.parse(code); @@ -1057,7 +966,6 @@ MainLoop *test(TestType p_type) { GDScriptCompiler gdc; err = gdc.compile(&parser, gds.ptr()); if (err) { - print_line("Compile Error:\n" + itos(gdc.get_error_line()) + ":" + itos(gdc.get_error_column()) + ":" + gdc.get_error()); return nullptr; } @@ -1065,7 +973,6 @@ MainLoop *test(TestType p_type) { Ref<GDScript> current = gds; while (current.is_valid()) { - print_line("** CLASS **"); _disassemble_class(current, lines); @@ -1073,7 +980,6 @@ MainLoop *test(TestType p_type) { } } else if (p_type == TEST_BYTECODE) { - Vector<uint8_t> buf2 = GDScriptTokenizerBuffer::parse_code_string(code); String dst = test.get_basename() + ".gdc"; FileAccess *fw = FileAccess::open(dst, FileAccess::WRITE); diff --git a/main/tests/test_gui.cpp b/main/tests/test_gui.cpp index c5c8917a51..14bc13ff61 100644 --- a/main/tests/test_gui.cpp +++ b/main/tests/test_gui.cpp @@ -59,14 +59,11 @@ namespace TestGUI { class TestMainLoop : public SceneTree { - public: virtual void request_quit() { - quit(); } virtual void init() { - SceneTree::init(); Panel *frame = memnew(Panel); @@ -266,7 +263,6 @@ public: }; MainLoop *test() { - return memnew(TestMainLoop); } } // namespace TestGUI diff --git a/main/tests/test_main.cpp b/main/tests/test_main.cpp index 922a55b88e..eb60372e6c 100644 --- a/main/tests/test_main.cpp +++ b/main/tests/test_main.cpp @@ -47,7 +47,6 @@ #include "test_string.h" const char **tests_get_names() { - static const char *test_names[] = { "string", "math", @@ -70,76 +69,61 @@ const char **tests_get_names() { } MainLoop *test_main(String p_test, const List<String> &p_args) { - if (p_test == "string") { - return TestString::test(); } if (p_test == "math") { - return TestMath::test(); } if (p_test == "physics_2d") { - return TestPhysics2D::test(); } if (p_test == "physics_3d") { - return TestPhysics3D::test(); } if (p_test == "render") { - return TestRender::test(); } if (p_test == "oa_hash_map") { - return TestOAHashMap::test(); } #ifndef _3D_DISABLED if (p_test == "gui") { - return TestGUI::test(); } #endif if (p_test == "shaderlang") { - return TestShaderLang::test(); } if (p_test == "gd_tokenizer") { - return TestGDScript::test(TestGDScript::TEST_TOKENIZER); } if (p_test == "gd_parser") { - return TestGDScript::test(TestGDScript::TEST_PARSER); } if (p_test == "gd_compiler") { - return TestGDScript::test(TestGDScript::TEST_COMPILER); } if (p_test == "gd_bytecode") { - return TestGDScript::test(TestGDScript::TEST_BYTECODE); } if (p_test == "ordered_hash_map") { - return TestOrderedHashMap::test(); } if (p_test == "astar") { - return TestAStar::test(); } @@ -150,7 +134,6 @@ MainLoop *test_main(String p_test, const List<String> &p_args) { #else const char **tests_get_names() { - static const char *test_names[] = { nullptr }; @@ -159,7 +142,6 @@ const char **tests_get_names() { } MainLoop *test_main(String p_test, const List<String> &p_args) { - return nullptr; } diff --git a/main/tests/test_math.cpp b/main/tests/test_math.cpp index fbd1aa275a..33589e37af 100644 --- a/main/tests/test_math.cpp +++ b/main/tests/test_math.cpp @@ -50,7 +50,6 @@ namespace TestMath { class GetClassAndNamespace { - String code; int idx; int line; @@ -77,12 +76,9 @@ class GetClassAndNamespace { }; Token get_token() { - while (true) { switch (code[idx]) { - case '\n': { - line++; idx++; break; @@ -92,37 +88,30 @@ class GetClassAndNamespace { } break; case '{': { - idx++; return TK_CURLY_BRACKET_OPEN; }; case '}': { - idx++; return TK_CURLY_BRACKET_CLOSE; }; case '[': { - idx++; return TK_BRACKET_OPEN; }; case ']': { - idx++; return TK_BRACKET_CLOSE; }; case ':': { - idx++; return TK_COLON; }; case ',': { - idx++; return TK_COMMA; }; case '.': { - idx++; return TK_PERIOD; }; @@ -134,7 +123,6 @@ class GetClassAndNamespace { continue; } break; case '/': { - switch (code[idx + 1]) { case '*': { // block comment @@ -145,7 +133,6 @@ class GetClassAndNamespace { error = true; return TK_ERROR; } else if (code[idx] == '*' && code[idx + 1] == '/') { - idx += 2; break; } else if (code[idx] == '\n') { @@ -174,7 +161,6 @@ class GetClassAndNamespace { } break; case '\'': case '"': { - CharType begin_str = code[idx]; idx++; String tk_string = String(); @@ -198,7 +184,6 @@ class GetClassAndNamespace { CharType res = 0; switch (next) { - case 'b': res = 8; break; @@ -241,7 +226,6 @@ class GetClassAndNamespace { } break; default: { - if (code[idx] <= 32) { idx++; break; @@ -262,11 +246,9 @@ class GetClassAndNamespace { return TK_NUMBER; } else if ((code[idx] >= 'A' && code[idx] <= 'Z') || (code[idx] >= 'a' && code[idx] <= 'z') || code[idx] > 127) { - String id; while ((code[idx] >= 'A' && code[idx] <= 'Z') || (code[idx] >= 'a' && code[idx] <= 'z') || code[idx] > 127) { - id += code[idx]; idx++; } @@ -285,7 +267,6 @@ class GetClassAndNamespace { public: Error parse(const String &p_code, const String &p_known_class_name = String()) { - code = p_code; idx = 0; line = 0; @@ -301,7 +282,6 @@ public: int curly_stack = 0; while (!error || tk != TK_EOF) { - if (tk == TK_BRACKET_OPEN) { tk = get_token(); if (tk == TK_IDENTIFIER && String(value) == "ScriptClass") { @@ -374,7 +354,6 @@ public: }; void test_vec(Plane p_vec) { - CameraMatrix cm; cm.set_perspective(45, 1, 0, 100); Plane v0 = cm.xform4(p_vec); @@ -413,7 +392,6 @@ uint32_t ihash3(uint32_t a) { } MainLoop *test() { - { Vector<Vector3> points; points.push_back(Vector3(0, 0, 0)); @@ -564,26 +542,22 @@ MainLoop *test() { } { - Vector<int> hashes; List<StringName> tl; ClassDB::get_class_list(&tl); for (List<StringName>::Element *E = tl.front(); E; E = E->next()) { - Vector<uint8_t> m5b = E->get().operator String().md5_buffer(); hashes.push_back(hashes.size()); } for (int i = nearest_shift(hashes.size()); i < 20; i++) { - bool success = true; for (int s = 0; s < 10000; s++) { Set<uint32_t> existing; success = true; for (int j = 0; j < hashes.size(); j++) { - uint32_t eh = ihash2(ihash3(hashes[j] + ihash(s) + s)) & ((1 << i) - 1); if (existing.has(eh)) { success = false; diff --git a/main/tests/test_oa_hash_map.cpp b/main/tests/test_oa_hash_map.cpp index cffec7fa77..b14fda15c4 100644 --- a/main/tests/test_oa_hash_map.cpp +++ b/main/tests/test_oa_hash_map.cpp @@ -36,7 +36,6 @@ namespace TestOAHashMap { MainLoop *test() { - OS::get_singleton()->print("\n\n\nHello from test\n"); // test element tracking. @@ -122,7 +121,6 @@ MainLoop *test() { // regression test / test for issue related to #31402 { - OS::get_singleton()->print("test for issue #31402 started...\n"); const int num_test_values = 12; diff --git a/main/tests/test_ordered_hash_map.cpp b/main/tests/test_ordered_hash_map.cpp index e909626243..12d9e7906c 100644 --- a/main/tests/test_ordered_hash_map.cpp +++ b/main/tests/test_ordered_hash_map.cpp @@ -146,7 +146,6 @@ TestFunc test_funcs[] = { }; MainLoop *test() { - int count = 0; int passed = 0; diff --git a/main/tests/test_physics_2d.cpp b/main/tests/test_physics_2d.cpp index 6feff3b0a9..7bb6dfedc9 100644 --- a/main/tests/test_physics_2d.cpp +++ b/main/tests/test_physics_2d.cpp @@ -44,7 +44,6 @@ static const unsigned char convex_png[] = { }; class TestPhysics2DMainLoop : public MainLoop { - GDCLASS(TestPhysics2DMainLoop, MainLoop); RID circle_img; @@ -58,7 +57,6 @@ class TestPhysics2DMainLoop : public MainLoop { Vector2 ray_from, ray_to; struct BodyShapeData { - RID image; RID shape; }; @@ -72,13 +70,10 @@ class TestPhysics2DMainLoop : public MainLoop { // SEGMENT { - Vector<uint8_t> pixels; pixels.resize(32 * 2 * 2); for (int i = 0; i < 2; i++) { - for (int j = 0; j < 32; j++) { - pixels.set(i * 32 * 2 + j * 2 + 0, (j == 0) ? 255 : 0); pixels.set(i * 32 * 2 + j * 2 + 1, 255); } @@ -97,13 +92,10 @@ class TestPhysics2DMainLoop : public MainLoop { // CIRCLE { - Vector<uint8_t> pixels; pixels.resize(32 * 32 * 2); for (int i = 0; i < 32; i++) { - for (int j = 0; j < 32; j++) { - bool black = Vector2(i - 16, j - 16).length_squared() < 16 * 16; pixels.set(i * 32 * 2 + j * 2 + 0, (i == 16 || j == 16) ? 255 : 0); @@ -124,13 +116,10 @@ class TestPhysics2DMainLoop : public MainLoop { // BOX { - Vector<uint8_t> pixels; pixels.resize(32 * 32 * 2); for (int i = 0; i < 32; i++) { - for (int j = 0; j < 32; j++) { - bool black = i > 0 && i < 31 && j > 0 && j < 31; pixels.set(i * 32 * 2 + j * 2 + 0, black ? 0 : 255); @@ -151,13 +140,10 @@ class TestPhysics2DMainLoop : public MainLoop { // CAPSULE { - Vector<uint8_t> pixels; pixels.resize(32 * 64 * 2); for (int i = 0; i < 64; i++) { - for (int j = 0; j < 32; j++) { - int si = i > 48 ? i - 32 : (i < 16 ? i : 16); bool black = Vector2(si - 16, j - 16).length_squared() < 16 * 16; @@ -179,7 +165,6 @@ class TestPhysics2DMainLoop : public MainLoop { // CONVEX { - Ref<Image> image = memnew(Image(convex_png)); body_shape_data[PhysicsServer2D::SHAPE_CONVEX_POLYGON].image = vs->texture_2d_create(image); @@ -202,7 +187,6 @@ class TestPhysics2DMainLoop : public MainLoop { } void _do_ray_query() { - /* PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); ps->query_intersection_segment(ray_query,ray_from,ray_to); @@ -211,13 +195,10 @@ class TestPhysics2DMainLoop : public MainLoop { protected: void input_event(const Ref<InputEvent> &p_event) { - Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid()) { - if (mb->is_pressed()) { - Point2 p(mb->get_position().x, mb->get_position().y); if (mb->get_button_index() == 1) { @@ -233,7 +214,6 @@ protected: Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - Point2 p = mm->get_position(); if (mm->get_button_mask() & BUTTON_MASK_LEFT) { @@ -247,7 +227,6 @@ protected: } RID _add_body(PhysicsServer2D::ShapeType p_shape, const Transform2D &p_xform) { - RenderingServer *vs = RenderingServer::get_singleton(); PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); @@ -272,7 +251,6 @@ protected: } void _add_plane(const Vector2 &p_normal, real_t p_d) { - PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); Array arr; @@ -289,7 +267,6 @@ protected: } void _add_concave(const Vector<Vector2> &p_points, const Transform2D &p_xform = Transform2D()) { - PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); RenderingServer *vs = RenderingServer::get_singleton(); @@ -315,7 +292,6 @@ protected: } void _ray_query_callback(const RID &p_rid, ObjectID p_id, int p_shape, const Vector2 &p_point, const Vector2 &p_normal) { - Vector2 ray_end; if (p_rid.is_valid()) { @@ -333,14 +309,12 @@ protected: } static void _bind_methods() { - ClassDB::bind_method(D_METHOD("_body_moved"), &TestPhysics2DMainLoop::_body_moved); ClassDB::bind_method(D_METHOD("_ray_query_callback"), &TestPhysics2DMainLoop::_ray_query_callback); } public: virtual void init() { - RenderingServer *vs = RenderingServer::get_singleton(); PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); @@ -351,7 +325,6 @@ public: ps->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY, 98); { - RID vp = vs->viewport_create(); canvas = vs->canvas_create(); @@ -377,7 +350,6 @@ public: _create_body_shape_data(); for (int i = 0; i < 32; i++) { - PhysicsServer2D::ShapeType types[4] = { PhysicsServer2D::SHAPE_CIRCLE, PhysicsServer2D::SHAPE_CAPSULE, @@ -402,7 +374,6 @@ public: Vector<Point2> parr; for (int i = 0; i < 30; i++) { - Point2 p(i * 60, Math::randf() * 70 + 340); if (i > 0) { parr.push_back(prev); @@ -418,7 +389,6 @@ public: } virtual bool idle(float p_time) { - return false; } virtual void finish() { @@ -430,7 +400,6 @@ public: namespace TestPhysics2D { MainLoop *test() { - return memnew(TestPhysics2DMainLoop); } } // namespace TestPhysics2D diff --git a/main/tests/test_physics_3d.cpp b/main/tests/test_physics_3d.cpp index 2d208ee317..0552db86a2 100644 --- a/main/tests/test_physics_3d.cpp +++ b/main/tests/test_physics_3d.cpp @@ -41,7 +41,6 @@ #include "servers/rendering_server.h" class TestPhysics3DMainLoop : public MainLoop { - GDCLASS(TestPhysics3DMainLoop, MainLoop); enum { @@ -69,7 +68,6 @@ class TestPhysics3DMainLoop : public MainLoop { Map<PhysicsServer3D::ShapeType, RID> type_mesh_map; void body_changed_transform(Object *p_state, RID p_visual_instance) { - PhysicsDirectBodyState3D *state = (PhysicsDirectBodyState3D *)p_state; RenderingServer *vs = RenderingServer::get_singleton(); Transform t = state->get_transform(); @@ -80,12 +78,10 @@ class TestPhysics3DMainLoop : public MainLoop { protected: static void _bind_methods() { - ClassDB::bind_method("body_changed_transform", &TestPhysics3DMainLoop::body_changed_transform); } RID create_body(PhysicsServer3D::ShapeType p_shape, PhysicsServer3D::BodyMode p_body, const Transform p_location, bool p_active_default = true, const Transform &p_shape_xform = Transform()) { - RenderingServer *vs = RenderingServer::get_singleton(); PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); @@ -101,14 +97,12 @@ protected: bodies.push_back(body); if (p_body == PhysicsServer3D::BODY_MODE_STATIC) { - vs->instance_set_transform(mesh_instance, p_location); } return body; } RID create_static_plane(const Plane &p_plane) { - PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); RID world_margin_shape = ps->shape_create(PhysicsServer3D::SHAPE_PLANE); @@ -122,7 +116,6 @@ protected: } void configure_body(RID p_body, float p_mass, float p_friction, float p_bounce) { - PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); ps->body_set_param(p_body, PhysicsServer3D::BODY_PARAM_MASS, p_mass); ps->body_set_param(p_body, PhysicsServer3D::BODY_PARAM_FRICTION, p_friction); @@ -130,7 +123,6 @@ protected: } void init_shapes() { - RenderingServer *vs = RenderingServer::get_singleton(); PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); @@ -188,7 +180,6 @@ protected: } void make_trimesh(Vector<Vector3> p_faces, const Transform &p_xform = Transform()) { - RenderingServer *vs = RenderingServer::get_singleton(); PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); RID trimesh_shape = ps->shape_create(PhysicsServer3D::SHAPE_CONCAVE_POLYGON); @@ -196,7 +187,6 @@ protected: p_faces = ps->shape_get_data(trimesh_shape); // optimized one Vector<Vector3> normals; // for drawing for (int i = 0; i < p_faces.size() / 3; i++) { - Plane p(p_faces[i * 3 + 0], p_faces[i * 3 + 1], p_faces[i * 3 + 2]); normals.push_back(p.normal); normals.push_back(p.normal); @@ -222,17 +212,14 @@ protected: } void make_grid(int p_width, int p_height, float p_cellsize, float p_cellheight, const Transform &p_xform = Transform()) { - Vector<Vector<float>> grid; grid.resize(p_width); for (int i = 0; i < p_width; i++) { - grid.write[i].resize(p_height); for (int j = 0; j < p_height; j++) { - grid.write[i].write[j] = 1.0 + Math::random(-p_cellheight, p_cellheight); } } @@ -240,9 +227,7 @@ protected: Vector<Vector3> faces; for (int i = 1; i < p_width; i++) { - for (int j = 1; j < p_height; j++) { - #define MAKE_VERTEX(m_x, m_z) \ faces.push_back(Vector3((m_x - p_width / 2) * p_cellsize, grid[m_x][m_z], (m_z - p_height / 2) * p_cellsize)) @@ -261,21 +246,17 @@ protected: public: virtual void input_event(const Ref<InputEvent> &p_event) { - Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid() && mm->get_button_mask() & 4) { - ofs_y -= mm->get_relative().y / 200.0; ofs_x += mm->get_relative().x / 200.0; } if (mm.is_valid() && mm->get_button_mask() & 1) { - float y = -mm->get_relative().y / 20.0; float x = mm->get_relative().x / 20.0; if (mover.is_valid()) { - PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); Transform t = ps->body_get_state(mover, PhysicsServer3D::BODY_STATE_TRANSFORM); t.origin += Vector3(x, y, 0); @@ -286,11 +267,9 @@ public: } virtual void request_quit() { - quit = true; } virtual void init() { - ofs_x = ofs_y = 0; init_shapes(); @@ -332,7 +311,6 @@ public: quit = false; } virtual bool iteration(float p_time) { - if (mover.is_valid()) { static float joy_speed = 10; PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); @@ -360,7 +338,6 @@ public: } void test_character() { - RenderingServer *vs = RenderingServer::get_singleton(); PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); @@ -393,9 +370,7 @@ public: } void test_fall() { - for (int i = 0; i < 35; i++) { - static const PhysicsServer3D::ShapeType shape_idx[] = { PhysicsServer3D::SHAPE_CAPSULE, PhysicsServer3D::SHAPE_BOX, @@ -417,7 +392,6 @@ public: } void test_activate() { - create_body(PhysicsServer3D::SHAPE_BOX, PhysicsServer3D::BODY_MODE_RIGID, Transform(Basis(), Vector3(0, 2, 0)), true); create_static_plane(Plane(Vector3(0, 1, 0), -1)); } @@ -433,7 +407,6 @@ public: namespace TestPhysics3D { MainLoop *test() { - return memnew(TestPhysics3DMainLoop); } } // namespace TestPhysics3D diff --git a/main/tests/test_render.cpp b/main/tests/test_render.cpp index bcfcf61e25..b512a17e55 100644 --- a/main/tests/test_render.cpp +++ b/main/tests/test_render.cpp @@ -44,7 +44,6 @@ namespace TestRender { class TestMainLoop : public MainLoop { - RID test_cube; RID instance; RID camera; @@ -53,7 +52,6 @@ class TestMainLoop : public MainLoop { RID scenario; struct InstanceInfo { - RID instance; Transform base; Vector3 rot_axis; @@ -67,13 +65,11 @@ class TestMainLoop : public MainLoop { protected: public: virtual void input_event(const Ref<InputEvent> &p_event) { - if (p_event->is_pressed()) quit = true; } virtual void init() { - print_line("INITIALIZING TEST RENDER"); RenderingServer *vs = RenderingServer::get_singleton(); test_cube = vs->get_test_cube(); @@ -144,7 +140,6 @@ public: }; for (int i = 0; i < object_count; i++) { - InstanceInfo ii; ii.instance = vs->instance_create2(test_cube, scenario); @@ -205,7 +200,6 @@ public: quit = false; } virtual bool iteration(float p_time) { - RenderingServer *vs = RenderingServer::get_singleton(); //Transform t; //t.rotate(Vector3(0, 1, 0), ofs); @@ -217,7 +211,6 @@ public: //return quit; for (List<InstanceInfo>::Element *E = instances.front(); E; E = E->next()) { - Transform pre(Basis(E->get().rot_axis, ofs), Vector3()); vs->instance_set_transform(E->get().instance, pre * E->get().base); /* @@ -240,7 +233,6 @@ public: }; MainLoop *test() { - return memnew(TestMainLoop); } } // namespace TestRender diff --git a/main/tests/test_shader_lang.cpp b/main/tests/test_shader_lang.cpp index abcf30c97f..42d4841ecf 100644 --- a/main/tests/test_shader_lang.cpp +++ b/main/tests/test_shader_lang.cpp @@ -44,7 +44,6 @@ typedef ShaderLanguage SL; namespace TestShaderLang { static String _mktab(int p_level) { - String tb; for (int i = 0; i < p_level; i++) { tb += "\t"; @@ -54,12 +53,10 @@ static String _mktab(int p_level) { } static String _typestr(SL::DataType p_type) { - return ShaderLanguage::get_datatype_name(p_type); } static String _prestr(SL::DataPrecision p_pres) { - switch (p_pres) { case SL::PRECISION_LOWP: return "lowp "; @@ -74,12 +71,10 @@ static String _prestr(SL::DataPrecision p_pres) { } static String _opstr(SL::Operator p_op) { - return ShaderLanguage::get_operator_text(p_op); } static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNode::Value> &p_values) { - switch (p_type) { case SL::TYPE_BOOL: return p_values[0].boolean ? "true" : "false"; @@ -119,17 +114,13 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo } static String dump_node_code(SL::Node *p_node, int p_level) { - String code; switch (p_node->type) { - case SL::Node::TYPE_SHADER: { - SL::ShaderNode *pnode = (SL::ShaderNode *)p_node; for (Map<StringName, SL::ShaderNode::Uniform>::Element *E = pnode->uniforms.front(); E; E = E->next()) { - String ucode = "uniform "; ucode += _prestr(E->get().precision); ucode += _typestr(E->get().type); @@ -156,7 +147,6 @@ static String dump_node_code(SL::Node *p_node, int p_level) { } for (Map<StringName, SL::ShaderNode::Varying>::Element *E = pnode->varyings.front(); E; E = E->next()) { - String vcode = "varying "; vcode += _prestr(E->get().precision); vcode += _typestr(E->get().type); @@ -165,13 +155,11 @@ static String dump_node_code(SL::Node *p_node, int p_level) { code += vcode + "\n"; } for (int i = 0; i < pnode->functions.size(); i++) { - SL::FunctionNode *fnode = pnode->functions[i].function; String header; header = _typestr(fnode->return_type) + " " + fnode->name + "("; for (int j = 0; j < fnode->arguments.size(); j++) { - if (j > 0) header += ", "; header += _prestr(fnode->arguments[j].precision) + _typestr(fnode->arguments[j].type) + " " + fnode->arguments[j].name; @@ -185,10 +173,8 @@ static String dump_node_code(SL::Node *p_node, int p_level) { //code+=dump_node_code(pnode->body,p_level); } break; case SL::Node::TYPE_STRUCT: { - } break; case SL::Node::TYPE_FUNCTION: { - } break; case SL::Node::TYPE_BLOCK: { SL::BlockNode *bnode = (SL::BlockNode *)p_node; @@ -196,12 +182,10 @@ static String dump_node_code(SL::Node *p_node, int p_level) { //variables code += _mktab(p_level - 1) + "{\n"; for (Map<StringName, SL::BlockNode::Variable>::Element *E = bnode->variables.front(); E; E = E->next()) { - code += _mktab(p_level) + _prestr(E->get().precision) + _typestr(E->get().type) + " " + E->key() + ";\n"; } for (int i = 0; i < bnode->statements.size(); i++) { - String scode = dump_node_code(bnode->statements[i], p_level); if (bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW) { @@ -240,7 +224,6 @@ static String dump_node_code(SL::Node *p_node, int p_level) { SL::OperatorNode *onode = (SL::OperatorNode *)p_node; switch (onode->op) { - case SL::OP_ASSIGN: case SL::OP_ASSIGN_ADD: case SL::OP_ASSIGN_SUB: @@ -276,7 +259,6 @@ static String dump_node_code(SL::Node *p_node, int p_level) { code += ")"; break; default: { - code = "(" + dump_node_code(onode->arguments[0], p_level) + _opstr(onode->op) + dump_node_code(onode->arguments[1], p_level) + ")"; break; } @@ -286,17 +268,14 @@ static String dump_node_code(SL::Node *p_node, int p_level) { case SL::Node::TYPE_CONTROL_FLOW: { SL::ControlFlowNode *cfnode = (SL::ControlFlowNode *)p_node; if (cfnode->flow_op == SL::FLOW_OP_IF) { - code += _mktab(p_level) + "if (" + dump_node_code(cfnode->expressions[0], p_level) + ")\n"; code += dump_node_code(cfnode->blocks[0], p_level + 1); if (cfnode->blocks.size() == 2) { - code += _mktab(p_level) + "else\n"; code += dump_node_code(cfnode->blocks[1], p_level + 1); } } else if (cfnode->flow_op == SL::FLOW_OP_RETURN) { - if (cfnode->blocks.size()) { code = "return " + dump_node_code(cfnode->blocks[0], p_level); } else { @@ -316,7 +295,6 @@ static String dump_node_code(SL::Node *p_node, int p_level) { } static Error recreate_code(void *p_str, SL::ShaderNode *p_program) { - String *str = (String *)p_str; *str = dump_node_code(p_program, 0); @@ -325,7 +303,6 @@ static Error recreate_code(void *p_str, SL::ShaderNode *p_program) { } MainLoop *test() { - List<String> cmdlargs = OS::get_singleton()->get_cmdline_args(); if (cmdlargs.empty()) { @@ -366,7 +343,6 @@ MainLoop *test() { Error err = sl.compile(code, dt, rm, types, nullptr); if (err) { - print_line("Error at line: " + rtos(sl.get_error_line()) + ": " + sl.get_error_text()); return nullptr; } else { diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp index 76631f9eae..aa59b74371 100644 --- a/main/tests/test_string.cpp +++ b/main/tests/test_string.cpp @@ -45,7 +45,6 @@ namespace TestString { bool test_1() { - OS::get_singleton()->print("\n\nTest 1: Assign from cstr\n"); String s = "Hello"; @@ -57,7 +56,6 @@ bool test_1() { } bool test_2() { - OS::get_singleton()->print("\n\nTest 2: Assign from string (operator=)\n"); String s = "Dolly"; @@ -70,7 +68,6 @@ bool test_2() { } bool test_3() { - OS::get_singleton()->print("\n\nTest 3: Assign from c-string (copycon)\n"); String s("Sheep"); @@ -83,7 +80,6 @@ bool test_3() { } bool test_4() { - OS::get_singleton()->print("\n\nTest 4: Assign from c-widechar (operator=)\n"); String s(L"Give me"); @@ -95,7 +91,6 @@ bool test_4() { } bool test_5() { - OS::get_singleton()->print("\n\nTest 5: Assign from c-widechar (copycon)\n"); String s(L"Wool"); @@ -107,7 +102,6 @@ bool test_5() { } bool test_6() { - OS::get_singleton()->print("\n\nTest 6: comparisons (equal)\n"); String s = "Test Compare"; @@ -127,7 +121,6 @@ bool test_6() { } bool test_7() { - OS::get_singleton()->print("\n\nTest 7: comparisons (unequal)\n"); String s = "Test Compare"; @@ -147,7 +140,6 @@ bool test_7() { } bool test_8() { - OS::get_singleton()->print("\n\nTest 8: comparisons (operator<)\n"); String s = "Bees"; @@ -167,7 +159,6 @@ bool test_8() { } bool test_9() { - OS::get_singleton()->print("\n\nTest 9: Concatenation\n"); String s; @@ -186,7 +177,6 @@ bool test_9() { } bool test_10() { - OS::get_singleton()->print("\n\nTest 10: Misc funcs (size/length/empty/etc)\n"); if (!String("").empty()) @@ -202,7 +192,6 @@ bool test_10() { } bool test_11() { - OS::get_singleton()->print("\n\nTest 11: Operator[]\n"); String a = "Kugar Sane"; @@ -220,7 +209,6 @@ bool test_11() { } bool test_12() { - OS::get_singleton()->print("\n\nTest 12: case functions\n"); String a = "MoMoNgA"; @@ -235,7 +223,6 @@ bool test_12() { } bool test_13() { - OS::get_singleton()->print("\n\nTest 13: UTF8\n"); /* how can i embed UTF in here? */ @@ -252,7 +239,6 @@ bool test_13() { } bool test_14() { - OS::get_singleton()->print("\n\nTest 14: ASCII\n"); String s = L"Primero Leche"; @@ -263,7 +249,6 @@ bool test_14() { } bool test_15() { - OS::get_singleton()->print("\n\nTest 15: substr\n"); String s = "Killer Baby"; @@ -273,7 +258,6 @@ bool test_15() { } bool test_16() { - OS::get_singleton()->print("\n\nTest 16: find\n"); String s = "Pretty Woman"; @@ -291,7 +275,6 @@ bool test_16() { } bool test_17() { - OS::get_singleton()->print("\n\nTest 17: find no case\n"); String s = "Pretty Whale"; @@ -309,7 +292,6 @@ bool test_17() { } bool test_18() { - OS::get_singleton()->print("\n\nTest 18: find no case\n"); String s = "Pretty Whale"; @@ -327,7 +309,6 @@ bool test_18() { } bool test_19() { - OS::get_singleton()->print("\n\nTest 19: Search & replace\n"); String s = "Happy Birthday, Anna!"; @@ -340,7 +321,6 @@ bool test_19() { } bool test_20() { - OS::get_singleton()->print("\n\nTest 20: Insertion\n"); String s = "Who is Frederic?"; @@ -353,7 +333,6 @@ bool test_20() { } bool test_21() { - OS::get_singleton()->print("\n\nTest 21: Number -> String\n"); OS::get_singleton()->print("\tPi is %f\n", 33.141593); @@ -363,7 +342,6 @@ bool test_21() { } bool test_22() { - OS::get_singleton()->print("\n\nTest 22: String -> Int\n"); static const char *nums[4] = { "1237461283", "- 22", "0", " - 1123412" }; @@ -380,7 +358,6 @@ bool test_22() { } bool test_23() { - OS::get_singleton()->print("\n\nTest 23: String -> Float\n"); static const char *nums[4] = { "-12348298412.2", "0.05", "2.0002", " -0.0001" }; @@ -397,7 +374,6 @@ bool test_23() { } bool test_24() { - OS::get_singleton()->print("\n\nTest 24: Slicing\n"); String s = "Mars,Jupiter,Saturn,Uranus"; @@ -407,7 +383,6 @@ bool test_24() { OS::get_singleton()->print("\tSlicing \"%ls\" by \"%s\"..\n", s.c_str(), ","); for (int i = 0; i < s.get_slice_count(","); i++) { - OS::get_singleton()->print("\t\t%i- %ls\n", i + 1, s.get_slice(",", i).c_str()); if (s.get_slice(",", i) != slices[i]) @@ -418,7 +393,6 @@ bool test_24() { } bool test_25() { - OS::get_singleton()->print("\n\nTest 25: Erasing\n"); String s = "Josephine is such a cute girl!"; @@ -433,7 +407,6 @@ bool test_25() { } bool test_26() { - OS::get_singleton()->print("\n\nTest 26: RegEx substitution\n"); #ifndef MODULE_REGEX_ENABLED @@ -461,7 +434,6 @@ struct test_27_data { }; bool test_27() { - OS::get_singleton()->print("\n\nTest 27: begins_with\n"); test_27_data tc[] = { { "res://foobar", "res://", true }, @@ -486,7 +458,6 @@ bool test_27() { }; bool test_28() { - OS::get_singleton()->print("\n\nTest 28: sprintf\n"); bool success, state = true; @@ -822,7 +793,6 @@ bool test_28() { } bool test_29() { - bool state = true; IP_Address ip0("2001:0db8:85a3:0000:0000:8a2e:0370:7334"); @@ -997,7 +967,6 @@ bool test_31() { }; bool test_32() { - #define STRIP_TEST(x) \ { \ bool success = x; \ @@ -1173,7 +1142,6 @@ TestFunc test_funcs[] = { }; MainLoop *test() { - /** A character length != wchar_t may be forced, so the tests won't work */ static_assert(sizeof(CharType) == sizeof(wchar_t)); |