HTMLComments.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. /* NOTE: This file needs to be treated as binary. It contains mixed line endings, including non-standard
  6. * line endings. Most text editors will not handle the file correctly. If you need to edit this
  7. * file, make sure you do a binary compare to ensure the non-standard line endings have not been lost.
  8. *
  9. * 'LS' refers to Unicode Character 'LINE SEPARATOR' (U+2028)
  10. * 'PS' refers to Unicode Character 'PARAGRAPH SEPARATOR' (U+2029)
  11. */
  12. WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
  13. /*
  14. * Line terminator sequences - standard (11.3 LineTerminator)
  15. */
  16. // CRLF
  17. WScript.Echo("Code before CRLF--> is reachable");
  18. --> WScript.Echo("Code after CRLF--> is unreachable");
  19. // CR
  20. WScript.Echo("Code before CR--> is reachable"); --> WScript.Echo("Code after CR--> is unreachable");
  21. // LF
  22. WScript.Echo("Code before LF--> is reachable");
  23. --> WScript.Echo("Code after LF--> is unreachable");
  24. // LS
  25. WScript.Echo("Code before LS--> is reachable");
--> WScript.Echo("Code after LS--> is unreachable");
  26. // PS
  27. WScript.Echo("Code before PS--> is reachable");
--> WScript.Echo("Code after PS--> is unreachable");
  28. /*
  29. * Line terminator sequences - non-standard (11.3 LineTerminatorSequence <CR>[lookahead != <LF>])
  30. */
  31. // CRLS
  32. WScript.Echo("Code before CRLS--> is reachable"); 
--> WScript.Echo("Code after CRLS--> is unreachable");
  33. // CRPS
  34. WScript.Echo("Code before CRPS--> is reachable"); 
--> WScript.Echo("Code after CRPS--> is unreachable");
  35. // HTML open comment comments out the rest of the line
  36. WScript.Echo("Code before <!-- is reachable"); <!-- WScript.Echo("Code after <!-- is unreachable");
  37. WScript.Echo("Code before <!-- --> is reachable"); <!-- --> WScript.Echo("Code after <!-- --> is unreachable");
  38. // Split multiline HTML comment comments out both lines
  39. WScript.Echo("Code before <!-- LineTerminator --> is reachable"); <!-- WScript.Echo("Code after multiline <!-- is unreachable");
  40. --> WScript.Echo("Code after <!-- LineTerminator --> is unreachable");
  41. // Delimited comments syntax
  42. /* Multi
  43. Line
  44. Comment */ --> WScript.Echo("Code after */ --> is unreachable");
  45. WScript.Echo("Code before /* */ --> is reachable"); /* Comment */ --> WScript.Echo("Code after /* */ --> is unreachable");
  46. WScript.Echo("Code before /* */--> is reachable"); /* Comment */--> WScript.Echo("Code after /* */--> is unreachable"); // No WhiteSpaceSequence
  47. // Post-decrement with a greater-than comparison does not get interpreted as a comment
  48. var a = 1; a-->a; WScript.Echo("Code after post-decrement with a greater-than comparison (-->) is reachable");
  49. assert.areEqual(0, a, "Post decrement executes");
  50. assert.throws(function () { eval('/* */ --->'); }, SyntaxError, "HTMLCloseComment causes syntax error with an extra -", "Syntax error");