From 09e49195098cb092c38601ffb526b17e03334046 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 25 Dec 2015 15:23:00 +0100 Subject: [PATCH] More things that should work but don't --- test/unit/CBot/CBot.cpp | 55 ++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/test/unit/CBot/CBot.cpp b/test/unit/CBot/CBot.cpp index 35964419..a5a86ccc 100644 --- a/test/unit/CBot/CBot.cpp +++ b/test/unit/CBot/CBot.cpp @@ -249,25 +249,31 @@ protected: std::string funcName; program->GetRunPos(funcName, cursor1, cursor2); + bool unknown = true; if (!funcName.empty()) { ss << " while executing function " << funcName << " (" << cursor1 << "-" << (cursor2 >= 0 ? cursor2 : cursor1) << ")" << std::endl << GetFormattedLineInfo(code, cursor1); + unknown = false; } else if(e.cursor1 >= 0) { ss << " at unknown location " << e.cursor1 << "-" << (e.cursor2 >= 0 ? e.cursor2 : e.cursor1) << std::endl << GetFormattedLineInfo(code, e.cursor1); + unknown = false; } ss << std::endl; - ss << "Variables:" << std::endl; - int level = 0; - while (true) + if (!unknown) { - CBotVar* var = program->GetStackVars(funcName, level--); - if (var == nullptr) break; + ss << "Variables:" << std::endl; + int level = 0; + while (true) + { + CBotVar* var = program->GetStackVars(funcName, level--); + if (var == nullptr) break; - ss << " Block " << -level << ":" << std::endl; - PrintVars(ss, var); + ss << " Block " << -level << ":" << std::endl; + PrintVars(ss, var); + } } ADD_FAILURE() << ss.str(); @@ -509,6 +515,37 @@ TEST_F(CBotUT, FunctionRedefined) ); } +// TODO: Doesn't work +TEST_F(CBotUT, DISABLED_FunctionBadReturn) +{ + ExecuteTest( + "int func()\n" + "{\n" + " return \"test\";\n" + "}\n" + "extern void FunctionBadReturn()\n" + "{\n" + " int a = func();\n" + "}\n", + static_cast(-1) // TODO: no error for that + ); +} + +// TODO: Doesn't work +TEST_F(CBotUT, DISABLED_FunctionNoReturn) +{ + ExecuteTest( + "int func()\n" + "{\n" + "}\n" + "extern void FunctionNoReturn()\n" + "{\n" + " func();\n" + "}\n", + static_cast(-1) // TODO: no error for that + ); +} + TEST_F(CBotUT, ClassConstructor) { ExecuteTest( @@ -570,7 +607,7 @@ TEST_F(CBotUT, DISABLED_ClassDestructorNaming) "public class TestClass {\n" " public void ~SomethingElse() {}\n" "}\n", - static_cast(-1) + static_cast(-1) // TODO: no error for that ); ExecuteTest( "public class SomethingElse {\n" @@ -578,7 +615,7 @@ TEST_F(CBotUT, DISABLED_ClassDestructorNaming) "public class TestClass2 {\n" " public void ~SomethingElse() {}\n" "}\n", - static_cast(-1) + static_cast(-1) // TODO: no error for that ); }