PageRenderTime 55ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/LayoutTests/fast/js/resources/regexp-compile.js

https://github.com/kvlasov/qtwebkit
JavaScript | 53 lines | 37 code | 14 blank | 2 comment | 0 complexity | 25cbd74bc3e3758dfb6230bc95d386f0 MD5 | raw file
Possible License(s): BSD-3-Clause, MPL-2.0-no-copyleft-exception, LGPL-2.1, LGPL-2.0
  1. description(
  2. 'Test RegExp.compile method.'
  3. );
  4. re = new RegExp("a", "i");
  5. shouldBe("re.toString()", "'/a/i'");
  6. re.compile("a");
  7. shouldBe("re.multiline", "false");
  8. shouldBe("re.ignoreCase", "false");
  9. shouldBe("re.global", "false");
  10. shouldBe("re.test('A')", "false");
  11. shouldBe("re.toString()", "'/a/'");
  12. re.compile("b", "g");
  13. shouldBe("re.toString()", "'/b/g'");
  14. re.compile(new RegExp("c"));
  15. shouldBe("re.toString()", "'/c/'");
  16. re.compile(new RegExp("c", "i"));
  17. shouldBe("re.ignoreCase", "true");
  18. shouldBe("re.test('C')", "true");
  19. shouldBe("re.toString()", "'/c/i'");
  20. shouldThrow("re.compile(new RegExp('c'), 'i');");
  21. // It's OK to supply a second argument, as long as the argument is "undefined".
  22. re.compile(re, undefined);
  23. shouldBe("re.toString()", "'/c/i'");
  24. shouldThrow("re.compile(new RegExp('+'));");
  25. re.compile(undefined);
  26. shouldBe("re.toString()", "'/undefined/'");
  27. re.compile(null);
  28. shouldBe("re.toString()", "'/null/'");
  29. re.compile();
  30. shouldBe("re.toString()", "'//'"); // /(?:)/ in Firefox
  31. re.compile("z", undefined);
  32. shouldBe("re.toString()", "'/z/'");
  33. // Compiling should reset lastIndex.
  34. re.lastIndex = 100;
  35. re.compile(/a/g);
  36. shouldBe("re.lastIndex", "0");
  37. re.exec("aaa");
  38. shouldBe("re.lastIndex", "1");
  39. var successfullyParsed = true;