lastIndex.baseline 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. *************
  119. *** Match ***
  120. *************
  121. ****** Local regex, matching string
  122. match(/x/ /*lastIndex=0*/ , "axbxcxd", 0);
  123. ["x"] /*input="axbxcxd", index=1*/
  124. r.lastIndex=0
  125. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  126. match(/x/ /*lastIndex=0*/ , "axbxcxd", 4);
  127. ["x"] /*input="axbxcxd", index=1*/
  128. r.lastIndex=4
  129. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  130. ****** Global regex, matching string
  131. match(/x/g /*lastIndex=0*/ , "axbxcxd", 0);
  132. ["x","x","x"]
  133. r.lastIndex=0
  134. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  135. match(/x/g, "axbxcxd", 4);
  136. ["x","x","x"]
  137. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  138. ****** Local regex, non-matching string
  139. match(/x/ /*lastIndex=4*/ , "abc", 0);
  140. null
  141. r.lastIndex=0
  142. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  143. match(/x/, "abc", 4);
  144. null
  145. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  146. ****** Global regex, non-matching string
  147. match(/x/g /*lastIndex=0*/ , "abc", 0);
  148. null
  149. r.lastIndex=0
  150. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  151. match(/x/g, "abc", 4);
  152. null
  153. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  154. ****** Local empty regex
  155. match(/(?:)/ /*lastIndex=4*/ , "axbxcxd", 0);
  156. [""] /*input="axbxcxd", index=0*/
  157. r.lastIndex=0
  158. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  159. match(/(?:)/ /*lastIndex=0*/ , "axbxcxd", 4);
  160. [""] /*input="axbxcxd", index=0*/
  161. r.lastIndex=4
  162. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  163. ****** Global empty regex
  164. match(/(?:)/g /*lastIndex=4*/ , "axbxcxd", 0);
  165. ["","","","","","","",""]
  166. r.lastIndex=0
  167. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  168. match(/(?:)/g, "axbxcxd", 4);
  169. ["","","","","","","",""]
  170. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  171. match(/(a)/gi /*lastIndex=0*/ , "A");
  172. ["A"]
  173. r.lastIndex=0
  174. RegExp.${_,1,...,9}=["A","A","","","","","","","",""]
  175. **************
  176. *** Search ***
  177. **************
  178. ****** Local regex, matching string
  179. search(/x/ /*lastIndex=0*/ , "axbxcxd", 0);
  180. 1
  181. r.lastIndex=0
  182. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  183. search(/x/ /*lastIndex=0*/ , "axbxcxd", 4);
  184. 1
  185. r.lastIndex=4
  186. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  187. ****** Global regex, matching string
  188. search(/x/g /*lastIndex=0*/ , "axbxcxd", 0);
  189. 1
  190. r.lastIndex=0
  191. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  192. search(/x/g /*lastIndex=0*/ , "axbxcxd", 4);
  193. 1
  194. r.lastIndex=4
  195. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  196. ****** Local regex, non-matching string
  197. search(/x/ /*lastIndex=4*/ , "abc", 0);
  198. -1
  199. r.lastIndex=0
  200. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  201. search(/x/ /*lastIndex=0*/ , "abc", 4);
  202. -1
  203. r.lastIndex=4
  204. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  205. ****** Global regex, non-matching string
  206. search(/x/g /*lastIndex=4*/ , "abc", 0);
  207. -1
  208. r.lastIndex=0
  209. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  210. search(/x/g /*lastIndex=0*/ , "abc", 4);
  211. -1
  212. r.lastIndex=4
  213. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  214. ****** Local empty regex
  215. search(/(?:)/ /*lastIndex=4*/ , "axbxcxd", 0);
  216. 0
  217. r.lastIndex=0
  218. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  219. search(/(?:)/ /*lastIndex=0*/ , "axbxcxd", 4);
  220. 0
  221. r.lastIndex=4
  222. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  223. ****** Global empty regex
  224. search(/(?:)/g /*lastIndex=0*/ , "axbxcxd", 0);
  225. 0
  226. r.lastIndex=0
  227. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  228. search(/(?:)/g /*lastIndex=0*/ , "axbxcxd", 4);
  229. 0
  230. r.lastIndex=4
  231. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  232. *************
  233. *** Split ***
  234. *************
  235. ****** Special cases
  236. split(/a/ /*lastIndex=0*/ , "a");
  237. ["",""]
  238. r.lastIndex=0
  239. RegExp.${_,1,...,9}=["a","","","","","","","","",""]
  240. split(/(\b)?/ /*lastIndex=0*/ , "a");
  241. ["a"]
  242. r.lastIndex=0
  243. RegExp.${_,1,...,9}=["a","","","","","","","","",""]
  244. *************************
  245. *** Setting lastIndex ***
  246. *************************
  247. exec(/x/g /*lastIndex=4*/ , "axbxcxd", "0");
  248. ["x"] /*input="axbxcxd", index=1*/
  249. r.lastIndex=2
  250. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  251. exec(/x/g /*lastIndex=2*/ , "axbxcxd", "4");
  252. ["x"] /*input="axbxcxd", index=5*/
  253. r.lastIndex=6
  254. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  255. exec(/x/g /*lastIndex=6*/ , "axbxcxd", 0);
  256. ["x"] /*input="axbxcxd", index=1*/
  257. r.lastIndex=2
  258. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  259. exec(/x/g /*lastIndex=2*/ , "axbxcxd", 4);
  260. ["x"] /*input="axbxcxd", index=5*/
  261. r.lastIndex=6
  262. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  263. exec(/x/g /*lastIndex=6*/ , "axbxcxd", 0.4);
  264. ["x"] /*input="axbxcxd", index=1*/
  265. r.lastIndex=2
  266. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  267. exec(/x/g /*lastIndex=2*/ , "axbxcxd", 0.5);
  268. ["x"] /*input="axbxcxd", index=1*/
  269. r.lastIndex=2
  270. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  271. exec(/x/g /*lastIndex=2*/ , "axbxcxd", 3.7);
  272. ["x"] /*input="axbxcxd", index=3*/
  273. r.lastIndex=4
  274. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  275. exec(/x/g /*lastIndex=4*/ , "axbxcxd", -4);
  276. null
  277. r.lastIndex=0
  278. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  279. exec(/x/g /*lastIndex=0*/ , "axbxcxd", 2147483647);
  280. null
  281. r.lastIndex=0
  282. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  283. exec(/x/g /*lastIndex=0*/ , "axbxcxd", NaN);
  284. ["x"] /*input="axbxcxd", index=1*/
  285. r.lastIndex=2
  286. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  287. exec(/x/g /*lastIndex=2*/ , "axbxcxd", -Infinity);
  288. null
  289. r.lastIndex=0
  290. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  291. exec(/x/g /*lastIndex=0*/ , "axbxcxd", Infinity);
  292. null
  293. r.lastIndex=0
  294. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  295. exec(/x/g /*lastIndex=0*/ , "axbxcxd", 5e-324);
  296. ["x"] /*input="axbxcxd", index=1*/
  297. r.lastIndex=2
  298. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  299. exec(/x/g /*lastIndex=2*/ , "axbxcxd", 2298473438738.997);
  300. null
  301. r.lastIndex=0
  302. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  303. exec(/x/g /*lastIndex=0*/ , "axbxcxd", "bogus");
  304. ["x"] /*input="axbxcxd", index=1*/
  305. r.lastIndex=2
  306. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  307. exec(/x/g /*lastIndex=2*/ , "axbxcxd", [3,2,1]);
  308. ["x"] /*input="axbxcxd", index=1*/
  309. r.lastIndex=2
  310. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  311. exec(/x/g /*lastIndex=2*/ , "axbxcxd", null);
  312. ["x"] /*input="axbxcxd", index=1*/
  313. r.lastIndex=2
  314. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  315. exec(/x/g /*lastIndex=2*/ , "axbxcxd", undefined);
  316. ["x"] /*input="axbxcxd", index=1*/
  317. r.lastIndex=2
  318. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  319. exec(/x/g /*lastIndex=2*/ , "axbxcxd", true);
  320. ["x"] /*input="axbxcxd", index=1*/
  321. r.lastIndex=2
  322. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  323. exec(/x/g /*lastIndex=2*/ , "axbxcxd", false);
  324. ["x"] /*input="axbxcxd", index=1*/
  325. r.lastIndex=2
  326. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  327. exec(/x/g /*lastIndex=2*/ , "axbxcxd", <object with toString>);
  328. ["x"] /*input="axbxcxd", index=5*/
  329. r.lastIndex=6
  330. RegExp.${_,1,...,9}=["axbxcxd","","","","","","","","",""]
  331. *********************************
  332. *** lastIndex on result array ***
  333. *********************************
  334. undefined
  335. undefined