home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pilot.zip / test.pil < prev   
Text File  |  1993-08-18  |  12KB  |  432 lines

  1. R:                              TEST
  2. R:
  3. R: This is a test program that contains a number of specific function
  4. R: tests for the Pilot interpreter.  It prompts the user for a particular
  5. R: type of test and then performs the test accordingly.  At the end of
  6. R: each test it returns to the main menu.
  7. R:
  8. R: (C) Copyright 1985, Dave Taylor
  9.  
  10. *menu
  11. R: keep track of reprompts to redisplay menu every so often...
  12. C: #attempts = 0
  13.  
  14. T:
  15.  :
  16.  :                          PILOT TEST PROGRAM
  17.  :
  18.  :  This program allows you to test and verify the functionality of the
  19.  :   current pilot interpreter.  If any of the tests fail unexpectedly
  20.  :      then there is some sort of defect in the actual interpreter!
  21.  :
  22.  :  Please select an area you'd like to test out by the associated number:
  23.  :
  24.  :    1 = Numerical input/output
  25.  :    2 = Mathematical calculations
  26.  :    3 = Conditional expressions
  27.  :    4 = String input/output
  28.  :    5 = String alterations
  29.  :    6 = Looping
  30.  :    7 = Subroutine calls
  31.  :    8 = Invalid and badly structured statements
  32.  :    9 = A conglomeration of the above sections
  33.  :   10 = Quit this program entirely.
  34. *reprompt
  35.  :
  36.  :  Please enter your choice;
  37. A: $choice
  38.  
  39. R: sort of case statement...
  40. M : 10
  41. TY:
  42.   : Bye!
  43. EY:
  44. M : 1
  45. JY: *numerical_io
  46. M : 2
  47. JY: *numerical_calc
  48. M : 3
  49. JY: *conditionals
  50. M : 4
  51. JY: *string_io
  52. M : 5
  53. JY: *string_alt
  54. M : 6
  55. JY: *looping
  56. M : 7
  57. JY: *subroutines
  58. M : 8
  59. JY: *bad_statements
  60. M : 9
  61. JY: *conglomeration
  62.  
  63. T : I can't understand your choice.  Please choose another!
  64. C : #attempts = #attempts + 1
  65. J(#attempts < 3): *reprompt
  66. J : *menu
  67.  
  68. *numerical_io
  69.  
  70. T :
  71.   : This routine tests the numerical input and output sections.
  72.   :
  73.   : Warning: if an invalid number is entered it will cause a FATAL
  74.   : error and stop the entire program!!
  75.  
  76. *num_io_top
  77.   :
  78.   : Please enter a positive, non-zero integer value
  79. A : #positive
  80. T(#positive <= 0): A -> POSITIVE NON-ZERO <- value!!  Try again!
  81. J(#positive <= 0): *num_io_top
  82.  
  83. *num_io_middle
  84. T :
  85.   : Now enter the number zero, please...
  86. A : #zero
  87. T(#zero <> 0): -> The number ZERO <- please!!  Try again!
  88. J(#zero <> 0): *num_io_middle
  89.  
  90. *num_io_bottom
  91. T :
  92.   : Finally, please enter a negative number
  93. A : #negative
  94. T(#negative >= 0): A -> NEGATIVE <- number, thank you!  Try again!
  95. J(#negative >= 0): *num_io_bottom
  96.  
  97. T :
  98.   : Okay, we've got all three numbers now.  Just to make sure I really
  99.   :   did get them all, you entered #positive, #zero, then #negative,
  100.   :   right?
  101. A : $answer
  102. M : Y y yes YES yup indeed true correct right exactly uh huh
  103. TY: I thought so.
  104. TN: You aren't telling the truth you silly person!  I'm a computer - I
  105. TN: don't lie ever!! (besides I'd get in trouble if I did from Ma Bell!)
  106. T :
  107.   : Please press <return> when you're ready to go back to the main menu.
  108. A : $answer
  109. J : *menu
  110.  
  111. *numerical_calc
  112.  
  113. T :
  114.   : This section tests the calculation ability of the Pilot interpreter.
  115.   :
  116.   : I'll first ask you for a couple of numbers and then do some amazing
  117.   : (relatively speaking) things with them!  Beware, however, if you
  118.   : type in an invalid number then I'll just give a FATAL error and stop!
  119.   :
  120.   : Please enter a number
  121. A : #num1
  122. T :    and another one
  123. A : #num2
  124. T :
  125.   : Okay!  Now let's see...
  126. C : #sum = #num1 + #num2
  127. C : #diff = #num1 - #num2
  128. C : #diff2 = #num2 - #num1
  129. T : #num1 + #num2 = #sum, #num1 - #num2 = #diff and #num2 - #num1 = #diff2
  130. C : #product = #num1 * #num2
  131. C : #value = (#num1+#num1)*(#num2+#num2)
  132. T : #num1 * #num2 = #product, (#num1+#num1)*(#num2+#num2) = #value
  133. C(#num2 <> 0): #div = #num1 / #num2
  134. T(#num2 <> 0): Not only that, but #num1 / #num2 = #div!  Pretty good, eh?
  135. T(#num2 = 0): (I was going to divide, but since the second number is zero it'd
  136.         : fail so I'll just forget the division test.  You can still try
  137.         : again by re-running this test if you really want to!!)
  138. T :
  139.   : Phew!  That's enough math for ANY computer to do at one time!!
  140.   :
  141.   : When you're ready to go back to the main menu press <return>!
  142. A : $answer
  143. J : *menu
  144.  
  145. *conditionals
  146.  
  147. T :
  148.   : This section tests the conditional evaluation section of the Pilot
  149.   : interpreter.  As always, if an improperly typed number is entered I
  150.   : will fail with a FATAL error and stop.
  151.   :
  152.   : You'll be entering three numbers before I start the test...
  153.   :
  154.   : Enter the first number
  155. A : #num1
  156. T :  the second number
  157. A : #num2
  158. T :  and the third number
  159. A : #num3
  160. T :
  161.   : Okay!  Now we can start some testing!!
  162.   :
  163.   : The following statements should all list valid conditions.  If not,
  164.   : then the interpreter is incorrectly solving conditionals!!
  165.   :
  166. T(#num1 < 0) : The first number entered is less than zero
  167. T(#num1 = 0) : The first number is equal to zero
  168. T(#num1 > 0) : The first number is greater than zero
  169. T(#num1 < #num2) : The first number is less than the second number
  170. T(#num1 = #num2) : The first number is equal to the second number
  171. T(#num1 > #num2) : The first number is greater than the second number
  172. T(#num1 < #num2+#num3) : The first number is less than the second + third
  173. T(#num1 = #num2+#num3) : The first number is equal to the second + third
  174. T(#num1 > #num2+#num3) : The first number is greater than the second + third
  175. T(#num1*#num2 < #num3*10) : The first * second is less than the third * 10
  176. T(#num1*#num2 = #num3*10) : The first * second is less than the third * 10
  177. T(#num1*#num2 > #num3*10) : The first * second is less than the third * 10
  178. T(#num1): The first number entered, #num1, is non-zero
  179. T :
  180.   : That's probably enough for now.  Hope it all worked out okay!!
  181.   :
  182.   : Please press <return> when you're ready to return to the menu.
  183. A : $answer
  184. J : *menu
  185.  
  186. *string_io
  187. T :
  188.   : This section tests the string input and output routines.
  189.   :
  190.   : Please enter your first name
  191. A : $first_name
  192. T : Your first name is $first_name?  I find that hard to believe!  Try
  193.   : another name - maybe I'll like it better...
  194. A : $first_name
  195. T : Okay.  I guess $first_name is okay.  I'd rather be called Computer,
  196.   : though.  I guess there's no accounting for tastes, eh?
  197.   :
  198.   : Please press <return> when you're ready to return to the main menu
  199. A : $answer
  200. J : *menu
  201.  
  202. *string_alt
  203.  
  204. T :
  205.   : This section tests the string computation statements.  It's real
  206.   : easy - just enter a word
  207. A : $word1
  208.   : and now another word
  209. A : $word2
  210. C : $normal = $word1 $word2
  211. C : $backwards = $word2 $word1
  212. C : $squashed = $word1$word2
  213. C : $filler = word $word1 is word one and word $word2 is word two.
  214. T :
  215.   : Okay:
  216.   :   one after the other: $normal
  217.   :       backwards order: $backwards
  218.   :              squashed: $squashed
  219.   : and: $filler
  220.   :
  221.   : Wasn't that easy?  Press <return> when you're ready to go back to the menu.
  222. A : $answer
  223. J : *menu
  224.  
  225. *looping
  226.  
  227. T :
  228.   : This section tests the looping ability of the program.  What we'll do is
  229.   : count up from one to ten looping each time...beware, though, if your disk
  230.   : is slow this might be a bit tedious!  (see if you can count faster than
  231.   : me in the meantime!!)
  232.   :
  233.   : Ready?  Here we go!
  234. C : #value = 1
  235.  
  236. *counting_loop
  237.  
  238. T : --- #value ----
  239. C : #value = #value + 1
  240. J(#value<11): *counting_loop
  241. T :
  242.   : Okay!  That was lots of fun!  Back to the menu now, though, once you
  243.   : press <return>
  244. A : $answer
  245. J : *menu
  246.  
  247. *subroutines
  248.  
  249. T :
  250.   : This section tests the ability of the Pilot interpreter to call and
  251.   : return from subroutines.  If it is working correctly it should output
  252.   :    subroutine 1
  253.   :       subroutine 2
  254.   :    subroutine 1
  255.   :       subroutine 3
  256.   :          subroutine 4
  257.   :    subroutine 1
  258.   : and then be done.  Here we go.....
  259.   :
  260. U : *subroutine1
  261. T :
  262.   : If you got here it must have worked okay!  That's good.
  263.   : When you're ready to continue, please press <return>
  264. A : $answer
  265. J : *menu
  266.  
  267. *subroutine1
  268.  
  269. T :   subroutine 1
  270. U : *subroutine2
  271. T :   subroutine 1
  272. U : *subroutine3
  273. T :   subroutine 1
  274. E :
  275.  
  276. *subroutine2
  277.  
  278. T :     subroutine 2
  279. E :
  280.  
  281. *subroutine3
  282.  
  283. T :     subroutine 3
  284. U : *subroutine4
  285. E :
  286.  
  287. *subroutine4
  288.  
  289. T :       subroutine 4
  290. E :
  291.  
  292. *conglomeration
  293.  
  294. T:
  295.  : Rather than a boring test like all the others, this test is
  296.  : actually a simple game for you to play...
  297.  :
  298.  : First off, though, please enter a number between -10000 and 10000
  299. A: #seed
  300. T:
  301.  : Okay!
  302.  :
  303.  :
  304.  : This is a number guessing game.  The object is for you to guess the number
  305.  : between 1 and 100 that I've choosen in the minimum guesses.  I'll give you
  306.  : an indication of total guesses + average number of guesses after each turn.
  307.  :
  308.  : Ready?
  309.  :
  310.  
  311. *top
  312.  
  313. U: *select_number
  314. C: #guesses = 0
  315. T:
  316.  : I've choosen a new number
  317.  
  318. *guess_loop
  319.  
  320. T:
  321. T: Your guess?
  322. A: #guess
  323. C: #guesses = #guesses + 1
  324. J(#guess = #number): *correct
  325. T(#guess < #number):
  326.            : That's too low!  Try again!
  327. T(#guess > #number):
  328.            : That's too high!  Try again!
  329. T(#guesses = 3):
  330.            : Having problems?
  331. T(#guesses = 5):
  332.            : You getting confused?
  333. T(#guesses = 7):
  334.            : You're lost, admit it!
  335. T(#guesses = 9):
  336.            : Keep going - you'll be able to try every number between
  337.                : 1 and 100 at this rate!!
  338. T(#guesses >10):
  339.            : Why bother?  You're never going to get it at this rate!
  340. J: *guess_loop
  341.  
  342. *correct
  343.  
  344. T(#guesses = 1):
  345.            : Incredible!  You got it in one Guess!
  346. T(#guesses > 1):
  347.                : You got it!  In #guesses guesses!
  348. C: #total_guesses = #total_guesses + #guesses
  349. C: #total_games = #total_games + 1
  350. C: #average = #total_guesses / #total_games
  351. T(#total_games > 1):
  352.                    : That's given you an average of #average guesses per turn
  353. T:
  354.  : Would you like to play again?
  355. A: $answer
  356. M: y Y yes YES yup please
  357. TN:
  358.   : Okay.  Back to the main menu with you!
  359. JN: *menu
  360.  
  361. J: *top
  362.  
  363. *select_number
  364.  
  365. R: This subroutine does some magical stuff to a given seed and
  366. R: generates a number between one and one-hundred, modifying
  367. R: the seed as it goes along.  It returns it's value in #number.
  368.  
  369. C(#seed < 0): #seed = #seed * -2
  370. C(#seed = 0): #seed = 4324
  371. C: #seed = #seed * 83 / 5
  372. C: #seed = (#seed-2425)/3
  373.  
  374. *loop
  375.  
  376. C(#seed < 1): #seed = #seed*-3+516
  377. C(#seed = 0): #seed = 9543
  378. C(#seed > 100): #seed = #seed/43
  379. J(#seed < 1): *loop
  380. J(#seed > 100): *loop
  381. C: #number = #seed
  382. E:
  383.  
  384. *bad_statements
  385.  
  386. R : This is at the end of the program so we don't keep hitting the
  387. R : duplicate label error on the deliberately duplicated label on
  388. R : one of the lines below!
  389.  
  390. T :
  391.   : This section is going to be a bit different from the others, so stay
  392.   : calm.  We are going to try to generate as many non-fatal error messages
  393.   : as possible...and see if they are dealt with correctly.
  394.   :
  395.   : Ready or not here we go!
  396.   :
  397.   : The first error should be "Unknown statement"
  398. ? : total trash
  399. T : The next error should be "Bad identifier: 'junk'"
  400. A : junk
  401. T : The next error should be "Badly formed instruction"
  402. C
  403. T : The next error should be "duplicate label 'bad_statements'"
  404. *bad_statements
  405. R: T : The next error should be "Name 'nametoolongforme' too long"
  406. R: T : #nametoolongformetodealwithinareasonablefashion
  407. T : The next error should be "Undefined Variable: 'wierd_var'"
  408. T : #wierd_var
  409. T :
  410.   : Ready for some more?  Press <return> when you're ready!
  411. A : $answer
  412. T :
  413. T : The next error should be "Badly formed expression: parenthesis"
  414. C : #num1 = ((4+5
  415. T : The next error should be "Badly formed expression"
  416. C : #num1 = 4+
  417. T : The next error should be "Bad left-hand-side of expression"
  418. C : junk = 2
  419. T : The next error should be "Missing or misplaced '=' in expression"
  420. C : #num1 * 3
  421. T : The next error should be "String variable in numerical expression"
  422. C : #num1= $answer + 3
  423. T : The next error should be "Bad relational expression"
  424. T(#num1:
  425. T :
  426.   : That's all of them!  I hope that wasn't too bewildering!!
  427.   :
  428.   : When you've recovered enough to want to go back to the main menu
  429.   : please press <return>
  430. A : $answer
  431. J : *menu
  432.