json_parse_Blue_548957.js 920 B

1234567891011121314151617181920212223242526272829
  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. var passed = true;
  6. try {
  7. JSON.parse("0101");
  8. WScript.Echo("Syntax error expected when parsing 0101.");
  9. passed = false;
  10. } catch (ex) {
  11. if (!(ex instanceof SyntaxError)) {
  12. WScript.Echo("Syntax error expected when parsing 0101. Got - " + ex);
  13. }
  14. }
  15. if (JSON.parse("0.101") !== 0.101) {
  16. WScript.Echo("Incorrectly parsed 0.101.");
  17. passed = false;
  18. };
  19. if (JSON.parse("101") !== 101) {
  20. WScript.Echo("Incorrectly parsed 101.");
  21. passed = false;
  22. };
  23. if (passed) {
  24. WScript.Echo("Pass");
  25. }