home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / ppw1320.zip / rexx4ppw.zip / rexx4ppw.rex
OS/2 REXX Batch file  |  2001-10-31  |  6KB  |  227 lines

  1. /*
  2.  * Generator   : PPWIZARD version 01.303
  3.  *             : FREE tool for Windows, OS/2, DOS and UNIX by Dennis Bareis (dbareis@labyrinth.net.au)
  4.  *             : http://www.labyrinth.net.au/~dbareis/ppwizard.htm
  5.  * Time        : Wednesday, 31 Oct 2001 7:00:03pm
  6.  * Input File  : C:\DBAREIS\Projects\MultiOs\PPWIZARD\rexx4ppw.x
  7.  * Output File : out\rexx4ppw.RE_
  8.  */
  9.  
  10. if arg(1)="!CheckSyntax!" then exit(21924)
  11.  
  12. PgmVersion = "01.304"
  13. Failed = 0
  14. Passed = 0
  15. say '[]-------------------------------------------------------------------------[]'
  16. say '| REXX4PPW.CMD: Version ' || PgmVersion || ' (C)opyright Dennis Bareis 1999               |'
  17. say '| http://www.labyrinth.net.au/~dbareis/index.htm (dbareis@labyrinth.net.au) |'
  18. say '[]-------------------------------------------------------------------------[]'
  19. say ''
  20. call CheckCmdLineParameters arg(1), arg(2)
  21. call ShowParseVersion
  22. call ShowParseSource
  23. call ShowCharacterEncoding
  24. call ShowAddress
  25. call TestVarLength
  26. call TestUNAME
  27. call TestStreamQueryExists
  28. call TestSleepCmd
  29. call TestEnvironment
  30. call TestInterpret
  31. call TestSimpleCmds
  32. say ''
  33. say 'SUMMARY'
  34. say '~~~~~~~'
  35. if Failed = 0 then
  36. say 'All ' || Passed || ' tests passed'
  37. else
  38. say 'Failed ' || Failed || ' tests, passed ' || passed || ' tests'
  39. exit(Failed)
  40.  
  41. CheckCmdLineParameters:
  42. if arg(2) <> '' then
  43. call Fail 'Have value of "' || arg(2) || ' in arg(2)'
  44. else
  45. do
  46. ExpectedArgs = "TEST REXX"
  47. if  translate(arg(1)) = ExpectedArgs then
  48. call Pass 'Command line parameters are OK'
  49. else
  50. do
  51. call Fail 'Expected arg(1) = "' || ExpectedArgs || '", not "' || arg(1) || '"!'
  52. say 'NOTE'
  53. say '~~~~'
  54. say 'You should start this program with the command:'
  55. say ''
  56. say '   rexx4ppw TEST REXX'
  57. say ''
  58. say 'If you didn''t then please restart the test and add the parameters!'
  59. say ''
  60. end
  61. end
  62. return
  63.  
  64. ShowParseSource:
  65. parse source Result
  66. call Info 'Parse SOURCE  = "' || Result || '"'
  67. return
  68.  
  69. ShowParseVersion:
  70. parse version Result
  71. call Info 'Parse VERSION = "' || Result || '"'
  72. return
  73.  
  74. ShowAddress:
  75. call Info 'ADDRESS()     = "' || address() || '"'
  76. return
  77.  
  78. ShowCharacterEncoding:
  79. if  '1' = 'F1'x then
  80. Encoding = "EBCDIC"
  81. else
  82. Encoding = "ASCII"
  83. call Info 'CHAR ENCODING = "' || Encoding || '"'
  84. return
  85.  
  86. TestInterpret:
  87. NlOk = TestNewLineInInterpret()
  88. if  NlOk = 'Y' then
  89. Sep = d2c(10)
  90. else
  91. Sep = ';'
  92. Fred      = 0
  93. SingleCmd = 'Fred = Fred + 1' || Sep
  94. lSingleCmd= length(SingleCmd)
  95. TestF = 50
  96. TestT = 10000
  97. OkLng = 0
  98. signal on SYNTAX  name TrapTestInterpretLng
  99. do MaxLng = TestF to TestT by 50
  100. ReqCnt  = MaxLng % lSingleCmd
  101. RealLng = ReqCnt * lSingleCmd
  102. interpret copies(SingleCmd, ReqCnt)
  103. OkLng =  RealLng
  104. end
  105. call INFO 'Tested interpret length from ' || TestF || ' to ' || TestT || ', All OK'
  106. return
  107.  
  108. TrapTestInterpretLng:
  109. call INFO 'Biggest Interpret length was ' || OkLng || ', failed on ' || RealLng || ' bytes'
  110. return
  111.  
  112. TestNewLineInInterpret:
  113. Fred     = 1
  114. RexxCmds = 'Fred = Fred + 1'
  115. RexxCmds = RexxCmds || d2c(10) || RexxCmds
  116. signal on SYNTAX  name TrapTestNewLineInInterpret
  117. interpret RexxCmds
  118. if  Fred = 3 then
  119. do
  120. call INFO "interpret cmd takes multiple commands seperated by NewLines"
  121. return('Y')
  122. end
  123. call FAIL 'interpret cmd did not die (from NewLines), however FRED = "' || Fred || '"!'
  124. return('N')
  125.  
  126. TrapTestNewLineInInterpret:
  127. call INFO 'interpret cmd does not like imbedded newlines'
  128. return('N')
  129.  
  130. TestVarLength:
  131. FoundBad = 0
  132. MaxTest  = 2000
  133. do  Index = 1 to MaxTest
  134. Var = copies('A', Index)
  135. if  symbol(Var) = 'BAD' then
  136. do
  137. FoundBad = Index
  138. leave
  139. end
  140. end
  141. if  FoundBad = 0 then
  142. call Info 'Tried variable name lengths from 1 to ' || MaxTest || ', all OK'
  143. else
  144. call Info 'Max variable name length is ' || FoundBad-1
  145. return
  146.  
  147. TestSleepCmd:
  148. call Info 'Testing for Sleep() function'
  149. signal on SYNTAX  name TrapTestSleepCmd
  150. call time 'R'
  151. call Sleep 3
  152. call PASS 'Seem to have a sleep(), did it sleep for 3 seconds? (Elapsed=' || time('E') || ')'
  153. return
  154.  
  155. TrapTestSleepCmd:
  156. call FAIL 'No function called Sleep(), or takes different parms'
  157. return
  158.  
  159. TestStreamQueryExists:
  160. call Info 'Testing for Stream("query exists") function'
  161. signal on SYNTAX  name TrapTestStreamQueryExists
  162. FullName = stream('rexx4ppw.rex', 'c', 'query exists')
  163. call PASS 'Seem to have a stream("query exists") - FULLNAME= "' || FullName || '"'
  164. return
  165.  
  166. TrapTestStreamQueryExists:
  167. call FAIL 'Died trying a stream("query exists")'
  168. return
  169.  
  170. TestUNAME:
  171. call Info 'Testing for uname() function'
  172. signal on SYNTAX  name TrapTestUnameCmd
  173. UnameValue = uname()
  174. call INFO 'uname() exists, RETURNED: ' || UnameValue
  175. return
  176.  
  177. TrapTestUnameCmd:
  178. call INFO 'uname() does not exist.'
  179. return
  180.  
  181. TestEnvironment:
  182. call TryEnv 'OS2ENVIRONMENT'
  183. call TryEnv 'ENVIRONMENT'
  184. call TryEnv 'SYSTEM'
  185. return
  186.  
  187. TryEnv:
  188. TestValue = "TestValue"
  189. signal on SYNTAX  name TrapTryEnv
  190. call value "REXX4PPW", TestValue, arg(1)
  191. BackFromEnv = value("REXX4PPW",,  arg(1))
  192. if  BackFromEnv = TestValue then
  193. call Info 'Environment is addressed by "' || arg(1) || '"'
  194. else
  195. call Info 'Addressed Environment by "' || arg(1) || '", no syntax error but got wrong value of "' || BackFromEnv || '"'
  196. return
  197.  
  198. TrapTryEnv:
  199. call Info 'Environment not addressed by "' || arg(1) || '"'
  200. return
  201.  
  202. TestSimpleCmds:
  203. say 'DIR'
  204. say '~~~'
  205. 'dir'
  206. say 'LS'
  207. say '~~'
  208. 'ls'
  209. say 'FIND --help'
  210. say '~~~~~~~~~~~'
  211. 'find --help'
  212. return
  213.  
  214. Info:
  215. say 'INFO: ' || arg(1)
  216. return
  217.  
  218. Fail:
  219. say 'FAIL: ' || arg(1)
  220. Failed = Failed + 1
  221. return
  222.  
  223. Pass:
  224. say 'PASS: ' || arg(1)
  225. Passed = Passed + 1
  226. return
  227.