123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- # testframework
- _ISTEST = 1
- _TRUE = (0 ! 1)
- _FALSE = (0 = 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
- minut = 30
- 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
- !! $ARGS[1]: the first array
- !! $ARGS[2]: the second array
- !! ARGS[3]: strict order (true / false: 1/0)
- if $ARGS[0] = 'assertEqualsStringArray':
- RESULT = 1
- if ARRSIZE($ARGS[1]) ! ARRSIZE($ARGS[2]):
- RESULT = 0
- else:
- $array_1 = 0
- $array_2 = 0
- elements = ARRSIZE($ARGS[1])
- COPYARR '$array_1', $ARGS[1]
- COPYARR '$array_2', $ARGS[2]
- index = 0
- :array_compare_loop
- pos = ARRPOS('$array_2', $array_1[index])
- if pos = -1:
- RESULT = 0
- elseif ARGS[3] = 1 and pos ! index:
- RESULT = 0
- end
- index += 1
- if index < elements and RESULT ! 0: jump ':array_compare_loop'
- end
- end
- !! $ARGS[1]: name of the array
- !! ARGS[2]: the value we are looking for
- if $ARGS[0] = 'assertNumberIsInArray':
- if $MID($ARGS[1], 1, 1) = '$':
- RESULT = 0
- $ACTUAL_MESSAGE = "'<<$ARGS[1]>>' is a string type array, use 'assertStringIsInArray' not 'assertNumberIsInArray'."
- elseif $ARGS[2] ! '' and ISNUM($ARGS[2]) = 0:
- RESULT = 0
- $ACTUAL_MESSAGE = "'<<$ARGS[1]>> is a numeric type array but <<$ARGS[2]>> is not a number."
- else:
- index = ARRPOS($ARGS[1], ARGS[2])
- if index ! -1:
- $ACTUAL_MESSAGE = "<<ARGS[2]>> was found in array '<<$ARGS[1]>> at index <<index>>."
- RESULT = index ! -1
- else
- $ACTUAL_MESSAGE = "<<ARGS[2]>> was not found in array '<<$ARGS[1]>>."
- RESULT = 0
- end
- end
- 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 'minut'
- 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 --------------------------------
|