Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: test/mjsunit/regexp.js

Issue 13168: Moved regexp-tests that fail on JSCRE to separate file, and made it PASS || FAIL. (Closed)
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/mjsunit.status ('k') | test/mjsunit/regexp-UC16.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 assertTrue(/foo$(?=(ball)?)/.test("foo"), "football11"); 258 assertTrue(/foo$(?=(ball)?)/.test("foo"), "football11");
259 assertTrue(/foo$(?!bar)/.test("foo"), "football12"); 259 assertTrue(/foo$(?!bar)/.test("foo"), "football12");
260 260
261 // Check that the back reference has two successors. See 261 // Check that the back reference has two successors. See
262 // BackReferenceNode::PropagateForward. 262 // BackReferenceNode::PropagateForward.
263 assertFalse(/f(o)\b\1/.test('foo')); 263 assertFalse(/f(o)\b\1/.test('foo'));
264 assertTrue(/f(o)\B\1/.test('foo')); 264 assertTrue(/f(o)\B\1/.test('foo'));
265 265
266 // Back-reference, ignore case: 266 // Back-reference, ignore case:
267 // ASCII 267 // ASCII
268 assertEquals("xaAx,a", String(/x(a)\1x/i.exec("xaAx")), "\\1 ASCII"); 268 assertEquals("xaAx,a", String(/x(a)\1x/i.exec("xaAx")), "backref-ASCII");
269 assertFalse(/x(...)\1/i.test("xaaaaa"), "\\1 ASCII, string short"); 269 assertFalse(/x(...)\1/i.test("xaaaaa"), "backref-ASCII-short");
270 assertTrue(/x((?:))\1\1x/i.test("xx"), "\\1 empty, ASCII"); 270 assertTrue(/x((?:))\1\1x/i.test("xx"), "backref-ASCII-empty");
271 assertTrue(/x(?:...|(...))\1x/i.test("xabcx"), "\\1 uncaptured, ASCII"); 271 assertTrue(/x(?:...|(...))\1x/i.test("xabcx"), "backref-ASCII-uncaptured");
272 assertTrue(/x(?:...|(...))\1x/i.test("xabcABCx"), "\\1 backtrack, ASCII"); 272 assertTrue(/x(?:...|(...))\1x/i.test("xabcABCx"), "backref-ASCII-backtrack");
273 assertEquals("xaBcAbCABCx,aBc", 273 assertEquals("xaBcAbCABCx,aBc",
274 String(/x(...)\1\1x/i.exec("xaBcAbCABCx")), 274 String(/x(...)\1\1x/i.exec("xaBcAbCABCx")),
275 "\\1\\1 ASCII"); 275 "backref-ASCII-twice");
276 276
277 for (var i = 0; i < 128; i++) { 277 for (var i = 0; i < 128; i++) {
278 var testName = "(.)\\1 ~ " + i + "," + (i^0x20); 278 var testName = "backref-ASCII-char-" + i + "," + (i^0x20);
279 var test = /^(.)\1$/i.test(String.fromCharCode(i, i ^ 0x20)) 279 var test = /^(.)\1$/i.test(String.fromCharCode(i, i ^ 0x20))
280 var c = String.fromCharCode(i); 280 var c = String.fromCharCode(i);
281 if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')) { 281 if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')) {
282 assertTrue(test, testName); 282 assertTrue(test, testName);
283 } else { 283 } else {
284 assertFalse(test, testName); 284 assertFalse(test, testName);
285 } 285 }
286 } 286 }
287 287
288 // UC16
289 // Characters used:
290 // "\u03a3\u03c2\u03c3\u039b\u03bb" - Sigma, final sigma, sigma, Lambda, lamda
291 assertEquals("x\u03a3\u03c3x,\u03a3",
292 String(/x(.)\1x/i.exec("x\u03a3\u03c3x")), "\\1 UC16");
293 assertFalse(/x(...)\1/i.test("x\u03a3\u03c2\u03c3\u03c2\u03c3"),
294 "\\1 ASCII, string short");
295 assertTrue(/\u03a3((?:))\1\1x/i.test("\u03c2x"), "\\1 empty, UC16");
296 assertTrue(/x(?:...|(...))\1x/i.test("x\u03a3\u03c2\u03c3x"),
297 "\\1 uncaptured, UC16");
298 assertTrue(/x(?:...|(...))\1x/i.test("x\u03c2\u03c3\u039b\u03a3\u03c2\u03bbx"),
299 "\\1 backtrack, UC16");
300 var longUC16String = "x\u03a3\u03c2\u039b\u03c2\u03c3\u03bb\u03c3\u03a3\u03bb";
301 assertEquals(longUC16String + "," + longUC16String.substring(1,4),
302 String(/x(...)\1\1/i.exec(longUC16String)),
303 "\\1\\1 UC16");
304
305 assertFalse(/f(o)$\1/.test('foo'), "backref detects at_end"); 288 assertFalse(/f(o)$\1/.test('foo'), "backref detects at_end");
OLDNEW
« no previous file with comments | « test/mjsunit/mjsunit.status ('k') | test/mjsunit/regexp-UC16.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698