1
0

testframework.qsrc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. # testframework
  2. _ISTEST = 1
  3. !! Set up the date, the player character basic attributes, etc.
  4. if $ARGS[0] = 'testsetup':
  5. daystart = 0
  6. month = 8
  7. $month = 'August'
  8. day = 26
  9. week = 5
  10. hour = 9
  11. birthyear = 1999
  12. birthmonth = 4
  13. birthday = 1
  14. pcs_haircol = 1
  15. pcs_eyesize = 2
  16. pcs_lip = 1
  17. pcs_lashes = 1
  18. !! Body
  19. pcs_hgt = 170
  20. pcs_teeth = 0
  21. pcs_butt = 8
  22. pcs_skin = 500
  23. !! Stats
  24. pcs_stren = 35
  25. strenbuf = 10
  26. pcs_agil = 35
  27. agilbuf = 10
  28. pcs_vital = 35
  29. vitalbuf = 10
  30. pcs_intel = 35
  31. pcs_sprt = 35
  32. pcs_react = 35
  33. pcs_chrsm = 35
  34. pcs_prcptn = 35
  35. pcs_magik = 0
  36. $pcs_firstname = "Svetlana"
  37. $pcs_lastname = "Lebedev"
  38. $pcs_nickname = "Sveta"
  39. end
  40. !! Asserts that the two strings passed in $ARGS[1] and $ARGS[2] are equal.
  41. if $ARGS[0] = 'assertEqualsString':
  42. RESULT = $ARGS[1] = $ARGS[2]
  43. end
  44. !! Asserts that the two numbers passed in ARGS[1] and ARGS[2] are equal.
  45. if $ARGS[0] = 'assertEqualsNumber':
  46. RESULT = ARGS[1] = ARGS[2]
  47. end
  48. !! Asserts that the two Arrays passed in $ARGS[1] and $ARGS[2] are equal.
  49. !! The two parameters are the Array variable names
  50. if $ARGS[0] = 'assertEqualsStringArray':
  51. RESULT = ARRSIZE($ARGS[1]) = ARRSIZE($ARGS[2])
  52. end
  53. if $ARGS[0] = 'addTestResult':
  54. $testResults[testCount] = "<<$TESTNAME>>; gs '<<$LOCATIONNAME>>', '<<$FUNCTIONNAME>>'" + iif($ARGUMENTS ! '', ', <<$ARGUMENTS>>', '') + "; <<$EXPECTED_MESSAGE>>; <<$ACTUAL_MESSAGE>>; "
  55. if TESTRESULT ! 0:
  56. $testResults[testCount] += '<font style="color: green;"><b>S</b></font>'
  57. testPassed += 1
  58. else
  59. $testResults[testCount] += '<font style="color: red;"><b>F</b></font>'
  60. testFailed += 1
  61. end
  62. testCount += 1
  63. end
  64. if $ARGS[0] = 'displayTestResults':
  65. $ROW[0] = '<h1>Test results for TestSuite: <<$_TESTSUITE>></h1>'
  66. $ROW[1] = ' <b>Test built</b>: <<$_TESTBUILDTIME>>'
  67. if _TESTSAVED ! 0:
  68. $ROW[2] = ' <h3>This is a saved test result, not a new run.</h3>'
  69. else
  70. $ROW[2] = ' <h3>New test run results</h3>'
  71. end
  72. $ROW[5] = ' <b>Number of tests executed</b>: <<testCount>>'
  73. $ROW[6] = ' <b>Number of test passed</b> : <<testPassed>>'
  74. $ROW[7] = ' <b>Number of test failed</b> : <<testFailed>>'
  75. $ROW[8] = '<table style="border: 2px solid #000; background: white;">'
  76. $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>'
  77. size = ARRSIZE('testResults')
  78. rowindex = ARRSIZE('ROW')
  79. resultindex = 0
  80. :testresultprocessloop
  81. $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>'
  82. rowindex += 1
  83. resultindex += 1
  84. if resultindex < size: jump 'testresultprocessloop'
  85. $ROW[rowindex] = '</table>'
  86. size = ARRSIZE('ROW')
  87. index = 0
  88. :testresultdisplayloop
  89. '<<$ROW[index]>>'
  90. index += 1
  91. if index < size: jump 'testresultdisplayloop'
  92. '<hr>'
  93. *nl
  94. end
  95. if $ARGS[0] = 'saveTestResults':
  96. gs 'testframework', 'cleanUpTestData'
  97. _TESTSAVED = 1
  98. savegame '<<$_TESTSUITE>>-Results-<<$_TESTFILETIME>>.test'
  99. end
  100. if $ARGS[0] = 'cleanUpDefault':
  101. killvar 'ARGUMENTS'
  102. killvar 'EXPECTED'
  103. killvar 'EXPECTED_MESSAGE'
  104. killvar 'ACTUAL'
  105. killvar 'ACTUAL_MESSAGE'
  106. killvar 'FUNCTIONNAME'
  107. killvar 'TESTRESULT'
  108. killvar 'daystart'
  109. killvar 'month'
  110. killvar '$month'
  111. killvar 'day'
  112. killvar 'week'
  113. killvar 'hour'
  114. killvar 'birthyear'
  115. killvar 'birthmonth'
  116. killvar 'birthday'
  117. killvar 'pcs_haircol'
  118. killvar 'pcs_eyesize'
  119. killvar 'pcs_lip'
  120. killvar 'pcs_lashes'
  121. !! Body
  122. killvar 'pcs_hgt'
  123. killvar 'pcs_teeth'
  124. killvar 'pcs_butt'
  125. killvar 'pcs_skin'
  126. !! Stats
  127. killvar 'pcs_stren'
  128. killvar 'strenbuf'
  129. killvar 'pcs_agil'
  130. killvar 'agilbuf'
  131. killvar 'pcs_vital'
  132. killvar 'vitalbuf'
  133. killvar 'pcs_intel'
  134. killvar 'pcs_sprt'
  135. killvar 'pcs_react'
  136. killvar 'pcs_chrsm'
  137. killvar 'pcs_prcptn'
  138. killvar 'pcs_magik'
  139. killvar 'pcs_firstname'
  140. killvar 'pcs_lastname'
  141. killvar 'pcs_nickname'
  142. end
  143. --- testframework --------------------------------