[colobot] 204/377: Can't stop testing
Didier Raboud
odyx at moszumanska.debian.org
Wed Mar 30 13:34:16 UTC 2016
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch debian/master
in repository colobot.
commit d041a16a50b03dc49a57484586d9a037472a7186
Author: krzys-h <krzys_h at interia.pl>
Date: Fri Dec 25 18:31:07 2015 +0100
Can't stop testing
---
test/unit/CBot/CBot.cpp | 99 +++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 95 insertions(+), 4 deletions(-)
diff --git a/test/unit/CBot/CBot.cpp b/test/unit/CBot/CBot.cpp
index 4a0f592..ca8fd22 100644
--- a/test/unit/CBot/CBot.cpp
+++ b/test/unit/CBot/CBot.cpp
@@ -194,7 +194,7 @@ private:
}
protected:
- void ExecuteTest(const std::string& code, CBotError expectedError = CBotNoErr)
+ std::unique_ptr<CBotProgram> ExecuteTest(const std::string& code, CBotError expectedError = CBotNoErr)
{
CBotError expectedCompileError = expectedError < 6000 ? expectedError : CBotNoErr;
CBotError expectedRuntimeError = expectedError >= 6000 ? expectedError : CBotNoErr;
@@ -211,14 +211,16 @@ protected:
std::stringstream ss;
if (error != CBotNoErr)
{
- FAIL() << "Compile error - " << error << " (" << cursor1 << "-" << (cursor2 >= 0 ? cursor2 : cursor1) << ")" << std::endl << GetFormattedLineInfo(code, cursor1); // TODO: Error messages are on Colobot side
+ ADD_FAILURE() << "Compile error - " << error << " (" << cursor1 << "-" << (cursor2 >= 0 ? cursor2 : cursor1) << ")" << std::endl << GetFormattedLineInfo(code, cursor1); // TODO: Error messages are on Colobot side
+ return std::move(program);
}
else
{
- FAIL() << "No compile error, expected " << expectedCompileError; // TODO: Error messages are on Colobot side
+ ADD_FAILURE() << "No compile error, expected " << expectedCompileError; // TODO: Error messages are on Colobot side
+ return std::move(program);
}
}
- if (expectedCompileError != CBotNoErr) return;
+ if (expectedCompileError != CBotNoErr) return std::move(program);
for (const std::string& test : tests)
{
@@ -279,6 +281,7 @@ protected:
ADD_FAILURE() << ss.str();
}
}
+ return std::move(program); // Take it if you want, destroy on exit otherwise
}
};
@@ -674,6 +677,34 @@ TEST_F(CBotUT, DISABLED_FunctionNoReturn)
);
}
+TEST_F(CBotUT, PublicFunctions)
+{
+ // Keep the program, so that the function continues to exist after ExecuteTest finishes
+ auto publicProgram = ExecuteTest(
+ "public int test()\n"
+ "{\n"
+ " return 1337;\n"
+ "}\n"
+ );
+
+ ExecuteTest(
+ "extern void TestPublic()\n"
+ "{\n"
+ " ASSERT(test() == 1337);\n"
+ "}\n"
+ );
+
+ publicProgram.reset(); // Now remove
+
+ ExecuteTest(
+ "extern void TestPublicRemoved()\n"
+ "{\n"
+ " ASSERT(test() == 1337);\n"
+ "}\n",
+ CBotErrUndefCall
+ );
+}
+
TEST_F(CBotUT, ClassConstructor)
{
ExecuteTest(
@@ -728,6 +759,38 @@ TEST_F(CBotUT, ClassDestructor)
);
}
+TEST_F(CBotUT, ClassNullPointer)
+{
+ ExecuteTest(
+ "public class TestClass {\n"
+ " public void TestClass() {\n"
+ " FAIL();\n"
+ " }\n"
+ "}\n"
+ "extern void TestClassNullPointer()\n"
+ "{\n"
+ " TestClass t;\n"
+ //" ASSERT(t == null);\n" // TODO: OH REALLY?
+ " TestClass t2 = null;\n"
+ " ASSERT(t2 == null);\n"
+ "}\n"
+ );
+ ExecuteTest(
+ "public class TestClass {\n"
+ " public int x = 0;"
+ " public void TestClass() {\n"
+ " FAIL();\n"
+ " }\n"
+ "}\n"
+ "extern void TestClassNullPointerAccess()\n"
+ "{\n"
+ " TestClass t;\n"
+ " int y = t.x;\n"
+ "}\n",
+ CBotErrNull
+ );
+}
+
// TODO: This doesn't work
TEST_F(CBotUT, DISABLED_ClassDestructorNaming)
{
@@ -792,6 +855,34 @@ TEST_F(CBotUT, DISABLED_ClassRedefined)
);
}
+// TODO: NOOOOOO!!! Nononononono :/
+TEST_F(CBotUT, DISABLED_PublicClasses)
+{
+ // Keep the program, so that the class continues to exist after ExecuteTest finishes
+ auto publicProgram = ExecuteTest(
+ "public class TestClass\n"
+ "{\n"
+ "}\n"
+ );
+
+ ExecuteTest(
+ "extern void TestPublic()\n"
+ "{\n"
+ " TestClass t();\n"
+ "}\n"
+ );
+
+ publicProgram.reset(); // Now remove
+
+ ExecuteTest(
+ "extern void TestPublicRemoved()\n"
+ "{\n"
+ " TestClass t();\n"
+ "}\n",
+ CBotErrUndefClass
+ );
+}
+
// TODO: This needs to be fixed
TEST_F(CBotUT, DISABLED_WeirdThisEarlyContextSwitch_Issue436)
{
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list