diff --git a/src/org/mozilla/javascript/TokenStream.java b/src/org/mozilla/javascript/TokenStream.java index 15ad0ae5a0..22f3b51983 100644 --- a/src/org/mozilla/javascript/TokenStream.java +++ b/src/org/mozilla/javascript/TokenStream.java @@ -1115,6 +1115,10 @@ final int getToken() throws IOException { String str = getStringFromBuffer(); this.string = (String) allStrings.intern(str); return Token.STRING; + } else if (c == '#' && cursor == 1 && peekChar() == '!' && !this.parser.calledByCompileFunction) { + // #! hashbang: only on the first line of a Script, no leading whitespace + skipLine(); + return Token.COMMENT; } switch (c) { diff --git a/testsrc/org/mozilla/javascript/tests/Test262SuiteTest.java b/testsrc/org/mozilla/javascript/tests/Test262SuiteTest.java index db31713b23..70ee634479 100644 --- a/testsrc/org/mozilla/javascript/tests/Test262SuiteTest.java +++ b/testsrc/org/mozilla/javascript/tests/Test262SuiteTest.java @@ -116,7 +116,6 @@ public class Test262SuiteTest { "String.prototype.matchAll", "Symbol.matchAll", "tail-call-optimization", - "hashbang", "u180e")); static { diff --git a/testsrc/test262.properties b/testsrc/test262.properties index 23251c6462..30b5b4c2af 100644 --- a/testsrc/test262.properties +++ b/testsrc/test262.properties @@ -2712,8 +2712,9 @@ language/block-scope 68/145 (46.9%) syntax/redeclaration/var-redeclaration-attempt-after-function.js syntax/redeclaration/var-redeclaration-attempt-after-generator.js -language/comments 36/52 (69.23%) - hashbang 29/29 (100.0%) +language/comments 9/52 (17.31%) + hashbang/function-constructor.js + hashbang/module.js {unsupported: [module]} mongolian-vowel-separator-multi.js {unsupported: [u180e]} mongolian-vowel-separator-single.js {unsupported: [u180e]} mongolian-vowel-separator-single-eval.js {unsupported: [u180e]}