PageRenderTime 43ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/lahabana/mozilla-central
JavaScript | 129 lines | 71 code | 31 blank | 27 comment | 5 complexity | 0bfa575d5479da0624215cb91be734cb MD5 | raw file
Possible License(s): GPL-2.0, Apache-2.0, LGPL-3.0, AGPL-1.0, LGPL-2.1, BSD-3-Clause, JSON, 0BSD, MIT, MPL-2.0-no-copyleft-exception
  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-002.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. //-----------------------------------------------------------------------------
  14. var SECTION = "RegExp/properties-002.js";
  15. var VERSION = "ECMA_2";
  16. var TITLE = "Properties of RegExp Instances";
  17. var BUGNUMBER ="124339";
  18. startTest();
  19. re_1 = /\cA?/g;
  20. re_1.lastIndex = Math.pow(2,31);
  21. AddRegExpCases( re_1, "\\cA?", true, false, false, Math.pow(2,31) );
  22. re_2 = /\w*/i;
  23. re_2.lastIndex = Math.pow(2,32) -1;
  24. AddRegExpCases( re_2, "\\w*", false, true, false, Math.pow(2,32)-1 );
  25. re_3 = /\*{0,80}/m;
  26. re_3.lastIndex = Math.pow(2,31) -1;
  27. AddRegExpCases( re_3, "\\*{0,80}", false, false, true, Math.pow(2,31) -1 );
  28. re_4 = /^./gim;
  29. re_4.lastIndex = Math.pow(2,30) -1;
  30. AddRegExpCases( re_4, "^.", true, true, true, Math.pow(2,30) -1 );
  31. re_5 = /\B/;
  32. re_5.lastIndex = Math.pow(2,30);
  33. AddRegExpCases( re_5, "\\B", false, false, false, Math.pow(2,30) );
  34. /*
  35. * Brendan: "need to test cases Math.pow(2,32) and greater to see
  36. * whether they round-trip." Reason: thanks to the work done in
  37. * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, lastIndex
  38. * is now stored as a double instead of a uint32_t (unsigned integer).
  39. *
  40. * Note 2^32 -1 is the upper bound for uint32's, but doubles can go
  41. * all the way up to Number.MAX_VALUE. So that's why we need cases
  42. * between those two numbers.
  43. *
  44. */
  45. re_6 = /\B/;
  46. re_6.lastIndex = Math.pow(2,32);
  47. AddRegExpCases( re_6, "\\B", false, false, false, Math.pow(2,32) );
  48. re_7 = /\B/;
  49. re_7.lastIndex = Math.pow(2,32) + 1;
  50. AddRegExpCases( re_7, "\\B", false, false, false, Math.pow(2,32) + 1 );
  51. re_8 = /\B/;
  52. re_8.lastIndex = Math.pow(2,32) * 2;
  53. AddRegExpCases( re_8, "\\B", false, false, false, Math.pow(2,32) * 2 );
  54. re_9 = /\B/;
  55. re_9.lastIndex = Math.pow(2,40);
  56. AddRegExpCases( re_9, "\\B", false, false, false, Math.pow(2,40) );
  57. re_10 = /\B/;
  58. re_10.lastIndex = Number.MAX_VALUE;
  59. AddRegExpCases( re_10, "\\B", false, false, false, Number.MAX_VALUE );
  60. //-----------------------------------------------------------------------------
  61. test();
  62. //-----------------------------------------------------------------------------
  63. function AddRegExpCases( re, s, g, i, m, l ){
  64. AddTestCase( re + ".test == RegExp.prototype.test",
  65. true,
  66. re.test == RegExp.prototype.test );
  67. AddTestCase( re + ".toString == RegExp.prototype.toString",
  68. true,
  69. re.toString == RegExp.prototype.toString );
  70. AddTestCase( re + ".contructor == RegExp.prototype.constructor",
  71. true,
  72. re.constructor == RegExp.prototype.constructor );
  73. AddTestCase( re + ".compile == RegExp.prototype.compile",
  74. true,
  75. re.compile == RegExp.prototype.compile );
  76. AddTestCase( re + ".exec == RegExp.prototype.exec",
  77. true,
  78. re.exec == RegExp.prototype.exec );
  79. // properties
  80. AddTestCase( re + ".source",
  81. s,
  82. re.source );
  83. AddTestCase( re + ".toString()",
  84. "/" + s +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""),
  85. re.toString() );
  86. AddTestCase( re + ".global",
  87. g,
  88. re.global );
  89. AddTestCase( re + ".ignoreCase",
  90. i,
  91. re.ignoreCase );
  92. AddTestCase( re + ".multiline",
  93. m,
  94. re.multiline);
  95. AddTestCase( re + ".lastIndex",
  96. l,
  97. re.lastIndex );
  98. }