PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/js/src/tests/ecma_2/RegExp/properties-001.js

https://bitbucket.org/Jiten/mozilla-central
JavaScript | 91 lines | 53 code | 20 blank | 18 comment | 5 complexity | 8a6a6ea09b41c9295799438b39036f9c MD5 | raw file
Possible License(s): JSON, Apache-2.0, 0BSD, LGPL-3.0, BSD-2-Clause, AGPL-1.0, MPL-2.0, GPL-2.0, LGPL-2.1, MIT, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. * File Name: RegExp/properties-001.js
  7. * ECMA Section: 15.7.6.js
  8. * Description: Based on ECMA 2 Draft 7 February 1999
  9. *
  10. * Author: christine@netscape.com
  11. * Date: 19 February 1999
  12. */
  13. var SECTION = "RegExp/properties-001.js";
  14. var VERSION = "ECMA_2";
  15. var TITLE = "Properties of RegExp Instances";
  16. var BUGNUMBER ="";
  17. startTest();
  18. AddRegExpCases( new RegExp, "", false, false, false, 0 );
  19. AddRegExpCases( /.*/, ".*", false, false, false, 0 );
  20. AddRegExpCases( /[\d]{5}/g, "[\\d]{5}", true, false, false, 0 );
  21. AddRegExpCases( /[\S]?$/i, "[\\S]?$", false, true, false, 0 );
  22. AddRegExpCases( /^([a-z]*)[^\w\s\f\n\r]+/m, "^([a-z]*)[^\\w\\s\\f\\n\\r]+", false, false, true, 0 );
  23. AddRegExpCases( /[\D]{1,5}[\ -][\d]/gi, "[\\D]{1,5}[\\ -][\\d]", true, true, false, 0 );
  24. AddRegExpCases( /[a-zA-Z0-9]*/gm, "[a-zA-Z0-9]*", true, false, true, 0 );
  25. AddRegExpCases( /x|y|z/gim, "x|y|z", true, true, true, 0 );
  26. AddRegExpCases( /\u0051/im, "\\u0051", false, true, true, 0 );
  27. AddRegExpCases( /\x45/gm, "\\x45", true, false, true, 0 );
  28. AddRegExpCases( /\097/gi, "\\097", true, true, false, 0 );
  29. test();
  30. function AddRegExpCases( re, s, g, i, m, l ) {
  31. AddTestCase( re + ".test == RegExp.prototype.test",
  32. true,
  33. re.test == RegExp.prototype.test );
  34. AddTestCase( re + ".toString == RegExp.prototype.toString",
  35. true,
  36. re.toString == RegExp.prototype.toString );
  37. AddTestCase( re + ".contructor == RegExp.prototype.constructor",
  38. true,
  39. re.constructor == RegExp.prototype.constructor );
  40. AddTestCase( re + ".compile == RegExp.prototype.compile",
  41. true,
  42. re.compile == RegExp.prototype.compile );
  43. AddTestCase( re + ".exec == RegExp.prototype.exec",
  44. true,
  45. re.exec == RegExp.prototype.exec );
  46. // properties
  47. AddTestCase( re + ".source",
  48. s,
  49. re.source );
  50. /*
  51. * http://bugzilla.mozilla.org/show_bug.cgi?id=225550 changed
  52. * the behavior of toString() and toSource() on empty regexps.
  53. * So branch if |s| is the empty string -
  54. */
  55. var S = s? s : '(?:)';
  56. AddTestCase( re + ".toString()",
  57. "/" + S +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""),
  58. re.toString() );
  59. AddTestCase( re + ".global",
  60. g,
  61. re.global );
  62. AddTestCase( re + ".ignoreCase",
  63. i,
  64. re.ignoreCase );
  65. AddTestCase( re + ".multiline",
  66. m,
  67. re.multiline);
  68. AddTestCase( re + ".lastIndex",
  69. l,
  70. re.lastIndex );
  71. }