# testframework
_ISTEST = 1
!! Set up the date, the player character basic attributes, etc.
if $ARGS[0] = 'testsetup':
daystart = 0
month = 8
$month = 'August'
day = 26
week = 5
hour = 9
birthyear = 1999
birthmonth = 4
birthday = 1
pcs_haircol = 1
pcs_eyesize = 2
pcs_lip = 1
pcs_lashes = 1
!! Body
pcs_hgt = 170
pcs_teeth = 0
pcs_butt = 8
pcs_skin = 500
!! Stats
pcs_stren = 35
strenbuf = 10
pcs_agil = 35
agilbuf = 10
pcs_vital = 35
vitalbuf = 10
pcs_intel = 35
pcs_sprt = 35
pcs_react = 35
pcs_chrsm = 35
pcs_prcptn = 35
pcs_magik = 0
$pcs_firstname = "Svetlana"
$pcs_lastname = "Lebedev"
$pcs_nickname = "Sveta"
end
!! Asserts that the two strings passed in $ARGS[1] and $ARGS[2] are equal.
if $ARGS[0] = 'assertEqualsString':
RESULT = $ARGS[1] = $ARGS[2]
end
!! Asserts that the two numbers passed in ARGS[1] and ARGS[2] are equal.
if $ARGS[0] = 'assertEqualsNumber':
RESULT = ARGS[1] = ARGS[2]
end
!! Asserts that the two Arrays passed in $ARGS[1] and $ARGS[2] are equal.
!! The two parameters are the Array variable names
if $ARGS[0] = 'assertEqualsStringArray':
RESULT = ARRSIZE($ARGS[1]) = ARRSIZE($ARGS[2])
end
if $ARGS[0] = 'addTestResult':
$testResults[testCount] = "<<$TESTNAME>>; gs '<<$LOCATIONNAME>>', '<<$FUNCTIONNAME>>'" + iif($ARGUMENTS ! '', ', <<$ARGUMENTS>>', '') + "; <<$EXPECTED_MESSAGE>>; <<$ACTUAL_MESSAGE>>; "
if TESTRESULT ! 0:
$testResults[testCount] += 'S'
testPassed += 1
else
$testResults[testCount] += 'F'
testFailed += 1
end
testCount += 1
end
if $ARGS[0] = 'displayTestResults':
$ROW[0] = '
Test results for TestSuite: <<$_TESTSUITE>>
'
$ROW[1] = ' Test built: <<$_TESTBUILDTIME>>'
if _TESTSAVED ! 0:
$ROW[2] = ' This is a saved test result, not a new run.
'
else
$ROW[2] = ' New test run results
'
end
$ROW[5] = ' Number of tests executed: <>'
$ROW[6] = ' Number of test passed : <>'
$ROW[7] = ' Number of test failed : <>'
$ROW[8] = ''
$ROW[9] = 'Test Name | Call (location, function) | Expected | Actual | Result |
'
size = ARRSIZE('testResults')
rowindex = ARRSIZE('ROW')
resultindex = 0
:testresultprocessloop
$ROW[rowindex] = '' + $REPLACE($testResults[resultindex], '; ', ' | ') + ' |
'
rowindex += 1
resultindex += 1
if resultindex < size: jump 'testresultprocessloop'
$ROW[rowindex] = '
'
size = ARRSIZE('ROW')
index = 0
:testresultdisplayloop
'<<$ROW[index]>>'
index += 1
if index < size: jump 'testresultdisplayloop'
'
'
*nl
end
if $ARGS[0] = 'saveTestResults':
gs 'testframework', 'cleanUpTestData'
_TESTSAVED = 1
savegame '<<$_TESTSUITE>>-Results-<<$_TESTFILETIME>>.test'
end
if $ARGS[0] = 'cleanUpDefault':
killvar 'ARGUMENTS'
killvar 'EXPECTED'
killvar 'EXPECTED_MESSAGE'
killvar 'ACTUAL'
killvar 'ACTUAL_MESSAGE'
killvar 'FUNCTIONNAME'
killvar 'TESTRESULT'
killvar 'daystart'
killvar 'month'
killvar '$month'
killvar 'day'
killvar 'week'
killvar 'hour'
killvar 'birthyear'
killvar 'birthmonth'
killvar 'birthday'
killvar 'pcs_haircol'
killvar 'pcs_eyesize'
killvar 'pcs_lip'
killvar 'pcs_lashes'
!! Body
killvar 'pcs_hgt'
killvar 'pcs_teeth'
killvar 'pcs_butt'
killvar 'pcs_skin'
!! Stats
killvar 'pcs_stren'
killvar 'strenbuf'
killvar 'pcs_agil'
killvar 'agilbuf'
killvar 'pcs_vital'
killvar 'vitalbuf'
killvar 'pcs_intel'
killvar 'pcs_sprt'
killvar 'pcs_react'
killvar 'pcs_chrsm'
killvar 'pcs_prcptn'
killvar 'pcs_magik'
killvar 'pcs_firstname'
killvar 'pcs_lastname'
killvar 'pcs_nickname'
end
--- testframework --------------------------------