Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. # Test suite (for verifying correctness)
  2. #
  3. # The test suite is a list of 5- or 3-tuples.  The 5 parts of a
  4. # complete tuple are:
  5. # element 0: a string containing the pattern
  6. #         1: the string to match against the pattern
  7. #         2: the expected result (0 - SUCCEED, 1 - FAIL, 2 - SYNTAX_ERROR)
  8. #         3: a string that will be eval()'ed to produce a test string.
  9. #            This is an arbitrary Python expression; the available
  10. #            variables are "found" (the whole match), and "g1", "g2", ...
  11. #            up to "g10" contain the contents of each group, or the
  12. #            string 'None' if the group wasn't given a value.
  13. #         4: The expected result of evaluating the expression.
  14. #            If the two don't match, an error is reported.
  15. #
  16. # If the regex isn't expected to work, the latter two elements can be omitted.
  17.  
  18. # test suite for search
  19. search_regex_tests=[
  20. ['abc', 'abc', 0, 'found', 'abc'],
  21. ['abc', 'xbc', 1],
  22. ['abc', 'axc', 1],
  23. ['abc', 'abx', 1],
  24. ['abc', 'xabcy', 0, 'found', 'abc'],
  25. ['abc', 'ababc', 0, 'found', 'abc'],
  26. ['ab*c', 'abc', 0, 'found', 'abc'],
  27. ['ab*bc', 'abc', 0, 'found', 'abc'],
  28. ['ab*bc', 'abbc', 0, 'found', 'abbc'],
  29. ['ab*bc', 'abbbbc', 0, 'found', 'abbbbc'],
  30. ['ab+bc', 'abbc', 0, 'found', 'abbc'],
  31. ['ab+bc', 'abc', 1],
  32. ['ab+bc', 'abq', 1],
  33. ['ab+bc', 'abbbbc', 0, 'found', 'abbbbc'],
  34. ['ab?bc', 'abbc', 0, 'found', 'abbc'],
  35. ['ab?bc', 'abc', 0, 'found', 'abc'],
  36. ['ab?bc', 'abbbbc', 1],
  37. ['ab?c', 'abc', 0, 'found', 'abc'],
  38. ['^abc$', 'abc', 0, 'found', 'abc'],
  39. ['^abc$', 'abcc', 1],
  40. ['^abc', 'abcc', 0, 'found', 'abc'],
  41. ['^abc$', 'aabc', 1],
  42. ['abc$', 'aabc', 0, 'found', 'abc'],
  43. ['^', 'abc', 0, 'found+"-"', '-'],
  44. ['$', 'abc', 0, 'found+"-"', '-'],
  45. ['a.c', 'abc', 0, 'found', 'abc'],
  46. ['a.c', 'axc', 0, 'found', 'axc'],
  47. ['a.*c', 'axyzc', 0, 'found', 'axyzc'],
  48. ['a.*c', 'axyzd', 1],
  49. ['a[bc]d', 'abc', 1],
  50. ['a[bc]d', 'abd', 0, 'found', 'abd'],
  51. ['a[b-d]e', 'abd', 1],
  52. ['a[b-d]e', 'ace', 0, 'found', 'ace'],
  53. ['a[b-d]', 'aac', 0, 'found', 'ac'],
  54. ['a[-b]', 'a-', 0, 'found', 'a-'],
  55. ['a[b-]', 'a-', 0, 'found', 'a-'],
  56. ['a[]b', '-', 2],
  57. ['a[', '-', 2],
  58. ['a\\', '-', 2],
  59. ['abc\\)', '-', 2],
  60. ['\\(abc', '-', 2],
  61. ['a]', 'a]', 0, 'found', 'a]'],
  62. ['a[]]b', 'a]b', 0, 'found', 'a]b'],
  63. ['a[^bc]d', 'aed', 0, 'found', 'aed'],
  64. ['a[^bc]d', 'abd', 1],
  65. ['a[^-b]c', 'adc', 0, 'found', 'adc'],
  66. ['a[^-b]c', 'a-c', 1],
  67. ['a[^]b]c', 'a]c', 1],
  68. ['a[^]b]c', 'adc', 0, 'found', 'adc'],
  69. ['\\ba\\b', 'a-', 0, '"-"', '-'],
  70. ['\\ba\\b', '-a', 0, '"-"', '-'],
  71. ['\\ba\\b', '-a-', 0, '"-"', '-'],
  72. ['\\by\\b', 'xy', 1],
  73. ['\\by\\b', 'yz', 1],
  74. ['\\by\\b', 'xyz', 1],
  75. ['ab\\|cd', 'abc', 0, 'found', 'ab'],
  76. ['ab\\|cd', 'abcd', 0, 'found', 'ab'],
  77. ['\\(\\)ef', 'def', 0, 'found+"-"+g1', 'ef-'],
  78. ['$b', 'b', 1],
  79. ['a(b', 'a(b', 0, 'found+"-"+g1', 'a(b-None'],
  80. ['a(*b', 'ab', 0, 'found', 'ab'],
  81. ['a(*b', 'a((b', 0, 'found', 'a((b'],
  82. ['a\\\\b', 'a\\b', 0, 'found', 'a\\b'],
  83. ['\\(\\(a\\)\\)', 'abc', 0, 'found+"-"+g1+"-"+g2', 'a-a-a'],
  84. ['\\(a\\)b\\(c\\)', 'abc', 0, 'found+"-"+g1+"-"+g2', 'abc-a-c'],
  85. ['a+b+c', 'aabbabc', 0, 'found', 'abc'],
  86. ['\\(a+\\|b\\)*', 'ab', 0, 'found+"-"+g1', 'ab-b'],
  87. ['\\(a+\\|b\\)+', 'ab', 0, 'found+"-"+g1', 'ab-b'],
  88. ['\\(a+\\|b\\)?', 'ab', 0, 'found+"-"+g1', 'a-a'],
  89. ['\\)\\(', '-', 2],
  90. ['[^ab]*', 'cde', 0, 'found', 'cde'],
  91. ['abc', '', 1],
  92. ['a*', '', 0, 'found', ''],
  93. ['a\\|b\\|c\\|d\\|e', 'e', 0, 'found', 'e'],
  94. ['\\(a\\|b\\|c\\|d\\|e\\)f', 'ef', 0, 'found+"-"+g1', 'ef-e'],
  95. ['abcd*efg', 'abcdefg', 0, 'found', 'abcdefg'],
  96. ['ab*', 'xabyabbbz', 0, 'found', 'ab'],
  97. ['ab*', 'xayabbbz', 0, 'found', 'a'],
  98. ['\\(ab\\|cd\\)e', 'abcde', 0, 'found+"-"+g1', 'cde-cd'],
  99. ['[abhgefdc]ij', 'hij', 0, 'found', 'hij'],
  100. ['^\\(ab\\|cd\\)e', 'abcde', 1, 'xg1y', 'xy'],
  101. ['\\(abc\\|\\)ef', 'abcdef', 0, 'found+"-"+g1', 'ef-'],
  102. ['\\(a\\|b\\)c*d', 'abcd', 0, 'found+"-"+g1', 'bcd-b'],
  103. ['\\(ab\\|ab*\\)bc', 'abc', 0, 'found+"-"+g1', 'abc-a'],
  104. ['a\\([bc]*\\)c*', 'abc', 0, 'found+"-"+g1', 'abc-bc'],
  105. ['a\\([bc]*\\)\\(c*d\\)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'],
  106. ['a\\([bc]+\\)\\(c*d\\)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'],
  107. ['a\\([bc]*\\)\\(c+d\\)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-b-cd'],
  108. ['a[bcd]*dcdcde', 'adcdcde', 0, 'found', 'adcdcde'],
  109. ['a[bcd]+dcdcde', 'adcdcde', 1],
  110. ['\\(ab\\|a\\)b*c', 'abc', 0, 'found+"-"+g1', 'abc-ab'],
  111. ['\\(\\(a\\)\\(b\\)c\\)\\(d\\)', 'abcd', 0, 'g1+"-"+g2+"-"+g3+"-"+g4', 'abc-a-b-d'],
  112. ['[a-zA-Z_][a-zA-Z0-9_]*', 'alpha', 0, 'found', 'alpha'],
  113. ['^a\\(bc+\\|b[eh]\\)g\\|.h$', 'abh', 0, 'found+"-"+g1', 'bh-None'],
  114. ['\\(bc+d$\\|ef*g.\\|h?i\\(j\\|k\\)\\)', 'effgz', 0, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'],
  115. ['\\(bc+d$\\|ef*g.\\|h?i\\(j\\|k\\)\\)', 'ij', 0, 'found+"-"+g1+"-"+g2', 'ij-ij-j'],
  116. ['\\(bc+d$\\|ef*g.\\|h?i\\(j\\|k\\)\\)', 'effg', 1],
  117. ['\\(bc+d$\\|ef*g.\\|h?i\\(j\\|k\\)\\)', 'bcdd', 1],
  118. ['\\(bc+d$\\|ef*g.\\|h?i\\(j\\|k\\)\\)', 'reffgz', 0, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'],
  119. ['\\(\\(\\(\\(\\(\\(\\(\\(\\(a\\)\\)\\)\\)\\)\\)\\)\\)\\)', 'a', 0, 'found', 'a'],
  120. ['multiple words of text', 'uh-uh', 1],
  121. ['multiple words', 'multiple words, yeah', 0, 'found', 'multiple words'],
  122. ['\\(.*\\)c\\(.*\\)', 'abcde', 0, 'found+"-"+g1+"-"+g2', 'abcde-ab-de'],
  123. ['(\\(.*\\), \\(.*\\))', '(a, b)', 0, 'g2+"-"+g1', 'b-a'],
  124. ['[k]', 'ab', 1],
  125. ['a[-]?c', 'ac', 0, 'found', 'ac'],
  126. ['\\(abc\\)\\1', 'abcabc', 0, 'g1', 'abc'],
  127. ['\\([a-c]*\\)\\1', 'abcabc', 0, 'g1', 'abc'],
  128. ['^\\(.+\\)?B', 'AB', 0, 'g1', 'A'],
  129. ['\\(a+\\).\\1$', 'aaaaa', 0, 'found+"-"+g1', 'aaaaa-aa'],
  130. ['^\\(a+\\).\\1$', 'aaaa', 1],
  131. ['\\(abc\\)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc'],
  132. ['\\([a-c]+\\)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc'],
  133. ['\\(a\\)\\1', 'aa', 0, 'found+"-"+g1', 'aa-a'],
  134. ['\\(a+\\)\\1', 'aa', 0, 'found+"-"+g1', 'aa-a'],
  135. ['\\(a+\\)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a'],
  136. ['\\(a\\).+\\1', 'aba', 0, 'found+"-"+g1', 'aba-a'],
  137. ['\\(a\\)ba*\\1', 'aba', 0, 'found+"-"+g1', 'aba-a'],
  138. ['\\(aa\\|a\\)a\\1$', 'aaa', 0, 'found+"-"+g1', 'aaa-a'],
  139. ['\\(a\\|aa\\)a\\1$', 'aaa', 0, 'found+"-"+g1', 'aaa-a'],
  140. ['\\(a+\\)a\\1$', 'aaa', 0, 'found+"-"+g1', 'aaa-a'],
  141. ['\\([abc]*\\)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc'],
  142. ['\\(a\\)\\(b\\)c\\|ab', 'ab', 0, 'found+"-"+g1+"-"+g2', 'ab-None-None'],
  143. ['\\(a\\)+x', 'aaax', 0, 'found+"-"+g1', 'aaax-a'],
  144. ['\\([ac]\\)+x', 'aacx', 0, 'found+"-"+g1', 'aacx-c'],
  145. ['\\([^/]*/\\)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', 0, 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/'],
  146. ['\\([^.]*\\)\\.\\([^:]*\\):[T ]+\\(.*\\)', 'track1.title:TBlah blah blah', 0, 'found+"-"+g1+"-"+g2+"-"+g3', 'track1.title:TBlah blah blah-track1-title-Blah blah blah'],
  147. ['\\([^N]*N\\)+', 'abNNxyzN', 0, 'found+"-"+g1', 'abNNxyzN-xyzN'],
  148. ['\\([^N]*N\\)+', 'abNNxyz', 0, 'found+"-"+g1', 'abNN-N'],
  149. ['\\([abc]*\\)x', 'abcx', 0, 'found+"-"+g1', 'abcx-abc'],
  150. ['\\([abc]*\\)x', 'abc', 1],
  151. ['\\([xyz]*\\)x', 'abcx', 0, 'found+"-"+g1', 'x-'],
  152. ['\\(a\\)+b\\|aac', 'aac', 0, 'found+"-"+g1', 'aac-None'],
  153. ['\\<a', 'a', 0, 'found', 'a'],
  154. ['\\<a', '!', 1],
  155. ['a\\<b', 'ab', 1],
  156. ['a\\>', 'ab', 1],
  157. ['a\\>', 'a!', 0, 'found', 'a'],
  158. ['a\\>', 'a', 0, 'found', 'a'],
  159. ]
  160.  
  161.  
  162. # test suite for match
  163. match_regex_tests=[
  164. ['abc', 'abc', 0, 'found', 'abc'],
  165. ['abc', 'xbc', 1],
  166. ['abc', 'axc', 1],
  167. ['abc', 'abx', 1],
  168. ['abc', 'xabcy', 1],
  169. ['abc', 'ababc', 1],
  170. ['ab*c', 'abc', 0, 'found', 'abc'],
  171. ['ab*bc', 'abc', 0, 'found', 'abc'],
  172. ['ab*bc', 'abbc', 0, 'found', 'abbc'],
  173. ['ab*bc', 'abbbbc', 0, 'found', 'abbbbc'],
  174. ['ab+bc', 'abbc', 0, 'found', 'abbc'],
  175. ['ab+bc', 'abc', 1],
  176. ['ab+bc', 'abq', 1],
  177. ['ab+bc', 'abbbbc', 0, 'found', 'abbbbc'],
  178. ['ab?bc', 'abbc', 0, 'found', 'abbc'],
  179. ['ab?bc', 'abc', 0, 'found', 'abc'],
  180. ['ab?bc', 'abbbbc', 1],
  181. ['ab?c', 'abc', 0, 'found', 'abc'],
  182. ['^abc$', 'abc', 0, 'found', 'abc'],
  183. ['^abc$', 'abcc', 1],
  184. ['^abc', 'abcc', 0, 'found', 'abc'],
  185. ['^abc$', 'aabc', 1],
  186. ['abc$', 'aabc', 1],
  187. ['^', 'abc', 0, 'found+"-"', '-'],
  188. ['$', 'abc', 1],
  189. ['a.c', 'abc', 0, 'found', 'abc'],
  190. ['a.c', 'axc', 0, 'found', 'axc'],
  191. ['a.*c', 'axyzc', 0, 'found', 'axyzc'],
  192. ['a.*c', 'axyzd', 1],
  193. ['a[bc]d', 'abc', 1],
  194. ['a[bc]d', 'abd', 0, 'found', 'abd'],
  195. ['a[b-d]e', 'abd', 1],
  196. ['a[b-d]e', 'ace', 0, 'found', 'ace'],
  197. ['a[b-d]', 'aac', 1],
  198. ['a[-b]', 'a-', 0, 'found', 'a-'],
  199. ['a[b-]', 'a-', 0, 'found', 'a-'],
  200. ['a[]b', '-', 2],
  201. ['a[', '-', 2],
  202. ['a\\', '-', 2],
  203. ['abc\\)', '-', 2],
  204. ['\\(abc', '-', 2],
  205. ['a]', 'a]', 0, 'found', 'a]'],
  206. ['a[]]b', 'a]b', 0, 'found', 'a]b'],
  207. ['a[^bc]d', 'aed', 0, 'found', 'aed'],
  208. ['a[^bc]d', 'abd', 1],
  209. ['a[^-b]c', 'adc', 0, 'found', 'adc'],
  210. ['a[^-b]c', 'a-c', 1],
  211. ['a[^]b]c', 'a]c', 1],
  212. ['a[^]b]c', 'adc', 0, 'found', 'adc'],
  213. ['\\ba\\b', 'a-', 0, '"-"', '-'],
  214. ['\\ba\\b', '-a', 1],
  215. ['\\ba\\b', '-a-', 1],
  216. ['\\by\\b', 'xy', 1],
  217. ['\\by\\b', 'yz', 1],
  218. ['\\by\\b', 'xyz', 1],
  219. ['ab\\|cd', 'abc', 0, 'found', 'ab'],
  220. ['ab\\|cd', 'abcd', 0, 'found', 'ab'],
  221. ['\\(\\)ef', 'def', 1],
  222. ['$b', 'b', 1],
  223. ['a(b', 'a(b', 0, 'found+"-"+g1', 'a(b-None'],
  224. ['a(*b', 'ab', 0, 'found', 'ab'],
  225. ['a(*b', 'a((b', 0, 'found', 'a((b'],
  226. ['a\\\\b', 'a\\b', 0, 'found', 'a\\b'],
  227. ['\\(\\(a\\)\\)', 'abc', 0, 'found+"-"+g1+"-"+g2', 'a-a-a'],
  228. ['\\(a\\)b\\(c\\)', 'abc', 0, 'found+"-"+g1+"-"+g2', 'abc-a-c'],
  229. ['a+b+c', 'aabbabc', 1],
  230. ['\\(a+\\|b\\)*', 'ab', 0, 'found+"-"+g1', 'ab-b'],
  231. ['\\(a+\\|b\\)+', 'ab', 0, 'found+"-"+g1', 'ab-b'],
  232. ['\\(a+\\|b\\)?', 'ab', 0, 'found+"-"+g1', 'a-a'],
  233. ['\\)\\(', '-', 2],
  234. ['[^ab]*', 'cde', 0, 'found', 'cde'],
  235. ['abc', '', 1],
  236. ['a*', '', 0, 'found', ''],
  237. ['a\\|b\\|c\\|d\\|e', 'e', 0, 'found', 'e'],
  238. ['\\(a\\|b\\|c\\|d\\|e\\)f', 'ef', 0, 'found+"-"+g1', 'ef-e'],
  239. ['abcd*efg', 'abcdefg', 0, 'found', 'abcdefg'],
  240. ['ab*', 'xabyabbbz', 1],
  241. ['ab*', 'xayabbbz', 1],
  242. ['\\(ab\\|cd\\)e', 'abcde', 1],
  243. ['[abhgefdc]ij', 'hij', 0, 'found', 'hij'],
  244. ['^\\(ab\\|cd\\)e', 'abcde', 1, 'xg1y', 'xy'],
  245. ['\\(abc\\|\\)ef', 'abcdef', 1],
  246. ['\\(a\\|b\\)c*d', 'abcd', 1],
  247. ['\\(ab\\|ab*\\)bc', 'abc', 0, 'found+"-"+g1', 'abc-a'],
  248. ['a\\([bc]*\\)c*', 'abc', 0, 'found+"-"+g1', 'abc-bc'],
  249. ['a\\([bc]*\\)\\(c*d\\)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'],
  250. ['a\\([bc]+\\)\\(c*d\\)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'],
  251. ['a\\([bc]*\\)\\(c+d\\)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-b-cd'],
  252. ['a[bcd]*dcdcde', 'adcdcde', 0, 'found', 'adcdcde'],
  253. ['a[bcd]+dcdcde', 'adcdcde', 1],
  254. ['\\(ab\\|a\\)b*c', 'abc', 0, 'found+"-"+g1', 'abc-ab'],
  255. ['\\(\\(a\\)\\(b\\)c\\)\\(d\\)', 'abcd', 0, 'g1+"-"+g2+"-"+g3+"-"+g4', 'abc-a-b-d'],
  256. ['[a-zA-Z_][a-zA-Z0-9_]*', 'alpha', 0, 'found', 'alpha'],
  257. ['^a\\(bc+\\|b[eh]\\)g\\|.h$', 'abh', 1],
  258. ['\\(bc+d$\\|ef*g.\\|h?i\\(j\\|k\\)\\)', 'effgz', 0, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'],
  259. ['\\(bc+d$\\|ef*g.\\|h?i\\(j\\|k\\)\\)', 'ij', 0, 'found+"-"+g1+"-"+g2', 'ij-ij-j'],
  260. ['\\(bc+d$\\|ef*g.\\|h?i\\(j\\|k\\)\\)', 'effg', 1],
  261. ['\\(bc+d$\\|ef*g.\\|h?i\\(j\\|k\\)\\)', 'bcdd', 1],
  262. ['\\(bc+d$\\|ef*g.\\|h?i\\(j\\|k\\)\\)', 'reffgz', 1],
  263. ['\\(\\(\\(\\(\\(\\(\\(\\(\\(a\\)\\)\\)\\)\\)\\)\\)\\)\\)', 'a', 0, 'found', 'a'],
  264. ['multiple words of text', 'uh-uh', 1],
  265. ['multiple words', 'multiple words, yeah', 0, 'found', 'multiple words'],
  266. ['\\(.*\\)c\\(.*\\)', 'abcde', 0, 'found+"-"+g1+"-"+g2', 'abcde-ab-de'],
  267. ['(\\(.*\\), \\(.*\\))', '(a, b)', 0, 'g2+"-"+g1', 'b-a'],
  268. ['[k]', 'ab', 1],
  269. ['a[-]?c', 'ac', 0, 'found', 'ac'],
  270. ['\\(abc\\)\\1', 'abcabc', 0, 'g1', 'abc'],
  271. ['\\([a-c]*\\)\\1', 'abcabc', 0, 'g1', 'abc'],
  272. ['^\\(.+\\)?B', 'AB', 0, 'g1', 'A'],
  273. ['\\(a+\\).\\1$', 'aaaaa', 0, 'found+"-"+g1', 'aaaaa-aa'],
  274. ['^\\(a+\\).\\1$', 'aaaa', 1],
  275. ['\\(abc\\)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc'],
  276. ['\\([a-c]+\\)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc'],
  277. ['\\(a\\)\\1', 'aa', 0, 'found+"-"+g1', 'aa-a'],
  278. ['\\(a+\\)\\1', 'aa', 0, 'found+"-"+g1', 'aa-a'],
  279. ['\\(a+\\)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a'],
  280. ['\\(a\\).+\\1', 'aba', 0, 'found+"-"+g1', 'aba-a'],
  281. ['\\(a\\)ba*\\1', 'aba', 0, 'found+"-"+g1', 'aba-a'],
  282. ['\\(aa\\|a\\)a\\1$', 'aaa', 0, 'found+"-"+g1', 'aaa-a'],
  283. ['\\(a\\|aa\\)a\\1$', 'aaa', 0, 'found+"-"+g1', 'aaa-a'],
  284. ['\\(a+\\)a\\1$', 'aaa', 0, 'found+"-"+g1', 'aaa-a'],
  285. ['\\([abc]*\\)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc'],
  286. ['\\(a\\)\\(b\\)c\\|ab', 'ab', 0, 'found+"-"+g1+"-"+g2', 'ab-None-None'],
  287. ['\\(a\\)+x', 'aaax', 0, 'found+"-"+g1', 'aaax-a'],
  288. ['\\([ac]\\)+x', 'aacx', 0, 'found+"-"+g1', 'aacx-c'],
  289. ['\\([^/]*/\\)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', 0, 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/'],
  290. ['\\([^.]*\\)\\.\\([^:]*\\):[T ]+\\(.*\\)', 'track1.title:TBlah blah blah', 0, 'found+"-"+g1+"-"+g2+"-"+g3', 'track1.title:TBlah blah blah-track1-title-Blah blah blah'],
  291. ['\\([^N]*N\\)+', 'abNNxyzN', 0, 'found+"-"+g1', 'abNNxyzN-xyzN'],
  292. ['\\([^N]*N\\)+', 'abNNxyz', 0, 'found+"-"+g1', 'abNN-N'],
  293. ['\\([abc]*\\)x', 'abcx', 0, 'found+"-"+g1', 'abcx-abc'],
  294. ['\\([abc]*\\)x', 'abc', 1],
  295. ['\\([xyz]*\\)x', 'abcx', 1],
  296. ['\\(a\\)+b\\|aac', 'aac', 0, 'found+"-"+g1', 'aac-None'],
  297. ['\\<a', 'a', 0, 'found', 'a'],
  298. ['\\<a', '!', 1],
  299. ['a\\<b', 'ab', 1],
  300. ['a\\>', 'ab', 1],
  301. ['a\\>', 'a!', 0, 'found', 'a'],
  302. ['a\\>', 'a', 0, 'found', 'a'],
  303. ]
  304.  
  305. # test suite for split()
  306. # element 0: pattern
  307. #         1: string to split
  308. #         3: compile result
  309. #         4: maxsplit
  310. #         5: splitted fields list
  311. split_regex_tests = [
  312. ["[ |,]", "with you, nothing, and me", 0, 0, ["with","you","nothing","and","me"]],
  313. ["[ |,]", "with you, nothing, and me", 0, 1, ["with", "you, nothing, and me"]],
  314. ["\\ ", "send email to apply", 0, 0, ["send", "email", "to", "apply"]],
  315. ["\\ ", "send email to apply", 0, 2, ["send", "email", "to apply"]],
  316. ["[+ | -]", "+86-028-83201034", 0, 0, ["86", "028", "83201034"]],
  317. ["[+ | -]", "+86-028-83201034", 0, 1, ["86", "028-83201034"]],
  318. ["[*|#]", "slide show", 0, 0, ["slide show"]],
  319. ["(", "whats ever", 0, 1, ["whats ever"]],
  320. ["@#!~$%^&*()<>\n", "who knows", 0, 1, ["who knows"]],
  321. ]
  322.  
  323. # test suite for findall()
  324. # element 0: pattern
  325. #         1: string to match
  326. #         3: compile result
  327. #         4: starting position
  328. #         5: grouped fields list
  329.  
  330. # reobj.find()
  331. findall_regex_tests = [
  332. ["\\ ", "send email to apply", 0, 0, [" ", " ", " "]],
  333. ["\\ ", "send email to apply", 0, 5, [" ", " "]],
  334. ["[+ | -]", "+86-028-83201034", 0, 0, ["+", "-", "-"]],
  335. ["[+ | -]", "+86-028-83201034", 0, 1, ["-", "-"]],
  336. ["sl.*e\\|#", "slide show at Room #3", 0, 0, ["slide", "#"]],
  337. ["w.+s\\|e.*r", "whats ever", 0, 0, ["whats", "ever"]],
  338. ["Euler\\|Gauss", "Both Euler and Gauss are great mathematicians", 0, 0, ["Euler", "Gauss"]],
  339. ]
  340.  
  341. # module re.findall()
  342. mod_findall_regex_tests = [
  343. ["\\ ", "send email to apply", 0, 0, [" ", " ", " "]],
  344. ["\\ ", "send email to apply", 0, 0, [" ", " ", " "]],
  345. ["[+ | -]", "+86-028-83201034", 0, 0, ["+", "-", "-"]],
  346. ["[+ | -]", "+86-028-83201034", 0, 0, ["+", "-", "-"]],
  347. ["sl.*e\\|#", "slide show at Room #3", 0, 0, ["slide", "#"]],
  348. ["w.+s\\|e.*r", "whats ever", 0, 0, ["whats", "ever"]],
  349. ["Euler\\|Gauss", "Both Euler and Gauss are great mathematicians", 0, 0, ["Euler", "Gauss"]],
  350. ]
  351.  
  352. # test for match object's groups() method
  353. # element 0: pattern
  354. #                 1: string
  355. #                 2: compile result
  356. #                 3: matched fields, for groups()
  357. #                 4: group index, valid when > 0, for start(), end(), and span()
  358. #                 5: pattern's starting index in string, for start() and span()
  359. #                 6: pattern's ending index in string, for end() and span
  360. matobj_groups_regex_tests = [
  361. ["\\(abc\\(.*xyz\\)\\(.*31415926\\)\\)", "where is abc and flurry xyz, which is pi 31415926, derived from ms", 0, ["abc and flurry xyz, which is pi 31415926"," and flurry xyz",", which is pi 31415926"], 2, 12, 27],
  362.  
  363. ["[a\\|b]\\(.+\\)shoe\\([t]+\\)d", "bbbshoetttdxrznmlkjp", 0, ["bb", "ttt"], 1, 1, 3],
  364.  
  365. ["abcdef", "xyah2oewoyqe030uabcdefwhalsdewnkhgiohyczb", 0, [], -1, 0, 0],
  366. ]
  367.  
  368.