github的一些开源项目
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.

540 lines
12 KiB

  1. # These are:
  2. #
  3. # (1) Tests of the match-limiting features. The results are different for
  4. # interpretive or JIT matching, so this test should not be run with JIT. The
  5. # same tests are run using JIT in test 17.
  6. # (2) Other tests that must not be run with JIT.
  7. # These tests are first so that they don't inherit a large enough heap frame
  8. # vector from a previous test.
  9. /(*LIMIT_HEAP=21)\[(a)]{60}/expand
  10. \[a]{60}
  11. Failed: error -63: heap limit exceeded
  12. "(*LIMIT_HEAP=21)()((?))()()()()()()()()()()()()()()()()()()()()()()()(())()()()()()()()()()()()()()()()()()()()()()(())()()()()()()()()()()()()()"
  13. xx
  14. Failed: error -63: heap limit exceeded
  15. # -----------------------------------------------------------------------
  16. /(a+)*zz/I
  17. Capture group count = 1
  18. Starting code units: a z
  19. Last code unit = 'z'
  20. Subject length lower bound = 2
  21. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazzbbbbbb\=find_limits_noheap
  22. Minimum match limit = 7
  23. Minimum depth limit = 7
  24. 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazz
  25. 1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  26. aaaaaaaaaaaaaz\=find_limits_noheap
  27. Minimum match limit = 20481
  28. Minimum depth limit = 30
  29. No match
  30. !((?:\s|//.*\\n|/[*](?:\\n|.)*?[*]/)*)!I
  31. Capture group count = 1
  32. May match empty string
  33. Subject length lower bound = 0
  34. /* this is a C style comment */\=find_limits_noheap
  35. Minimum match limit = 64
  36. Minimum depth limit = 7
  37. 0: /* this is a C style comment */
  38. 1: /* this is a C style comment */
  39. /^(?>a)++/
  40. aa\=find_limits_noheap
  41. Minimum match limit = 5
  42. Minimum depth limit = 3
  43. 0: aa
  44. aaaaaaaaa\=find_limits_noheap
  45. Minimum match limit = 12
  46. Minimum depth limit = 3
  47. 0: aaaaaaaaa
  48. /(a)(?1)++/
  49. aa\=find_limits_noheap
  50. Minimum match limit = 7
  51. Minimum depth limit = 5
  52. 0: aa
  53. 1: a
  54. aaaaaaaaa\=find_limits_noheap
  55. Minimum match limit = 21
  56. Minimum depth limit = 5
  57. 0: aaaaaaaaa
  58. 1: a
  59. /a(?:.)*?a/ims
  60. abbbbbbbbbbbbbbbbbbbbba\=find_limits_noheap
  61. Minimum match limit = 24
  62. Minimum depth limit = 3
  63. 0: abbbbbbbbbbbbbbbbbbbbba
  64. /a(?:.(*THEN))*?a/ims
  65. abbbbbbbbbbbbbbbbbbbbba\=find_limits_noheap
  66. Minimum match limit = 66
  67. Minimum depth limit = 45
  68. 0: abbbbbbbbbbbbbbbbbbbbba
  69. /a(?:.(*THEN:ABC))*?a/ims
  70. abbbbbbbbbbbbbbbbbbbbba\=find_limits_noheap
  71. Minimum match limit = 66
  72. Minimum depth limit = 45
  73. 0: abbbbbbbbbbbbbbbbbbbbba
  74. /^(?>a+)(?>b+)(?>c+)(?>d+)(?>e+)/
  75. aabbccddee\=find_limits_noheap
  76. Minimum match limit = 7
  77. Minimum depth limit = 7
  78. 0: aabbccddee
  79. /^(?>(a+))(?>(b+))(?>(c+))(?>(d+))(?>(e+))/
  80. aabbccddee\=find_limits_noheap
  81. Minimum match limit = 12
  82. Minimum depth limit = 12
  83. 0: aabbccddee
  84. 1: aa
  85. 2: bb
  86. 3: cc
  87. 4: dd
  88. 5: ee
  89. /^(?>(a+))(?>b+)(?>(c+))(?>d+)(?>(e+))/
  90. aabbccddee\=find_limits_noheap
  91. Minimum match limit = 10
  92. Minimum depth limit = 10
  93. 0: aabbccddee
  94. 1: aa
  95. 2: cc
  96. 3: ee
  97. /(*LIMIT_MATCH=12bc)abc/
  98. Failed: error 160 at offset 17: (*VERB) not recognized or malformed
  99. /(*LIMIT_MATCH=4294967290)abc/
  100. Failed: error 160 at offset 24: (*VERB) not recognized or malformed
  101. /(*LIMIT_DEPTH=4294967280)abc/I
  102. Capture group count = 0
  103. Depth limit = 4294967280
  104. First code unit = 'a'
  105. Last code unit = 'c'
  106. Subject length lower bound = 3
  107. /(a+)*zz/
  108. \= Expect no match
  109. aaaaaaaaaaaaaz
  110. No match
  111. \= Expect limit exceeded
  112. aaaaaaaaaaaaaz\=match_limit=3000
  113. Failed: error -47: match limit exceeded
  114. /(a+)*zz/
  115. \= Expect limit exceeded
  116. aaaaaaaaaaaaaz\=depth_limit=10
  117. Failed: error -53: matching depth limit exceeded
  118. /(*LIMIT_MATCH=3000)(a+)*zz/I
  119. Capture group count = 1
  120. Match limit = 3000
  121. Starting code units: a z
  122. Last code unit = 'z'
  123. Subject length lower bound = 2
  124. \= Expect limit exceeded
  125. aaaaaaaaaaaaaz
  126. Failed: error -47: match limit exceeded
  127. \= Expect limit exceeded
  128. aaaaaaaaaaaaaz\=match_limit=60000
  129. Failed: error -47: match limit exceeded
  130. /(*LIMIT_MATCH=60000)(*LIMIT_MATCH=3000)(a+)*zz/I
  131. Capture group count = 1
  132. Match limit = 3000
  133. Starting code units: a z
  134. Last code unit = 'z'
  135. Subject length lower bound = 2
  136. \= Expect limit exceeded
  137. aaaaaaaaaaaaaz
  138. Failed: error -47: match limit exceeded
  139. /(*LIMIT_MATCH=60000)(a+)*zz/I
  140. Capture group count = 1
  141. Match limit = 60000
  142. Starting code units: a z
  143. Last code unit = 'z'
  144. Subject length lower bound = 2
  145. \= Expect no match
  146. aaaaaaaaaaaaaz
  147. No match
  148. \= Expect limit exceeded
  149. aaaaaaaaaaaaaz\=match_limit=3000
  150. Failed: error -47: match limit exceeded
  151. /(*LIMIT_DEPTH=10)(a+)*zz/I
  152. Capture group count = 1
  153. Depth limit = 10
  154. Starting code units: a z
  155. Last code unit = 'z'
  156. Subject length lower bound = 2
  157. \= Expect limit exceeded
  158. aaaaaaaaaaaaaz
  159. Failed: error -53: matching depth limit exceeded
  160. \= Expect limit exceeded
  161. aaaaaaaaaaaaaz\=depth_limit=1000
  162. Failed: error -53: matching depth limit exceeded
  163. /(*LIMIT_DEPTH=10)(*LIMIT_DEPTH=1000)(a+)*zz/I
  164. Capture group count = 1
  165. Depth limit = 1000
  166. Starting code units: a z
  167. Last code unit = 'z'
  168. Subject length lower bound = 2
  169. \= Expect no match
  170. aaaaaaaaaaaaaz
  171. No match
  172. /(*LIMIT_DEPTH=1000)(a+)*zz/I
  173. Capture group count = 1
  174. Depth limit = 1000
  175. Starting code units: a z
  176. Last code unit = 'z'
  177. Subject length lower bound = 2
  178. \= Expect no match
  179. aaaaaaaaaaaaaz
  180. No match
  181. \= Expect limit exceeded
  182. aaaaaaaaaaaaaz\=depth_limit=10
  183. Failed: error -53: matching depth limit exceeded
  184. # These three have infinitely nested recursions.
  185. /((?2))((?1))/
  186. abc
  187. Failed: error -52: nested recursion at the same subject position
  188. /((?(R2)a+|(?1)b))()/
  189. aaaabcde
  190. Failed: error -52: nested recursion at the same subject position
  191. /(?(R)a*(?1)|((?R))b)/
  192. aaaabcde
  193. Failed: error -52: nested recursion at the same subject position
  194. # The allusedtext modifier does not work with JIT, which does not maintain
  195. # the leftchar/rightchar data.
  196. /abc(?=xyz)/allusedtext
  197. abcxyzpqr
  198. 0: abcxyz
  199. >>>
  200. abcxyzpqr\=aftertext
  201. 0: abcxyz
  202. >>>
  203. 0+ xyzpqr
  204. /(?<=pqr)abc(?=xyz)/allusedtext
  205. xyzpqrabcxyzpqr
  206. 0: pqrabcxyz
  207. <<< >>>
  208. xyzpqrabcxyzpqr\=aftertext
  209. 0: pqrabcxyz
  210. <<< >>>
  211. 0+ xyzpqr
  212. /a\b/
  213. a.\=allusedtext
  214. 0: a.
  215. >
  216. a\=allusedtext
  217. 0: a
  218. /abc\Kxyz/
  219. abcxyz\=allusedtext
  220. 0: abcxyz
  221. <<<
  222. /abc(?=xyz(*ACCEPT))/
  223. abcxyz\=allusedtext
  224. 0: abcxyz
  225. >>>
  226. /abc(?=abcde)(?=ab)/allusedtext
  227. abcabcdefg
  228. 0: abcabcde
  229. >>>>>
  230. #subject allusedtext
  231. /(?<=abc)123/
  232. xyzabc123pqr
  233. 0: abc123
  234. <<<
  235. xyzabc12\=ps
  236. Partial match: abc12
  237. <<<
  238. xyzabc12\=ph
  239. Partial match: abc12
  240. <<<
  241. /\babc\b/
  242. +++abc+++
  243. 0: +abc+
  244. < >
  245. +++ab\=ps
  246. Partial match: +ab
  247. <
  248. +++ab\=ph
  249. Partial match: +ab
  250. <
  251. /(?<=abc)def/
  252. abc\=ph
  253. Partial match: abc
  254. <<<
  255. /(?<=123)(*MARK:xx)abc/mark
  256. xxxx123a\=ph
  257. Partial match, mark=xx: 123a
  258. <<<
  259. xxxx123a\=ps
  260. Partial match, mark=xx: 123a
  261. <<<
  262. /(?<=(?<=a)b)c.*/I
  263. Capture group count = 0
  264. Max lookbehind = 1
  265. First code unit = 'c'
  266. Subject length lower bound = 1
  267. abc\=ph
  268. Partial match: abc
  269. <<
  270. \= Expect no match
  271. xbc\=ph
  272. No match
  273. /(?<=ab)c.*/I
  274. Capture group count = 0
  275. Max lookbehind = 2
  276. First code unit = 'c'
  277. Subject length lower bound = 1
  278. abc\=ph
  279. Partial match: abc
  280. <<
  281. \= Expect no match
  282. xbc\=ph
  283. No match
  284. /abc(?<=bc)def/
  285. xxxabcd\=ph
  286. Partial match: abcd
  287. /(?<=ab)cdef/
  288. xxabcd\=ph
  289. Partial match: abcd
  290. <<
  291. /(?<=(?<=(?<=a)b)c)./I
  292. Capture group count = 0
  293. Max lookbehind = 1
  294. Subject length lower bound = 1
  295. 123abcXYZ
  296. 0: abcX
  297. <<<
  298. /(?<=ab(cd(?<=...)))./I
  299. Capture group count = 1
  300. Max lookbehind = 4
  301. Subject length lower bound = 1
  302. abcdX
  303. 0: abcdX
  304. <<<<
  305. 1: cd
  306. /(?<=ab((?<=...)cd))./I
  307. Capture group count = 1
  308. Max lookbehind = 4
  309. Subject length lower bound = 1
  310. ZabcdX
  311. 0: ZabcdX
  312. <<<<<
  313. 1: cd
  314. /(?<=((?<=(?<=ab).))(?1)(?1))./I
  315. Capture group count = 1
  316. Max lookbehind = 2
  317. Subject length lower bound = 1
  318. abxZ
  319. 0: abxZ
  320. <<<
  321. 1:
  322. #subject
  323. # -------------------------------------------------------------------
  324. # These tests provoke recursion loops, which give a different error message
  325. # when JIT is used.
  326. /(?R)/I
  327. Capture group count = 0
  328. May match empty string
  329. Subject length lower bound = 0
  330. abcd
  331. Failed: error -52: nested recursion at the same subject position
  332. /(a|(?R))/I
  333. Capture group count = 1
  334. May match empty string
  335. Subject length lower bound = 0
  336. abcd
  337. 0: a
  338. 1: a
  339. defg
  340. Failed: error -52: nested recursion at the same subject position
  341. /(ab|(bc|(de|(?R))))/I
  342. Capture group count = 3
  343. May match empty string
  344. Subject length lower bound = 0
  345. abcd
  346. 0: ab
  347. 1: ab
  348. fghi
  349. Failed: error -52: nested recursion at the same subject position
  350. /(ab|(bc|(de|(?1))))/I
  351. Capture group count = 3
  352. May match empty string
  353. Subject length lower bound = 0
  354. abcd
  355. 0: ab
  356. 1: ab
  357. fghi
  358. Failed: error -52: nested recursion at the same subject position
  359. /x(ab|(bc|(de|(?1)x)x)x)/I
  360. Capture group count = 3
  361. First code unit = 'x'
  362. Subject length lower bound = 3
  363. xab123
  364. 0: xab
  365. 1: ab
  366. xfghi
  367. Failed: error -52: nested recursion at the same subject position
  368. /(?!\w)(?R)/
  369. abcd
  370. Failed: error -52: nested recursion at the same subject position
  371. =abc
  372. Failed: error -52: nested recursion at the same subject position
  373. /(?=\w)(?R)/
  374. =abc
  375. Failed: error -52: nested recursion at the same subject position
  376. abcd
  377. Failed: error -52: nested recursion at the same subject position
  378. /(?<!\w)(?R)/
  379. abcd
  380. Failed: error -52: nested recursion at the same subject position
  381. /(?<=\w)(?R)/
  382. abcd
  383. Failed: error -52: nested recursion at the same subject position
  384. /(a+|(?R)b)/
  385. aaa
  386. 0: aaa
  387. 1: aaa
  388. bbb
  389. Failed: error -52: nested recursion at the same subject position
  390. /[^\xff]((?1))/BI
  391. ------------------------------------------------------------------
  392. Bra
  393. [^\x{ff}]
  394. CBra 1
  395. Recurse
  396. Ket
  397. Ket
  398. End
  399. ------------------------------------------------------------------
  400. Capture group count = 1
  401. Subject length lower bound = 1
  402. abcd
  403. Failed: error -52: nested recursion at the same subject position
  404. # These tests don't behave the same with JIT
  405. /\w+(?C1)/BI,no_auto_possess
  406. ------------------------------------------------------------------
  407. Bra
  408. \w+
  409. Callout 1 8 0
  410. Ket
  411. End
  412. ------------------------------------------------------------------
  413. Capture group count = 0
  414. Options: no_auto_possess
  415. Starting code units: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P
  416. Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z
  417. Subject length lower bound = 1
  418. abc\=callout_fail=1
  419. --->abc
  420. 1 ^ ^ End of pattern
  421. 1 ^ ^ End of pattern
  422. 1 ^^ End of pattern
  423. 1 ^ ^ End of pattern
  424. 1 ^^ End of pattern
  425. 1 ^^ End of pattern
  426. No match
  427. /(*NO_AUTO_POSSESS)\w+(?C1)/BI
  428. ------------------------------------------------------------------
  429. Bra
  430. \w+
  431. Callout 1 26 0
  432. Ket
  433. End
  434. ------------------------------------------------------------------
  435. Capture group count = 0
  436. Compile options: <none>
  437. Overall options: no_auto_possess
  438. Starting code units: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P
  439. Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z
  440. Subject length lower bound = 1
  441. abc\=callout_fail=1
  442. --->abc
  443. 1 ^ ^ End of pattern
  444. 1 ^ ^ End of pattern
  445. 1 ^^ End of pattern
  446. 1 ^ ^ End of pattern
  447. 1 ^^ End of pattern
  448. 1 ^^ End of pattern
  449. No match
  450. # This test breaks the JIT stack limit
  451. /(|]+){2,2452}/
  452. (|]+){2,2452}
  453. 0:
  454. 1:
  455. /b(?<!ax)(?!cx)/allusedtext
  456. abc
  457. 0: abc
  458. < >
  459. abcz
  460. 0: abcz
  461. < >>
  462. # This test triggers the recursion limit in the interpreter, but completes in
  463. # JIT. It's in testinput2 with disable_recurse_loop_check to get it to work
  464. # in the interpreter.
  465. /(a(?1)z||(?1)++)$/
  466. abcd
  467. Failed: error -52: nested recursion at the same subject position
  468. # End of testinput15