123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- # 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] += '<font style="color: green;"><b>S</b></font>'
- testPassed += 1
- else
- $testResults[testCount] += '<font style="color: red;"><b>F</b></font>'
- testFailed += 1
- end
- testCount += 1
- end
- if $ARGS[0] = 'displayTestResults':
- $ROW[0] = '<h1>Test results for TestSuite: <<$_TESTSUITE>></h1>'
- $ROW[1] = ' <b>Test built</b>: <<$_TESTBUILDTIME>>'
- if _TESTSAVED ! 0:
- $ROW[2] = ' <h3>This is a saved test result, not a new run.</h3>'
- else
- $ROW[2] = ' <h3>New test run results</h3>'
- end
- $ROW[5] = ' <b>Number of tests executed</b>: <<testCount>>'
- $ROW[6] = ' <b>Number of test passed</b> : <<testPassed>>'
- $ROW[7] = ' <b>Number of test failed</b> : <<testFailed>>'
- $ROW[8] = '<table style="border: 2px solid #000; background: white;">'
- $ROW[9] = '<tr style="border: 2px solid #000; background: white;"><th style="max-width: 15%; border: 2px solid #000; background: white;">Test Name</th><th style="max-width: 30%; border: 1px solid #000; background: white;">Call (location, function)</th><th style="max-width: 25%; border: 1px solid #000; background: white;">Expected</th><th style="max-width: 20%; border: 1px solid #000; background: white;">Actual</th><th style="max-width: 10%; border: 1px solid #000; background: white;">Result</th></tr>'
- size = ARRSIZE('testResults')
- rowindex = ARRSIZE('ROW')
- resultindex = 0
- :testresultprocessloop
- $ROW[rowindex] = '<tr style="padding: 5px; border: 1px solid #000;"><td style="border: 1px solid #000; padding: 10px; margin-right: 10px;">' + $REPLACE($testResults[resultindex], '; ', '</td><td style="border: 1px solid #000; padding: 10px; margin: 0px 10px 0px 10px;">') + '</td></tr>'
- rowindex += 1
- resultindex += 1
- if resultindex < size: jump 'testresultprocessloop'
- $ROW[rowindex] = '</table>'
- size = ARRSIZE('ROW')
- index = 0
- :testresultdisplayloop
- '<<$ROW[index]>>'
- index += 1
- if index < size: jump 'testresultdisplayloop'
- '<hr>'
- *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 --------------------------------
|