PageRenderTime 26ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/external/webkit/Source/JavaScriptCore/tests/mozilla/ecma_3/RegExp/15.10.2-1.js

https://gitlab.com/brian0218/rk3188_r-box_android4.2.2_sdk
JavaScript | 176 lines | 109 code | 21 blank | 46 comment | 0 complexity | b609e567f32e056244c21cae8171c7d4 MD5 | raw file
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: NPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Netscape Public License
  5. * Version 1.1 (the "License"); you may not use this file except in
  6. * compliance with the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/NPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Original Code is JavaScript Engine testing utilities.
  15. *
  16. * The Initial Developer of the Original Code is Netscape Communications Corp.
  17. * Portions created by the Initial Developer are Copyright (C) 2002
  18. * the Initial Developer. All Rights Reserved.
  19. *
  20. * Contributor(s): rogerl@netscape.com, pschwartau@netscape.com
  21. *
  22. * Alternatively, the contents of this file may be used under the terms of
  23. * either the GNU General Public License Version 2 or later (the "GPL"), or
  24. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  25. * in which case the provisions of the GPL or the LGPL are applicable instead
  26. * of those above. If you wish to allow use of your version of this file only
  27. * under the terms of either the GPL or the LGPL, and not to allow others to
  28. * use your version of this file under the terms of the NPL, indicate your
  29. * decision by deleting the provisions above and replace them with the notice
  30. * and other provisions required by the GPL or the LGPL. If you do not delete
  31. * the provisions above, a recipient may use your version of this file under
  32. * the terms of any one of the NPL, the GPL or the LGPL.
  33. *
  34. * ***** END LICENSE BLOCK *****
  35. *
  36. *
  37. * Date: 09 July 2002
  38. * SUMMARY: RegExp conformance test
  39. *
  40. * These testcases are derived from the examples in the ECMA-262 Ed.3 spec
  41. * scattered through section 15.10.2.
  42. *
  43. */
  44. //-----------------------------------------------------------------------------
  45. var i = 0;
  46. var bug = '(none)';
  47. var summary = 'RegExp conformance test';
  48. var status = '';
  49. var statusmessages = new Array();
  50. var pattern = '';
  51. var patterns = new Array();
  52. var string = '';
  53. var strings = new Array();
  54. var actualmatch = '';
  55. var actualmatches = new Array();
  56. var expectedmatch = '';
  57. var expectedmatches = new Array();
  58. status = inSection(1);
  59. pattern = /a|ab/;
  60. string = 'abc';
  61. actualmatch = string.match(pattern);
  62. expectedmatch = Array('a');
  63. addThis();
  64. status = inSection(2);
  65. pattern = /((a)|(ab))((c)|(bc))/;
  66. string = 'abc';
  67. actualmatch = string.match(pattern);
  68. expectedmatch = Array('abc', 'a', 'a', undefined, 'bc', undefined, 'bc');
  69. addThis();
  70. status = inSection(3);
  71. pattern = /a[a-z]{2,4}/;
  72. string = 'abcdefghi';
  73. actualmatch = string.match(pattern);
  74. expectedmatch = Array('abcde');
  75. addThis();
  76. status = inSection(4);
  77. pattern = /a[a-z]{2,4}?/;
  78. string = 'abcdefghi';
  79. actualmatch = string.match(pattern);
  80. expectedmatch = Array('abc');
  81. addThis();
  82. status = inSection(5);
  83. pattern = /(aa|aabaac|ba|b|c)*/;
  84. string = 'aabaac';
  85. actualmatch = string.match(pattern);
  86. expectedmatch = Array('aaba', 'ba');
  87. addThis();
  88. status = inSection(6);
  89. pattern = /^(a+)\1*,\1+$/;
  90. string = 'aaaaaaaaaa,aaaaaaaaaaaaaaa';
  91. actualmatch = string.match(pattern);
  92. expectedmatch = Array('aaaaaaaaaa,aaaaaaaaaaaaaaa', 'aaaaa');
  93. addThis();
  94. status = inSection(7);
  95. pattern = /(z)((a+)?(b+)?(c))*/;
  96. string = 'zaacbbbcac';
  97. actualmatch = string.match(pattern);
  98. expectedmatch = Array('zaacbbbcac', 'z', 'ac', 'a', undefined, 'c');
  99. addThis();
  100. status = inSection(8);
  101. pattern = /(a*)*/;
  102. string = 'b';
  103. actualmatch = string.match(pattern);
  104. expectedmatch = Array('', undefined);
  105. addThis();
  106. status = inSection(9);
  107. pattern = /(a*)b\1+/;
  108. string = 'baaaac';
  109. actualmatch = string.match(pattern);
  110. expectedmatch = Array('b', '');
  111. addThis();
  112. status = inSection(10);
  113. pattern = /(?=(a+))/;
  114. string = 'baaabac';
  115. actualmatch = string.match(pattern);
  116. expectedmatch = Array('', 'aaa');
  117. addThis();
  118. status = inSection(11);
  119. pattern = /(?=(a+))a*b\1/;
  120. string = 'baaabac';
  121. actualmatch = string.match(pattern);
  122. expectedmatch = Array('aba', 'a');
  123. addThis();
  124. status = inSection(12);
  125. pattern = /(.*?)a(?!(a+)b\2c)\2(.*)/;
  126. string = 'baaabaac';
  127. actualmatch = string.match(pattern);
  128. expectedmatch = Array('baaabaac', 'ba', undefined, 'abaac');
  129. addThis();
  130. status = inSection(13);
  131. pattern = /(?=(a+))/;
  132. string = 'baaabac';
  133. actualmatch = string.match(pattern);
  134. expectedmatch = Array('', 'aaa');
  135. addThis();
  136. //-------------------------------------------------------------------------------------------------
  137. test();
  138. //-------------------------------------------------------------------------------------------------
  139. function addThis()
  140. {
  141. statusmessages[i] = status;
  142. patterns[i] = pattern;
  143. strings[i] = string;
  144. actualmatches[i] = actualmatch;
  145. expectedmatches[i] = expectedmatch;
  146. i++;
  147. }
  148. function test()
  149. {
  150. enterFunc ('test');
  151. printBugNumber (bug);
  152. printStatus (summary);
  153. testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
  154. exitFunc ('test');
  155. }