01.octal_sm.js 1.1 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. "use strict";
  6. function write(v) { WScript.Echo(v + ""); }
  7. // Octal number
  8. (function Test1() {
  9. var str = "Octal number";
  10. try {
  11. eval("01");
  12. } catch (e) {
  13. write("Exception: " + str);
  14. return;
  15. }
  16. write("Return: " + str);
  17. })();
  18. // Octal string literal
  19. (function Test2() {
  20. var str = "Octal string literal";
  21. try {
  22. eval("\'\\02\'");
  23. } catch (e) {
  24. write("Exception: " + str);
  25. return;
  26. }
  27. write("Return: " + str);
  28. })();
  29. // Hex followed by octal
  30. (function Test3() {
  31. var str = "Octal number following a hex number";
  32. var a;
  33. try {
  34. eval("a = 0x1; a = 01;");
  35. }
  36. catch (e) {
  37. write("Exception: " + str);
  38. return;
  39. }
  40. write("Return: " + str);
  41. })();