diff --git a/rhino/src/main/java/org/mozilla/javascript/Token.java b/rhino/src/main/java/org/mozilla/javascript/Token.java index 3405f3885f..5218c13760 100644 --- a/rhino/src/main/java/org/mozilla/javascript/Token.java +++ b/rhino/src/main/java/org/mozilla/javascript/Token.java @@ -32,6 +32,7 @@ public static enum CommentType { public static final int // start enum ERROR = -1, // well-known as the only code < EOF + FIRST_TOKEN = ERROR, EOF = ERROR + 1, // end of file token - (not EOF_CHAR) EOL = EOF + 1, // end of line @@ -586,6 +587,8 @@ public static String typeToName(int token) { return "CONST"; case SETCONST: return "SETCONST"; + case SETCONSTVAR: + return "SETCONSTVAR"; case ARRAYCOMP: return "ARRAYCOMP"; case WITHEXPR: @@ -606,6 +609,12 @@ public static String typeToName(int token) { return "YIELD_STAR"; case BIGINT: return "BIGINT"; + case GETPROP_OPTIONAL: + return "GETPROP_OPTIONAL"; + case REF_SPECIAL_OPTIONAL: + return "REF_SPECIAL_OPTIONAL"; + case CALL_OPTIONAL: + return "CALL_OPTIONAL"; case TEMPLATE_LITERAL: return "TEMPLATE_LITERAL"; case TEMPLATE_CHARS: @@ -614,6 +623,8 @@ public static String typeToName(int token) { return "TEMPLATE_LITERAL_SUBST"; case TAGGED_TEMPLATE_LITERAL: return "TAGGED_TEMPLATE_LITERAL"; + case DOTDOTDOT: + return "DOTDOTDOT"; case QUESTION_DOT: return "DOT_QUESTION"; } diff --git a/rhino/src/test/java/org/mozilla/javascript/TokenTest.java b/rhino/src/test/java/org/mozilla/javascript/TokenTest.java new file mode 100644 index 0000000000..66f80f0805 --- /dev/null +++ b/rhino/src/test/java/org/mozilla/javascript/TokenTest.java @@ -0,0 +1,16 @@ +package org.mozilla.javascript; + +import static org.junit.Assert.assertNotNull; +import static org.mozilla.javascript.Token.FIRST_TOKEN; +import static org.mozilla.javascript.Token.LAST_TOKEN; + +import org.junit.Test; + +public class TokenTest { + @Test + public void allTokensHaveAName() { + for (int token = FIRST_TOKEN; token < LAST_TOKEN; ++token) { + assertNotNull(Token.typeToName(token)); + } + } +}