Research portable Memory game | Исследовать портируемую игру Память
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cli_test.py 6.1KB

6 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. from cli import *
  2. from memory import *
  3. from memory_Context import *
  4. def cli_test_exit_e(
  5. ) -> str:
  6. c = memory_createContext()
  7. c.input = "e"
  8. c.recentField = "input"
  9. c = cli_exit(c)
  10. if (
  11. c.recentField == "exit"
  12. ):
  13. return "OK: cli_exit_e"
  14. #}
  15. return "ERR: cli_exit_e"
  16. #}
  17. def cli_test_exit_exit(
  18. ) -> str:
  19. c = memory_createContext()
  20. c.input = "exit"
  21. c.recentField = "input"
  22. c = cli_exit(c)
  23. if (
  24. c.recentField == "exit"
  25. ):
  26. return "OK: cli_exit_exit"
  27. #}
  28. return "ERR: cli_exit_e"
  29. #}
  30. def cli_test_exit_victory(
  31. ) -> str:
  32. c = memory_createContext()
  33. c.playfieldSize = 2
  34. c.recentField = "playfieldSize"
  35. c = memory_generateConstPlayfield(c)
  36. # Match the first pair of tiles.
  37. c.input = "1"
  38. c.recentField = "input"
  39. c = cli_selectItem(c)
  40. c = memory_selectItem(c)
  41. c.input = "2"
  42. c.recentField = "input"
  43. c = cli_selectItem(c)
  44. c = memory_selectItem(c)
  45. c = memory_hideMatchingItems(c)
  46. # Match the second pair of tiles.
  47. c.input = "3"
  48. c.recentField = "input"
  49. c = cli_selectItem(c)
  50. c = memory_selectItem(c)
  51. c.input = "4"
  52. c.recentField = "input"
  53. c = cli_selectItem(c)
  54. c = memory_selectItem(c)
  55. c = memory_hideMatchingItems(c)
  56. c = memory_detectVictory(c)
  57. c = cli_reportVictory(c)
  58. c = cli_exit(c)
  59. if (
  60. c.recentField == "exit"
  61. ):
  62. return "OK: cli_exit_victory"
  63. #}
  64. return "ERR: cli_exit_victory"
  65. #}
  66. def cli_test_exit_q(
  67. ) -> str:
  68. c = memory_createContext()
  69. c.input = "q"
  70. c.recentField = "input"
  71. c = cli_exit(c)
  72. if (
  73. c.recentField == "exit"
  74. ):
  75. return "OK: cli_exit_q"
  76. #}
  77. return "ERR: cli_exit_q"
  78. #}
  79. def cli_test_exit_quit(
  80. ) -> str:
  81. c = memory_createContext()
  82. c.input = "quit"
  83. c.recentField = "input"
  84. c = cli_exit(c)
  85. if (
  86. c.recentField == "exit"
  87. ):
  88. return "OK: cli_exit_quit"
  89. #}
  90. return "ERR: cli_exit_quit"
  91. #}
  92. def cli_test_goOn(
  93. ) -> str:
  94. c = memory_createContext()
  95. c.playfieldSize = 2
  96. c.recentField = "playfieldSize"
  97. c = memory_generateConstPlayfield(c)
  98. # Match the first pair of items.
  99. c.input = "1"
  100. c.recentField = "input"
  101. c = cli_selectItem(c)
  102. c = memory_selectItem(c)
  103. c.input = "2"
  104. c.recentField = "input"
  105. c = cli_selectItem(c)
  106. c = memory_selectItem(c)
  107. c = memory_hideMatchingItems(c)
  108. c = cli_reportMatchedItems(c)
  109. c = cli_goOn(c)
  110. if (
  111. c.recentField == "outputGoOn"
  112. ):
  113. return "OK: cli_goOn"
  114. #}
  115. return "ERR: cli_goOn"
  116. #}
  117. def cli_test_greetUser(
  118. ) -> str:
  119. c = memory_createContext()
  120. c.didLaunch = True
  121. c.recentField = "didLaunch"
  122. c = cli_greetUser(c)
  123. if (
  124. c.recentField == "outputGreeting"
  125. ):
  126. return "OK: cli_greetUser"
  127. #}
  128. return "ERR: cli_greetUser"
  129. #}
  130. def cli_test_promptSecondItemSelection(
  131. ) -> str:
  132. c = memory_createContext()
  133. c.input = "1"
  134. c.recentField = "input"
  135. c = cli_selectItem(c)
  136. c = memory_selectItem(c)
  137. c = cli_promptSecondItemSelection(c)
  138. if (
  139. c.recentField == "outputPromptSelection"
  140. ):
  141. return "OK: cli_promptSecondItemSelection"
  142. #}
  143. return "ERR: cli_promptSecondItemSelection"
  144. #}
  145. def cli_test_reportMatchedItems(
  146. ) -> str:
  147. c = memory_createContext()
  148. c.playfieldSize = 2
  149. c.recentField = "playfieldSize"
  150. c = memory_generateConstPlayfield(c)
  151. c.input = "1"
  152. c.recentField = "input"
  153. c = cli_selectItem(c)
  154. c = memory_selectItem(c)
  155. c.input = "2"
  156. c.recentField = "input"
  157. c = cli_selectItem(c)
  158. c = memory_selectItem(c)
  159. c = memory_hideMatchingItems(c)
  160. c = cli_reportMatchedItems(c)
  161. if (
  162. c.recentField == "outputMatchedItems"
  163. ):
  164. return "OK: cli_reportMatchedItems"
  165. #}
  166. return "ERR: cli_reportMatchedItems"
  167. #}
  168. def cli_test_reportMismatchedItems(
  169. ) -> str:
  170. c = memory_createContext()
  171. c.playfieldSize = 2
  172. c.recentField = "playfieldSize"
  173. c = memory_generateConstPlayfield(c)
  174. c.input = "1"
  175. c.recentField = "input"
  176. c = cli_selectItem(c)
  177. c = memory_selectItem(c)
  178. c.input = "3"
  179. c.recentField = "input"
  180. c = cli_selectItem(c)
  181. c = memory_selectItem(c)
  182. c = memory_detectMismatchedItems(c)
  183. c = cli_reportMismatchedItems(c)
  184. if (
  185. c.recentField == "outputMismatchedItems"
  186. ):
  187. return "OK: cli_reportMismatchedItems"
  188. #}
  189. return "ERR: cli_reportMismatchedItems"
  190. #}
  191. def cli_test_selectItem(
  192. ) -> str:
  193. c = memory_createContext()
  194. c.input = "1"
  195. c.recentField = "input"
  196. c = cli_selectItem(c)
  197. if (
  198. c.recentField == "selectedId" and
  199. c.selectedId == 0
  200. ):
  201. return "OK: cli_selectItem"
  202. #}
  203. return "ERR: cli_selectItem"
  204. #}
  205. def cli_test_showHelp_h(
  206. ) -> str:
  207. c = memory_createContext()
  208. c.input = "h"
  209. c.recentField = "input"
  210. c = cli_showHelp(c)
  211. if (
  212. c.recentField == "outputHelp"
  213. ):
  214. return "OK: cli_showHelp_h"
  215. #}
  216. return "ERR: cli_showHelp_h"
  217. #}
  218. def cli_test_showHelp_help(
  219. ) -> str:
  220. c = memory_createContext()
  221. c.input = "help"
  222. c.recentField = "input"
  223. c = cli_showHelp(c)
  224. if (
  225. c.recentField == "outputHelp"
  226. ):
  227. return "OK: cli_showHelp_help"
  228. #}
  229. return "ERR: cli_showHelp_help"
  230. #}
  231. def cli_test_reportVictory(
  232. ) -> str:
  233. c = memory_createContext()
  234. c.playfieldSize = 2
  235. c.recentField = "playfieldSize"
  236. c = memory_generateConstPlayfield(c)
  237. # Match the first pair of tiles.
  238. c.input = "1"
  239. c.recentField = "input"
  240. c = cli_selectItem(c)
  241. c = memory_selectItem(c)
  242. c.input = "2"
  243. c.recentField = "input"
  244. c = cli_selectItem(c)
  245. c = memory_selectItem(c)
  246. c = memory_hideMatchingItems(c)
  247. # Match the second pair of tiles.
  248. c.input = "3"
  249. c.recentField = "input"
  250. c = cli_selectItem(c)
  251. c = memory_selectItem(c)
  252. c.input = "4"
  253. c.recentField = "input"
  254. c = cli_selectItem(c)
  255. c = memory_selectItem(c)
  256. c = memory_hideMatchingItems(c)
  257. c = memory_detectVictory(c)
  258. c = cli_reportVictory(c)
  259. if (
  260. c.recentField == "outputVictory"
  261. ):
  262. return "OK: cli_reportVictory"
  263. #}
  264. return "ERR: cli_reportVictory"
  265. #}
  266. #def cli_test_shouldReportIvalidItemSelection_outOfBoundsMin(
  267. #) -> str:
  268. # c = cli_createContext()
  269. # c.cMemory = memory_createContext()
  270. # c.input = "0"
  271. # c = cli_selectItem(c)
  272. # c = cli_shouldReportInvalidItemSelection(c)
  273. # if (
  274. # c.recentField == "outputInvalidItemSelection"
  275. # ):
  276. # return "OK: cli_shouldReportInvalidItemSelection"
  277. # #}
  278. # return "ERR: cli_shouldReportInvalidItemSelection"
  279. ##}
  280. #