1
0
forked from mirrors/0ad

Rename expectException from 1cdc8f1356 to TS_ASSERT_EXCEPTION.

Move it from the test of the testsetup to the setup of the tests, so it
can be reused by tests, refs #4759, D871.

This was SVN commit r20989.
This commit is contained in:
elexis
2018-01-23 20:00:52 +00:00
parent b3fa0aaf0f
commit 5245e9983b
2 changed files with 15 additions and 14 deletions
@@ -6,19 +6,11 @@ TestSetup.prototype.Init = function() {};
Engine.RegisterSystemComponentType(IID_TestSetup, "TestSetup", TestSetup);
let cmpTestSetup = ConstructComponent(SYSTEM_ENTITY, "TestSetup", { "property": "value" });
function expectException(func)
{
try {
func();
Engine.TS_FAIL("Missed exception at " + new Error().stack);
} catch (e) {}
}
expectException(() => { cmpTestSetup.template = "replacement forbidden"; });
expectException(() => { cmpTestSetup.template.property = "modification forbidden"; });
expectException(() => { cmpTestSetup.template.other_property = "insertion forbidden"; });
expectException(() => { delete cmpTestSetup.entity; });
expectException(() => { delete cmpTestSetup.template; });
expectException(() => { delete cmpTestSetup.template.property; });
TS_ASSERT_EXCEPTION(() => { cmpTestSetup.template = "replacement forbidden"; });
TS_ASSERT_EXCEPTION(() => { cmpTestSetup.template.property = "modification forbidden"; });
TS_ASSERT_EXCEPTION(() => { cmpTestSetup.template.other_property = "insertion forbidden"; });
TS_ASSERT_EXCEPTION(() => { delete cmpTestSetup.entity; });
TS_ASSERT_EXCEPTION(() => { delete cmpTestSetup.template; });
TS_ASSERT_EXCEPTION(() => { delete cmpTestSetup.template.property; });
TS_ASSERT_UNEVAL_EQUALS(cmpTestSetup.template, { "property": "value" });
+9
View File
@@ -43,3 +43,12 @@ global.TS_ASSERT_UNEVAL_EQUALS = function TS_ASSERT_UNEVAL_EQUALS(x, y)
if (!(uneval(x) === uneval(y)))
fail("Expected equal, got "+uneval(x)+" !== "+uneval(y));
}
global.TS_ASSERT_EXCEPTION = function(func)
{
try {
func();
Engine.TS_FAIL("Missed exception at:\n" + new Error().stack);
} catch (e) {
}
}