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:
@@ -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" });
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user