lastIndex.baseline 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. ************
  2. *** Exec ***
  3. ************
  4. ****** Local regex, matching string
  5. exec(/x/ /*lastIndex=0*/ , "axbxcxd", 0);
  6. ["x"] /*input="axbxcxd", index=1*/
  7. r.lastIndex=0
  8. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  9. exec(/x/ /*lastIndex=0*/ , "axbxcxd", 4);
  10. ["x"] /*input="axbxcxd", index=1*/
  11. r.lastIndex=4
  12. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  13. ****** Global regex, matching string
  14. exec(/x/g /*lastIndex=0*/ , "axbxcxd", 0);
  15. ["x"] /*input="axbxcxd", index=1*/
  16. r.lastIndex=2
  17. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  18. exec(/x/g /*lastIndex=2*/ , "axbxcxd", 4);
  19. ["x"] /*input="axbxcxd", index=5*/
  20. r.lastIndex=6
  21. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  22. ****** Local regex, non-matching string
  23. exec(/x/ /*lastIndex=4*/ , "abc", 0);
  24. null
  25. r.lastIndex=0
  26. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  27. exec(/x/, "abc", 4);
  28. null
  29. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  30. ****** Global regex, non-matching string
  31. exec(/x/g /*lastIndex=6*/ , "abc", 0);
  32. null
  33. r.lastIndex=0
  34. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  35. exec(/x/g /*lastIndex=0*/ , "abc", 4);
  36. null
  37. r.lastIndex=0
  38. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  39. ****** Local empty regex
  40. exec(/(?:)/ /*lastIndex=0*/ , "axbxcxd", 0);
  41. [""] /*input="axbxcxd", index=0*/
  42. r.lastIndex=0
  43. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  44. exec(/(?:)/ /*lastIndex=0*/ , "axbxcxd", 4);
  45. [""] /*input="axbxcxd", index=0*/
  46. r.lastIndex=4
  47. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  48. ****** Global empty regex
  49. exec(/(?:)/g /*lastIndex=0*/ , "axbxcxd", 0);
  50. [""] /*input="axbxcxd", index=0*/
  51. r.lastIndex=0
  52. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  53. exec(/(?:)/g /*lastIndex=0*/ , "axbxcxd", 4);
  54. [""] /*input="axbxcxd", index=4*/
  55. r.lastIndex=4
  56. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  57. ****** Special cases
  58. exec(/^/ /*lastIndex=0*/ , "");
  59. [""] /*input="", index=0*/
  60. r.lastIndex=0
  61. RegExp.${_,1,...,9}=["","","","","","","","","",""]
  62. ************
  63. *** Test ***
  64. ************
  65. ****** Local regex, matching string
  66. test(/x/ /*lastIndex=0*/ , "axbxcxd", 0);
  67. true
  68. r.lastIndex=0
  69. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  70. test(/x/ /*lastIndex=0*/ , "axbxcxd", 4);
  71. true
  72. r.lastIndex=4
  73. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  74. ****** Global regex, matching string
  75. test(/x/g /*lastIndex=0*/ , "axbxcxd", 0);
  76. true
  77. r.lastIndex=2
  78. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  79. test(/x/g /*lastIndex=2*/ , "axbxcxd", 4);
  80. true
  81. r.lastIndex=6
  82. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  83. ****** Local regex, non-matching string
  84. test(/x/ /*lastIndex=4*/ , "abc", 0);
  85. false
  86. r.lastIndex=0
  87. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  88. test(/x/, "abc", 4);
  89. false
  90. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  91. ****** Global regex, non-matching string
  92. test(/x/g /*lastIndex=6*/ , "abc", 0);
  93. false
  94. r.lastIndex=0
  95. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  96. test(/x/g /*lastIndex=0*/ , "abc", 4);
  97. false
  98. r.lastIndex=0
  99. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  100. ****** Local empty regex
  101. test(/(?:)/ /*lastIndex=4*/ , "axbxcxd", 0);
  102. true
  103. r.lastIndex=0
  104. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  105. test(/(?:)/ /*lastIndex=0*/ , "axbxcxd", 4);
  106. true
  107. r.lastIndex=4
  108. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  109. ****** Global empty regex
  110. test(/(?:)/g /*lastIndex=4*/ , "axbxcxd", 0);
  111. true
  112. r.lastIndex=0
  113. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  114. test(/(?:)/g /*lastIndex=0*/ , "axbxcxd", 4);
  115. true
  116. r.lastIndex=4
  117. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  118. ****** lastIndex above MaxCharCount
  119. test(/x/g /*lastIndex=0*/ , "axbxcxd", 9007199254740991);
  120. false
  121. r.lastIndex=0
  122. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  123. *************
  124. *** Match ***
  125. *************
  126. ****** Local regex, matching string
  127. match(/x/ /*lastIndex=0*/ , "axbxcxd", 0);
  128. ["x"] /*input="axbxcxd", index=1*/
  129. r.lastIndex=0
  130. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  131. match(/x/ /*lastIndex=0*/ , "axbxcxd", 4);
  132. ["x"] /*input="axbxcxd", index=1*/
  133. r.lastIndex=4
  134. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  135. ****** Global regex, matching string
  136. match(/x/g /*lastIndex=0*/ , "axbxcxd", 0);
  137. ["x","x","x"]
  138. r.lastIndex=0
  139. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  140. match(/x/g, "axbxcxd", 4);
  141. ["x","x","x"]
  142. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  143. ****** Local regex, non-matching string
  144. match(/x/ /*lastIndex=4*/ , "abc", 0);
  145. null
  146. r.lastIndex=0
  147. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  148. match(/x/, "abc", 4);
  149. null
  150. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  151. ****** Global regex, non-matching string
  152. match(/x/g /*lastIndex=0*/ , "abc", 0);
  153. null
  154. r.lastIndex=0
  155. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  156. match(/x/g, "abc", 4);
  157. null
  158. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  159. ****** Local empty regex
  160. match(/(?:)/ /*lastIndex=4*/ , "axbxcxd", 0);
  161. [""] /*input="axbxcxd", index=0*/
  162. r.lastIndex=0
  163. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  164. match(/(?:)/ /*lastIndex=0*/ , "axbxcxd", 4);
  165. [""] /*input="axbxcxd", index=0*/
  166. r.lastIndex=4
  167. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  168. ****** Global empty regex
  169. match(/(?:)/g /*lastIndex=4*/ , "axbxcxd", 0);
  170. ["","","","","","","",""]
  171. r.lastIndex=0
  172. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  173. match(/(?:)/g, "axbxcxd", 4);
  174. ["","","","","","","",""]
  175. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  176. match(/(a)/gi /*lastIndex=0*/ , "A");
  177. ["A"]
  178. r.lastIndex=0
  179. RegExp.${_,1,...,9}=["A","A","","","","","","","",""]
  180. **************
  181. *** Search ***
  182. **************
  183. ****** Local regex, matching string
  184. search(/x/ /*lastIndex=0*/ , "axbxcxd", 0);
  185. 1
  186. r.lastIndex=0
  187. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  188. search(/x/ /*lastIndex=0*/ , "axbxcxd", 4);
  189. 1
  190. r.lastIndex=4
  191. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  192. ****** Global regex, matching string
  193. search(/x/g /*lastIndex=0*/ , "axbxcxd", 0);
  194. 1
  195. r.lastIndex=0
  196. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  197. search(/x/g /*lastIndex=0*/ , "axbxcxd", 4);
  198. 1
  199. r.lastIndex=4
  200. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  201. ****** Local regex, non-matching string
  202. search(/x/ /*lastIndex=4*/ , "abc", 0);
  203. -1
  204. r.lastIndex=0
  205. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  206. search(/x/ /*lastIndex=0*/ , "abc", 4);
  207. -1
  208. r.lastIndex=4
  209. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  210. ****** Global regex, non-matching string
  211. search(/x/g /*lastIndex=4*/ , "abc", 0);
  212. -1
  213. r.lastIndex=0
  214. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  215. search(/x/g /*lastIndex=0*/ , "abc", 4);
  216. -1
  217. r.lastIndex=4
  218. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  219. ****** Local empty regex
  220. search(/(?:)/ /*lastIndex=4*/ , "axbxcxd", 0);
  221. 0
  222. r.lastIndex=0
  223. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  224. search(/(?:)/ /*lastIndex=0*/ , "axbxcxd", 4);
  225. 0
  226. r.lastIndex=4
  227. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  228. ****** Global empty regex
  229. search(/(?:)/g /*lastIndex=0*/ , "axbxcxd", 0);
  230. 0
  231. r.lastIndex=0
  232. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  233. search(/(?:)/g /*lastIndex=0*/ , "axbxcxd", 4);
  234. 0
  235. r.lastIndex=4
  236. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  237. *************
  238. *** Split ***
  239. *************
  240. ****** Special cases
  241. split(/a/ /*lastIndex=0*/ , "a");
  242. ["",""]
  243. r.lastIndex=0
  244. RegExp.${_,1,...,9}=["a","","","","","","","","",""]
  245. split(/(\b)?/ /*lastIndex=0*/ , "a");
  246. ["a"]
  247. r.lastIndex=0
  248. RegExp.${_,1,...,9}=["a","","","","","","","","",""]
  249. *************************
  250. *** Setting lastIndex ***
  251. *************************
  252. exec(/x/g /*lastIndex=4*/ , "axbxcxd", "0");
  253. ["x"] /*input="axbxcxd", index=1*/
  254. r.lastIndex=2
  255. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  256. exec(/x/g /*lastIndex=2*/ , "axbxcxd", "4");
  257. ["x"] /*input="axbxcxd", index=5*/
  258. r.lastIndex=6
  259. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  260. exec(/x/g /*lastIndex=6*/ , "axbxcxd", 0);
  261. ["x"] /*input="axbxcxd", index=1*/
  262. r.lastIndex=2
  263. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  264. exec(/x/g /*lastIndex=2*/ , "axbxcxd", 4);
  265. ["x"] /*input="axbxcxd", index=5*/
  266. r.lastIndex=6
  267. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  268. exec(/x/g /*lastIndex=6*/ , "axbxcxd", 0.4);
  269. ["x"] /*input="axbxcxd", index=1*/
  270. r.lastIndex=2
  271. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  272. exec(/x/g /*lastIndex=2*/ , "axbxcxd", 0.5);
  273. ["x"] /*input="axbxcxd", index=1*/
  274. r.lastIndex=2
  275. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  276. exec(/x/g /*lastIndex=2*/ , "axbxcxd", 3.7);
  277. ["x"] /*input="axbxcxd", index=3*/
  278. r.lastIndex=4
  279. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  280. exec(/x/g /*lastIndex=4*/ , "axbxcxd", -4);
  281. null
  282. r.lastIndex=0
  283. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  284. exec(/x/g /*lastIndex=0*/ , "axbxcxd", 2147483647);
  285. null
  286. r.lastIndex=0
  287. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  288. exec(/x/g /*lastIndex=0*/ , "axbxcxd", NaN);
  289. ["x"] /*input="axbxcxd", index=1*/
  290. r.lastIndex=2
  291. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  292. exec(/x/g /*lastIndex=2*/ , "axbxcxd", -Infinity);
  293. null
  294. r.lastIndex=0
  295. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  296. exec(/x/g /*lastIndex=0*/ , "axbxcxd", Infinity);
  297. null
  298. r.lastIndex=0
  299. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  300. exec(/x/g /*lastIndex=0*/ , "axbxcxd", 5e-324);
  301. ["x"] /*input="axbxcxd", index=1*/
  302. r.lastIndex=2
  303. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  304. exec(/x/g /*lastIndex=2*/ , "axbxcxd", 2298473438738.997);
  305. null
  306. r.lastIndex=0
  307. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  308. exec(/x/g /*lastIndex=0*/ , "axbxcxd", "bogus");
  309. ["x"] /*input="axbxcxd", index=1*/
  310. r.lastIndex=2
  311. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  312. exec(/x/g /*lastIndex=2*/ , "axbxcxd", [3,2,1]);
  313. ["x"] /*input="axbxcxd", index=1*/
  314. r.lastIndex=2
  315. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  316. exec(/x/g /*lastIndex=2*/ , "axbxcxd", null);
  317. ["x"] /*input="axbxcxd", index=1*/
  318. r.lastIndex=2
  319. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  320. exec(/x/g /*lastIndex=2*/ , "axbxcxd", undefined);
  321. ["x"] /*input="axbxcxd", index=1*/
  322. r.lastIndex=2
  323. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  324. exec(/x/g /*lastIndex=2*/ , "axbxcxd", true);
  325. ["x"] /*input="axbxcxd", index=1*/
  326. r.lastIndex=2
  327. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  328. exec(/x/g /*lastIndex=2*/ , "axbxcxd", false);
  329. ["x"] /*input="axbxcxd", index=1*/
  330. r.lastIndex=2
  331. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  332. exec(/x/g /*lastIndex=2*/ , "axbxcxd", <object with toString>);
  333. ["x"] /*input="axbxcxd", index=5*/
  334. r.lastIndex=6
  335. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  336. *********************************
  337. *** lastIndex on result array ***
  338. *********************************
  339. undefined
  340. undefined