Lex_u3.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. // auto ';' in return
  6. var a = 1
  7. var b = 3
  8. function foo()
  9. {
  10. if(true)
  11. return /*afsdf
  12. sdafa */ a+b;
  13. }
  14. write(foo())
  15. //full support for <LS><PS>
  16. eval("function foo(){if(true) return \/*afsdf \u2028 sdafa *\/ a+b;} write(foo());")
  17. var x= "str const Left \u000A str const right"
  18. write(x)
  19. try
  20. {
  21. eval('x= \"str const Left \u2028 str const right\";write(escape(x))');
  22. }
  23. catch(e)
  24. {
  25. write("LS in string - compile failure in ES5: not expected." + e)
  26. }
  27. var re = /falls/
  28. try
  29. {
  30. eval('x= \/str const regex \u2028 regex const right\/;write(escape(x))');
  31. }
  32. catch(e)
  33. {
  34. write("LS in regex literal - compile failure in ES5: expected." + e)
  35. }
  36. try
  37. {
  38. eval('x= \"LS in escape sequence string literal \\\u2028 :more string\";write(escape(x))');
  39. }
  40. catch(e)
  41. {
  42. write("LS in escape sequence string literal - compile failure in ES5: not expected." + e)
  43. }
  44. //BOM in strings
  45. try
  46. {
  47. eval('x= 25 + \ufeff 66 ;write(\"BOM is WS : \" + escape(x))');
  48. }
  49. catch(e)
  50. {
  51. write("BOM is WS in unicode 3 - compile failure in ES5: not expected." + e)
  52. }
  53. //<ZVN><ZVNJ>
  54. try
  55. {
  56. eval('var x = new Object(); x.aa\u200cbb = 6 ; for(m in x ) {write(\"ZVNJ is id part : \" + escape(m));}');
  57. }
  58. catch(e)
  59. {
  60. write("ZVNJ is id part in unicode 3 - compile failure in ES5: not expected." + e)
  61. }
  62. function write(a) {
  63. if (this.WScript == undefined) {
  64. document.write(a);
  65. document.write("</br>");
  66. }
  67. else
  68. WScript.Echo(a)
  69. }