scanner.js 1.3 KB

12345678910111213141516171819202122232425262728
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
  6. var tests = [
  7. {
  8. name: "SyncToLiteralsAndBackupInst should continue scanning for a literal from the furthest point scanned in the previous iteration",
  9. body: function () {
  10. var re = /<(foo|bar)/;
  11. var string = "0bar1<1<foo";
  12. // We first find "foo" at index 8, but then find "bar" at index 1.
  13. // Since the index of the "bar" is lower, we try to match at that
  14. // position. However, the "bar" isn't preceded by a '<', so we
  15. // retry again. In the second iteration, we're supposed to match
  16. // the string at index 7, right before the "foo".
  17. var result = re.exec(string);
  18. assert.areNotEqual(null, result, "result");
  19. assert.areEqual(7, result.index, "result.index");
  20. }
  21. },
  22. ];
  23. testRunner.runTests(tests, { verbose: WScript.Arguments[0] != 'summary' });