ES6StringTemplateSlow.js 1.8 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: "Octal escape sequences are not allowed in string template literals - exhaustive test",
  9. body: function() {
  10. function verifyOctalThrows(octalNumber) {
  11. if (octalNumber < 10) {
  12. assert.throws(function () { eval('print(`\\00' + octalNumber + '`)'); }, SyntaxError, "Scanning an octal escape sequence " + "`\\00" + octalNumber + "` throws SyntaxError.", "Octal numeric literals and escape characters not allowed in strict mode");
  13. }
  14. if (octalNumber < 100) {
  15. assert.throws(function () { eval('print(`\\0' + octalNumber + '`)'); }, SyntaxError, "Scanning an octal escape sequence " + "`\\0" + octalNumber + "` throws SyntaxError.", "Octal numeric literals and escape characters not allowed in strict mode");
  16. }
  17. assert.throws(function () { eval('print(`\\' + octalNumber + '`)'); }, SyntaxError, "Scanning an octal escape sequence " + "`\\" + octalNumber + "` throws SyntaxError.", "Octal numeric literals and escape characters not allowed in strict mode");
  18. }
  19. for (var i = 1; i <= 255; i++) {
  20. verifyOctalThrows(i.toString(8));
  21. }
  22. }
  23. },
  24. ];
  25. testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });