bug_258259.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. // 000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889
  6. // 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
  7. var expectedError = "Error: aİc\n\tat aTurkish (bug_258259.js:12:5)\n\tat Global code (bug_258259.js:34:9)";
  8. //-- Turkish 'i' character in error message and file name
  9. function aTurkish() {
  10. throw Error("aİc");
  11. }
  12. function filterFullFilePathFromCallstack(cs) {
  13. var filteredStack = cs;
  14. var fileName = "bug_258259.js:";
  15. var startDelim = " (";
  16. // remove full path from the file name in the call stack (x2)
  17. var lastInd = filteredStack.lastIndexOf(fileName);
  18. var firstInd = filteredStack.lastIndexOf(startDelim, lastInd);
  19. filteredStack = filteredStack.substring(0, firstInd + startDelim.length) + filteredStack.substring(lastInd);
  20. lastInd = filteredStack.lastIndexOf(fileName);
  21. lastInd = filteredStack.lastIndexOf(fileName, lastInd - 1);
  22. firstInd = filteredStack.lastIndexOf(startDelim, lastInd);
  23. filteredStack = filteredStack.substring(0, firstInd + startDelim.length) + filteredStack.substring(lastInd);
  24. return filteredStack;
  25. }
  26. try {
  27. aTurkish();
  28. } catch (ex) {
  29. var filteredStack = filterFullFilePathFromCallstack([ex.stack].toString());
  30. if (filteredStack == expectedError) {
  31. WScript.Echo("PASSED");
  32. } else {
  33. WScript.Echo("FAILED");
  34. WScript.Echo("\nActual (raw):\n" + [ex.stack]);
  35. WScript.Echo("\nActual (filtered):\n" + filteredStack);
  36. WScript.Echo("\n\nExpected:\n" + expectedError);
  37. }
  38. }