{"action":"created","comment":{"url":"https://api.github.com/repos/shapesecurity/shift-java/pulls/comments/37423676","id":37423676,"diff_hunk":"@@ -0,0 +1,536 @@\n+/*\n+ * Copyright 2014 Shape Security, Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package com.shapesecurity.shift.validator;\n+\n+import com.shapesecurity.functional.data.ImmutableList;\n+import com.shapesecurity.functional.data.Maybe;\n+import com.shapesecurity.shift.ast.*;\n+import com.shapesecurity.shift.parser.JsError;\n+import com.shapesecurity.shift.parser.Parser;\n+import org.junit.Test;\n+\n+import static org.junit.Assert.assertEquals;\n+\n+public class ValidatorTest {\n+\n+  private void assertCorrectFailures(Script script, int expectedNumErrors, String expectedErrorMsg) {\n+    ImmutableList<ValidationError> errors = Validator.validate(script);\n+    assertEquals(expectedNumErrors, errors.length);\n+    for (ValidationError error : errors) {\n+      assertEquals(error.message, expectedErrorMsg);\n+    }\n+  }\n+\n+  private void assertCorrectFailures(Module module, int expectedNumErrors, String expectedErrorMsg) {\n+    ImmutableList<ValidationError> errors = Validator.validate(module);\n+    assertEquals(expectedNumErrors, errors.length);\n+    for (ValidationError error : errors) {\n+      assertEquals(error.message, expectedErrorMsg);\n+    }\n+  }\n+\n+  @Test\n+  public void testBindingIdentifier() throws JsError {\n+    Script test0 = Parser.parseScript(\"x=1\");\n+    assertCorrectFailures(test0, 0, \"\");\n+\n+    Script test1 = new Script(ImmutableList.nil(), ImmutableList.list(new ExpressionStatement(new AssignmentExpression(new BindingIdentifier(\"1\"), new LiteralNumericExpression(0.0)))));\n+    assertCorrectFailures(test1, 1, ValidationErrorMessages.VALID_BINDING_IDENTIFIER_NAME);\n+  }\n+\n+  @Test\n+  public void testBreakStatement() throws JsError {\n+    Script test0 = Parser.parseScript(\"for(var i = 0; i < 10; i++) { break; }\");\n+    assertCorrectFailures(test0, 0, \"\");\n+\n+    Script test1 = Parser.parseScript(\"done: while (true) { break done; }\");\n+    assertCorrectFailures(test1, 0, \"\");\n+\n+    Script test2 = new Script(ImmutableList.nil(), ImmutableList.list(new LabeledStatement(\"done\", new WhileStatement(new LiteralBooleanExpression(true), new BlockStatement(new Block(ImmutableList.list(new BreakStatement(Maybe.just(\"1done\")))))))));\n+    assertCorrectFailures(test2, 1, ValidationErrorMessages.VALID_BREAK_STATEMENT_LABEL);\n+  }\n+\n+  @Test\n+  public void testCatchClause() throws JsError {\n+    Script test0 = Parser.parseScript(\"try{} catch(e){} finally{}\");\n+    assertCorrectFailures(test0, 0, \"\");\n+\n+    Script test1 = new Script(ImmutableList.nil(), ImmutableList.list(new TryFinallyStatement(new Block(ImmutableList.nil()), Maybe.just(new CatchClause(new ComputedMemberExpression(new IdentifierExpression(\"a\"), new IdentifierExpression(\"b\")), new Block(ImmutableList.nil()))), new Block(ImmutableList.nil()))));\n+    assertCorrectFailures(test1, 1, ValidationErrorMessages.CATCH_CLAUSE_BINDING_NOT_MEMBER_EXPRESSION);\n+\n+    Script test2 = new Script(ImmutableList.nil(), ImmutableList.list(new TryFinallyStatement(new Block(ImmutableList.nil()), Maybe.just(new CatchClause(new StaticMemberExpression(\"a\", new IdentifierExpression(\"b\")), new Block(ImmutableList.nil()))), new Block(ImmutableList.nil()))));\n+    assertCorrectFailures(test2, 1, ValidationErrorMessages.CATCH_CLAUSE_BINDING_NOT_MEMBER_EXPRESSION);\n+  }\n+\n+  @Test\n+  public void testContinueStatement() throws JsError {\n+    Script test0 = Parser.parseScript(\"for(var i = 0; i < 10; i++) { continue; }\");\n+    assertCorrectFailures(test0, 0, \"\");\n+\n+    Script test1 = Parser.parseScript(\"done: while (true) { continue done; }\");\n+    assertCorrectFailures(test1, 0, \"\");\n+\n+    Script test2 = new Script(ImmutableList.nil(), ImmutableList.list(new LabeledStatement(\"done\", new WhileStatement(new LiteralBooleanExpression(true), new BlockStatement(new Block(ImmutableList.list(new ContinueStatement(Maybe.just(\"1done\")))))))));\n+    assertCorrectFailures(test2, 1, ValidationErrorMessages.VALID_CONTINUE_STATEMENT_LABEL);\n+  }\n+\n+  @Test\n+  public void testDirective() {\n+    Script test0 = new Script(ImmutableList.list(new Directive(\"use strict;\"), new Directive(\"linda;\"), new Directive(\".-#($*&#\")), ImmutableList.nil());\n+    assertCorrectFailures(test0, 0, \"\");\n+\n+    Script test1 = new Script(ImmutableList.list(new Directive(\"'use strict;\")), ImmutableList.nil());\n+    assertCorrectFailures(test1, 1, ValidationErrorMessages.VALID_DIRECTIVE);\n+\n+    Script test2 = new Script(ImmutableList.list(new Directive(\"'use strict;\"), new Directive(\"linda';\"), new Directive(\"'.-#($*&#\")), ImmutableList.nil());\n+    assertCorrectFailures(test2, 3, ValidationErrorMessages.VALID_DIRECTIVE);\n+\n+    Script test3 = new Script(ImmutableList.list(new Directive(\"'use stri\\\"ct;\"), new Directive(\"li\\\"nda;'\"), new Directive(\".-\\\"#'($*&#\")), ImmutableList.nil());\n+    assertCorrectFailures(test3, 3, ValidationErrorMessages.VALID_DIRECTIVE);\n+\n+    Script test4 = new Script(ImmutableList.list(new Directive(\"'use s\\ntrict;\"), new Directive(\"lind\\na;'\"), new Directive(\".-#'($\\n*&#\")), ImmutableList.nil());\n+    assertCorrectFailures(test4, 3, ValidationErrorMessages.VALID_DIRECTIVE);\n+\n+    Script test5 = new Script(ImmutableList.list(new Directive(\"'use s\\rtrict;\"), new Directive(\"lind\\ra;'\"), new Directive(\".-#'($\\r*&#\")), ImmutableList.nil());\n+    assertCorrectFailures(test5, 3, ValidationErrorMessages.VALID_DIRECTIVE);\n+\n+    Script test6 = new Script(ImmutableList.list(new Directive(\"('\\\\x0');\"), new Directive(\"('\\u2028')\"), new Directive(\"(\\\\u{110000}\\\\\\\")\")), ImmutableList.nil());\n+    assertCorrectFailures(test6, 3, ValidationErrorMessages.VALID_DIRECTIVE);\n+  }\n+\n+  @Test\n+  public void testExportSpecifier() throws JsError {\n+    Module test0 = Parser.parseModule(\"export * from 'a';\");\n+    assertCorrectFailures(test0, 0, \"\");\n+\n+    Module test1 = new Module(ImmutableList.nil(), ImmutableList.list(new ExportFrom(ImmutableList.list(new ExportSpecifier(Maybe.just(\"2a_\"), \"b\")), Maybe.just(\"a\"))));\n+    assertCorrectFailures(test1, 1, ValidationErrorMessages.VALID_EXPORT_SPECIFIER_NAME);\n+\n+    Module test2 = new Module(ImmutableList.nil(), ImmutableList.list(new ExportFrom(ImmutableList.list(new ExportSpecifier(Maybe.just(\"b\"), \"%dlk45\")), Maybe.just(\"a\"))));\n+    assertCorrectFailures(test2, 1, ValidationErrorMessages.VALID_EXPORTED_NAME);\n+\n+    Module test3 = new Module(ImmutableList.nil(), ImmutableList.list(new ExportFrom(ImmutableList.list(new ExportSpecifier(Maybe.nothing(), \"a\")), Maybe.just(\"a\"))));\n+    assertCorrectFailures(test3, 0, \"\");\n+  }\n+\n+  @Test\n+  public void testForInStatement() throws JsError {\n+    Script test0 = Parser.parseScript(\"for (var x in [1,2,3]){}\");\n+    assertCorrectFailures(test0, 0, \"\");\n+\n+    Script test1 = new Script(ImmutableList.nil(), ImmutableList.list(new ForInStatement(new VariableDeclaration(VariableDeclarationKind.Var, ImmutableList.list(new VariableDeclarator(new BindingIdentifier(\"a\"), Maybe.nothing()), new VariableDeclarator(new BindingIdentifier(\"b\"), Maybe.nothing()))), new ArrayExpression(ImmutableList.list(Maybe.just(new LiteralNumericExpression(0.0)), Maybe.just(new LiteralNumericExpression(1.0)))), new EmptyStatement())));\n+    assertCorrectFailures(test1, 1, ValidationErrorMessages.ONE_VARIABLE_DECLARATOR_IN_FOR_IN);\n+\n+    Script test2 = new Script(ImmutableList.nil(), ImmutableList.list(new ForInStatement(new VariableDeclaration(VariableDeclarationKind.Let, ImmutableList.list(new VariableDeclarator(new BindingIdentifier(\"a\"), Maybe.nothing()), new VariableDeclarator(new BindingIdentifier(\"b\"), Maybe.nothing()))), new ArrayExpression(ImmutableList.list(Maybe.just(new LiteralNumericExpression(0.0)), Maybe.just(new LiteralNumericExpression(1.0)))), new EmptyStatement())));\n+    assertCorrectFailures(test2, 1, ValidationErrorMessages.ONE_VARIABLE_DECLARATOR_IN_FOR_IN);\n+\n+    Script test3 = new Script(ImmutableList.nil(), ImmutableList.list(new ForInStatement(new VariableDeclaration(VariableDeclarationKind.Const, ImmutableList.list(new VariableDeclarator(new BindingIdentifier(\"a\"), Maybe.nothing()), new VariableDeclarator(new BindingIdentifier(\"b\"), Maybe.nothing()))), new ArrayExpression(ImmutableList.list(Maybe.just(new LiteralNumericExpression(0.0)), Maybe.just(new LiteralNumericExpression(1.0)))), new EmptyStatement())));\n+    assertCorrectFailures(test3, 1, ValidationErrorMessages.ONE_VARIABLE_DECLARATOR_IN_FOR_IN);\n+\n+    Script test4 = new Script(ImmutableList.nil(), ImmutableList.list(new ForInStatement(new VariableDeclaration(VariableDeclarationKind.Var, ImmutableList.list(new VariableDeclarator(new BindingIdentifier(\"a\"), Maybe.just(new LiteralNumericExpression(0.0))))), new ArrayExpression(ImmutableList.list(Maybe.just(new LiteralNumericExpression(0.0)), Maybe.just(new LiteralNumericExpression(1.0)))), new EmptyStatement())));\n+    assertCorrectFailures(test4, 1, ValidationErrorMessages.NO_INIT_IN_VARIABLE_DECLARATOR_IN_FOR_IN);\n+\n+    Script test5 = new Script(ImmutableList.nil(), ImmutableList.list(new ForInStatement(new VariableDeclaration(VariableDeclarationKind.Let, ImmutableList.list(new VariableDeclarator(new BindingIdentifier(\"a\"), Maybe.just(new LiteralNumericExpression(0.0))))), new ArrayExpression(ImmutableList.list(Maybe.just(new LiteralNumericExpression(0.0)), Maybe.just(new LiteralNumericExpression(1.0)))), new EmptyStatement())));\n+    assertCorrectFailures(test5, 1, ValidationErrorMessages.NO_INIT_IN_VARIABLE_DECLARATOR_IN_FOR_IN);\n+\n+    Script test6 = new Script(ImmutableList.nil(), ImmutableList.list(new ForInStatement(new VariableDeclaration(VariableDeclarationKind.Const, ImmutableList.list(new VariableDeclarator(new BindingIdentifier(\"a\"), Maybe.just(new LiteralNumericExpression(0.0))))), new ArrayExpression(ImmutableList.list(Maybe.just(new LiteralNumericExpression(0.0)), Maybe.just(new LiteralNumericExpression(1.0)))), new EmptyStatement())));\n+    assertCorrectFailures(test6, 1, ValidationErrorMessages.NO_INIT_IN_VARIABLE_DECLARATOR_IN_FOR_IN);\n+  }\n+\n+  @Test\n+  public void testForOfStatement() throws JsError {\n+    Script test0 = Parser.parseScript(\"for (var x of [1,2,3]){}\");\n+    assertCorrectFailures(test0, 0, \"\");\n+\n+    Script test1 = new Script(ImmutableList.nil(), ImmutableList.list(new ForOfStatement(new VariableDeclaration(VariableDeclarationKind.Var, ImmutableList.list(new VariableDeclarator(new BindingIdentifier(\"a\"), Maybe.nothing()), new VariableDeclarator(new BindingIdentifier(\"b\"), Maybe.nothing()))), new ArrayExpression(ImmutableList.list(Maybe.just(new LiteralNumericExpression(0.0)), Maybe.just(new LiteralNumericExpression(1.0)))), new EmptyStatement())));\n+    assertCorrectFailures(test1, 1, ValidationErrorMessages.ONE_VARIABLE_DECLARATOR_IN_FOR_OF);\n+\n+    Script test2 = new Script(ImmutableList.nil(), ImmutableList.list(new ForOfStatement(new VariableDeclaration(VariableDeclarationKind.Let, ImmutableList.list(new VariableDeclarator(new BindingIdentifier(\"a\"), Maybe.nothing()), new VariableDeclarator(new BindingIdentifier(\"b\"), Maybe.nothing()))), new ArrayExpression(ImmutableList.list(Maybe.just(new LiteralNumericExpression(0.0)), Maybe.just(new LiteralNumericExpression(1.0)))), new EmptyStatement())));\n+    assertCorrectFailures(test2, 1, ValidationErrorMessages.ONE_VARIABLE_DECLARATOR_IN_FOR_OF);\n+\n+    Script test3 = new Script(ImmutableList.nil(), ImmutableList.list(new ForOfStatement(new VariableDeclaration(VariableDeclarationKind.Const, ImmutableList.list(new VariableDeclarator(new BindingIdentifier(\"a\"), Maybe.nothing()), new VariableDeclarator(new BindingIdentifier(\"b\"), Maybe.nothing()))), new ArrayExpression(ImmutableList.list(Maybe.just(new LiteralNumericExpression(0.0)), Maybe.just(new LiteralNumericExpression(1.0)))), new EmptyStatement())));\n+    assertCorrectFailures(test3, 1, ValidationErrorMessages.ONE_VARIABLE_DECLARATOR_IN_FOR_OF);\n+\n+    Script test4 = new Script(ImmutableList.nil(), ImmutableList.list(new ForOfStatement(new VariableDeclaration(VariableDeclarationKind.Var, ImmutableList.list(new VariableDeclarator(new BindingIdentifier(\"a\"), Maybe.just(new LiteralNumericExpression(0.0))))), new ArrayExpression(ImmutableList.list(Maybe.just(new LiteralNumericExpression(0.0)), Maybe.just(new LiteralNumericExpression(1.0)))), new EmptyStatement())));\n+    assertCorrectFailures(test4, 1, ValidationErrorMessages.NO_INIT_IN_VARIABLE_DECLARATOR_IN_FOR_OF);\n+\n+    Script test5 = new Script(ImmutableList.nil(), ImmutableList.list(new ForOfStatement(new VariableDeclaration(VariableDeclarationKind.Let, ImmutableList.list(new VariableDeclarator(new BindingIdentifier(\"a\"), Maybe.just(new LiteralNumericExpression(0.0))))), new ArrayExpression(ImmutableList.list(Maybe.just(new LiteralNumericExpression(0.0)), Maybe.just(new LiteralNumericExpression(1.0)))), new EmptyStatement())));\n+    assertCorrectFailures(test5, 1, ValidationErrorMessages.NO_INIT_IN_VARIABLE_DECLARATOR_IN_FOR_OF);\n+\n+    Script test6 = new Script(ImmutableList.nil(), ImmutableList.list(new ForOfStatement(new VariableDeclaration(VariableDeclarationKind.Const, ImmutableList.list(new VariableDeclarator(new BindingIdentifier(\"a\"), Maybe.just(new LiteralNumericExpression(0.0))))), new ArrayExpression(ImmutableList.list(Maybe.just(new LiteralNumericExpression(0.0)), Maybe.just(new LiteralNumericExpression(1.0)))), new EmptyStatement())));\n+    assertCorrectFailures(test6, 1, ValidationErrorMessages.NO_INIT_IN_VARIABLE_DECLARATOR_IN_FOR_OF);\n+  }\n+\n+  @Test\n+  public void testFormalParameters() {\n+    Script test0 = new Script(ImmutableList.nil(), ImmutableList.list(new FunctionDeclaration(new BindingIdentifier(\"hello\"), false, new FormalParameters(ImmutableList.list(new BindingIdentifier(\"a\")), Maybe.nothing()), new FunctionBody(ImmutableList.nil(), ImmutableList.list(new ExpressionStatement(new CallExpression(new IdentifierExpression(\"z\"), ImmutableList.nil())))))));\n+    assertCorrectFailures(test0, 0, \"\");\n+\n+    Script test1 = new Script(ImmutableList.nil(), ImmutableList.list(new FunctionDeclaration(new BindingIdentifier(\"hello\"), false, new FormalParameters(ImmutableList.nil(), Maybe.nothing()), new FunctionBody(ImmutableList.nil(), ImmutableList.list(new ExpressionStatement(new CallExpression(new IdentifierExpression(\"z\"), ImmutableList.nil())))))));\n+    assertCorrectFailures(test1, 0, \"\");\n+\n+    Script test2 = new Script(ImmutableList.nil(), ImmutableList.list(new FunctionDeclaration(new BindingIdentifier(\"hello\"), false, new FormalParameters(ImmutableList.list(new ComputedMemberExpression(new IdentifierExpression(\"a\"), new IdentifierExpression(\"b\"))), Maybe.nothing()), new FunctionBody(ImmutableList.nil(), ImmutableList.list(new ExpressionStatement(new CallExpression(new IdentifierExpression(\"z\"), ImmutableList.nil())))))));\n+    assertCorrectFailures(test2, 1, ValidationErrorMessages.FORMAL_PARAMETER_ITEMS_NOT_MEMBER_EXPRESSION);\n+\n+    Script test3 = new Script(ImmutableList.nil(), ImmutableList.list(new FunctionDeclaration(new BindingIdentifier(\"hello\"), false, new FormalParameters(ImmutableList.list(new StaticMemberExpression(\"a\", new IdentifierExpression(\"b\"))), Maybe.nothing()), new FunctionBody(ImmutableList.nil(), ImmutableList.list(new ExpressionStatement(new CallExpression(new IdentifierExpression(\"z\"), ImmutableList.nil())))))));\n+    assertCorrectFailures(test3, 1, ValidationErrorMessages.FORMAL_PARAMETER_ITEMS_NOT_MEMBER_EXPRESSION);\n+\n+    Script test4 = new Script(ImmutableList.nil(), ImmutableList.list(new FunctionDeclaration(new BindingIdentifier(\"hello\"), false, new FormalParameters(ImmutableList.list(new BindingWithDefault(new BindingIdentifier(\"a\"), new IdentifierExpression(\"b\"))), Maybe.nothing()), new FunctionBody(ImmutableList.nil(), ImmutableList.list(new ExpressionStatement(new CallExpression(new IdentifierExpression(\"z\"), ImmutableList.nil())))))));\n+    assertCorrectFailures(test4, 0, \"\");\n+\n+    Script test5 = new Script(ImmutableList.nil(), ImmutableList.list(new FunctionDeclaration(new BindingIdentifier(\"hello\"), false, new FormalParameters(ImmutableList.list(new BindingWithDefault(new ComputedMemberExpression(new IdentifierExpression(\"a\"), new IdentifierExpression(\"b\")), new IdentifierExpression(\"b\"))), Maybe.nothing()), new FunctionBody(ImmutableList.nil(), ImmutableList.list(new ExpressionStatement(new CallExpression(new IdentifierExpression(\"z\"), ImmutableList.nil())))))));\n+    assertCorrectFailures(test5, 1, ValidationErrorMessages.FORMAL_PARAMETER_ITEMS_BINDING_NOT_MEMBER_EXPRESSION);\n+\n+    Script test6 = new Script(ImmutableList.nil(), ImmutableList.list(new FunctionDeclaration(new BindingIdentifier(\"hello\"), false, new FormalParameters(ImmutableList.list(new BindingWithDefault(new StaticMemberExpression(\"a\", new IdentifierExpression(\"b\")), new IdentifierExpression(\"b\"))), Maybe.nothing()), new FunctionBody(ImmutableList.nil(), ImmutableList.list(new ExpressionStatement(new CallExpression(new IdentifierExpression(\"z\"), ImmutableList.nil())))))));\n+    assertCorrectFailures(test6, 1, ValidationErrorMessages.FORMAL_PARAMETER_ITEMS_BINDING_NOT_MEMBER_EXPRESSION);\n+  }\n+\n+  @Test\n+  public void testIdentifierExpression() {\n+    Script test0 = new Script(ImmutableList.nil(), ImmutableList.list(new ExpressionStatement(new IdentifierExpression(\"linda\"))));\n+    assertCorrectFailures(test0, 0, \"\");\n+\n+    Script test1 = new Script(ImmutableList.nil(), ImmutableList.list(new ExpressionStatement(new IdentifierExpression(\"9458723\"))));\n+    assertCorrectFailures(test1, 1, ValidationErrorMessages.VALID_IDENTIFIER_NAME);\n+\n+    Script test2 = new Script(ImmutableList.nil(), ImmutableList.list(new ExpressionStatement(new IdentifierExpression(\"A*9458723\"))));\n+    assertCorrectFailures(test2, 1, ValidationErrorMessages.VALID_IDENTIFIER_NAME);\n+\n+    Script test3 = new Script(ImmutableList.nil(), ImmutableList.list(new ExpressionStatement(new IdentifierExpression(\"0lkdjaf\"))));\n+    assertCorrectFailures(test3, 1, ValidationErrorMessages.VALID_IDENTIFIER_NAME);\n+  }\n+\n+  @Test\n+  public void testIfStatement() {\n+    Script test0 = new Script(ImmutableList.nil(), ImmutableList.list(new IfStatement(new ThisExpression(), new ExpressionStatement(new ThisExpression()), Maybe.just(new ExpressionStatement(new ThisExpression())))));\n+    assertCorrectFailures(test0, 0, \"\");\n+\n+    Script test1 = new Script(ImmutableList.nil(), ImmutableList.list(new IfStatement(new IdentifierExpression(\"a\"), new ExpressionStatement(new IdentifierExpression(\"b\")), Maybe.nothing())));\n+    assertCorrectFailures(test1, 0, \"\");\n+\n+    Script test2 = new Script(ImmutableList.nil(), ImmutableList.list(new IfStatement(new IdentifierExpression(\"a\"), new IfStatement(new ThisExpression(), new ExpressionStatement(new ThisExpression()), Maybe.nothing()), Maybe.just(new ExpressionStatement(new ThisExpression())))));\n+    assertCorrectFailures(test2, 1, ValidationErrorMessages.VALID_IF_STATEMENT);\n+  }\n+\n+  @Test\n+  public void testImportSpecifier() {\n+    Module test0 = new Module(ImmutableList.nil(), ImmutableList.list(new Import(Maybe.just(new BindingIdentifier(\"a\")), ImmutableList.list(new ImportSpecifier(Maybe.nothing(), new BindingIdentifier(\"b\"))), \"c\")));\n+    assertCorrectFailures(test0, 0, \"\");\n+\n+    Module test1 = new Module(ImmutableList.nil(), ImmutableList.list(new Import(Maybe.just(new BindingIdentifier(\"a\")), ImmutableList.list(new ImportSpecifier(Maybe.just(\"a\"), new BindingIdentifier(\"b\"))), \"c\")));\n+    assertCorrectFailures(test1, 0, \"\");\n+\n+    Module test2 = new Module(ImmutableList.nil(), ImmutableList.list(new Import(Maybe.just(new BindingIdentifier(\"a\")), ImmutableList.list(new ImportSpecifier(Maybe.just(\"2d849\"), new BindingIdentifier(\"b\"))), \"c\")));\n+    assertCorrectFailures(test2, 1, ValidationErrorMessages.VALID_IMPORT_SPECIFIER_NAME);\n+  }\n+\n+  @Test\n+  public void testLabeledStatement() {\n+    Script test0 = new Script(ImmutableList.nil(), ImmutableList.list(new LabeledStatement(\"done\", new WhileStatement(new LiteralBooleanExpression(true), new BlockStatement(new Block(ImmutableList.list(new BreakStatement(Maybe.just(\"done\")))))))));\n+    assertCorrectFailures(test0, 0, \"\");\n+\n+    Script test1 = new Script(ImmutableList.nil(), ImmutableList.list(new LabeledStatement(\"5346done\", new WhileStatement(new LiteralBooleanExpression(true), new BlockStatement(new Block(ImmutableList.list(new BreakStatement(Maybe.just(\"done\")))))))));\n+    assertCorrectFailures(test1, 1, ValidationErrorMessages.VALID_LABEL);\n+\n+    Script test2 = new Script(ImmutableList.nil(), ImmutableList.list(new LabeledStatement(\"#das*($839da\", new WhileStatement(new LiteralBooleanExpression(true), new BlockStatement(new Block(ImmutableList.list(new ContinueStatement(Maybe.just(\"done\")))))))));\n+    assertCorrectFailures(test2, 1, ValidationErrorMessages.VALID_LABEL);\n+\n+  }\n+\n+  @Test\n+  public void testLiteralNumericExpression() throws JsError {\n+    Script test0 = Parser.parseScript(\"1.0\");\n+    assertCorrectFailures(test0, 0, \"\");\n+\n+    Script test1 = new Script(ImmutableList.nil(), ImmutableList.list(new ExpressionStatement(new LiteralNumericExpression(-1.0))));\n+    assertCorrectFailures(test1, 1, ValidationErrorMessages.LITERAL_NUMERIC_VALUE_NOT_NEGATIVE);\n+\n+    Script test2 = new Script(ImmutableList.nil(), ImmutableList.list(new ExpressionStatement(new LiteralNumericExpression(1.0/0))));\n+    assertCorrectFailures(test2, 1, ValidationErrorMessages.LITERAL_NUMERIC_VALUE_NOT_INFINITE);\n+\n+    Script test3 = new Script(ImmutableList.nil(), ImmutableList.list(new ExpressionStatement(new LiteralNumericExpression(Double.NaN))));\n+    assertCorrectFailures(test3, 1, ValidationErrorMessages.LITERAL_NUMERIC_VALUE_NOT_NAN);\n+\n+  }\n+\n+  @Test\n+  public void testLiteralRegExpExpression() {","path":"src/test/java/com/shapesecurity/shift/validator/ValidatorTest.java","position":271,"original_position":271,"commit_id":"4c2146d354fab54370fe03ab2aca733723200dd6","original_commit_id":"4c2146d354fab54370fe03ab2aca733723200dd6","user":{"login":"michaelficarra","id":218840,"avatar_url":"https://avatars.githubusercontent.com/u/218840?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelficarra","html_url":"https://github.com/michaelficarra","followers_url":"https://api.github.com/users/michaelficarra/followers","following_url":"https://api.github.com/users/michaelficarra/following{/other_user}","gists_url":"https://api.github.com/users/michaelficarra/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelficarra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelficarra/subscriptions","organizations_url":"https://api.github.com/users/michaelficarra/orgs","repos_url":"https://api.github.com/users/michaelficarra/repos","events_url":"https://api.github.com/users/michaelficarra/events{/privacy}","received_events_url":"https://api.github.com/users/michaelficarra/received_events","type":"User","site_admin":false},"body":"Please make sure each test has at least one example without a failure. This test does not have one.","created_at":"2015-08-19T14:53:10Z","updated_at":"2015-08-19T14:53:10Z","html_url":"https://github.com/shapesecurity/shift-java/pull/76#discussion_r37423676","pull_request_url":"https://api.github.com/repos/shapesecurity/shift-java/pulls/76","_links":{"self":{"href":"https://api.github.com/repos/shapesecurity/shift-java/pulls/comments/37423676"},"html":{"href":"https://github.com/shapesecurity/shift-java/pull/76#discussion_r37423676"},"pull_request":{"href":"https://api.github.com/repos/shapesecurity/shift-java/pulls/76"}}},"pull_request":{"url":"https://api.github.com/repos/shapesecurity/shift-java/pulls/76","id":42770013,"html_url":"https://github.com/shapesecurity/shift-java/pull/76","diff_url":"https://github.com/shapesecurity/shift-java/pull/76.diff","patch_url":"https://github.com/shapesecurity/shift-java/pull/76.patch","issue_url":"https://api.github.com/repos/shapesecurity/shift-java/issues/76","number":76,"state":"open","locked":false,"title":"Es6 validator unit tests","user":{"login":"yaylinda","id":10225317,"avatar_url":"https://avatars.githubusercontent.com/u/10225317?v=3","gravatar_id":"","url":"https://api.github.com/users/yaylinda","html_url":"https://github.com/yaylinda","followers_url":"https://api.github.com/users/yaylinda/followers","following_url":"https://api.github.com/users/yaylinda/following{/other_user}","gists_url":"https://api.github.com/users/yaylinda/gists{/gist_id}","starred_url":"https://api.github.com/users/yaylinda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yaylinda/subscriptions","organizations_url":"https://api.github.com/users/yaylinda/orgs","repos_url":"https://api.github.com/users/yaylinda/repos","events_url":"https://api.github.com/users/yaylinda/events{/privacy}","received_events_url":"https://api.github.com/users/yaylinda/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-19T02:08:15Z","updated_at":"2015-08-19T14:53:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"45ddbb200e6d0c0c576ac64568f6845f3e6da39b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/shapesecurity/shift-java/pulls/76/commits","review_comments_url":"https://api.github.com/repos/shapesecurity/shift-java/pulls/76/comments","review_comment_url":"https://api.github.com/repos/shapesecurity/shift-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/shapesecurity/shift-java/issues/76/comments","statuses_url":"https://api.github.com/repos/shapesecurity/shift-java/statuses/4c2146d354fab54370fe03ab2aca733723200dd6","head":{"label":"shapesecurity:es6-validator-unit-tests","ref":"es6-validator-unit-tests","sha":"4c2146d354fab54370fe03ab2aca733723200dd6","user":{"login":"shapesecurity","id":7728313,"avatar_url":"https://avatars.githubusercontent.com/u/7728313?v=3","gravatar_id":"","url":"https://api.github.com/users/shapesecurity","html_url":"https://github.com/shapesecurity","followers_url":"https://api.github.com/users/shapesecurity/followers","following_url":"https://api.github.com/users/shapesecurity/following{/other_user}","gists_url":"https://api.github.com/users/shapesecurity/gists{/gist_id}","starred_url":"https://api.github.com/users/shapesecurity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shapesecurity/subscriptions","organizations_url":"https://api.github.com/users/shapesecurity/orgs","repos_url":"https://api.github.com/users/shapesecurity/repos","events_url":"https://api.github.com/users/shapesecurity/events{/privacy}","received_events_url":"https://api.github.com/users/shapesecurity/received_events","type":"Organization","site_admin":false},"repo":{"id":27738435,"name":"shift-java","full_name":"shapesecurity/shift-java","owner":{"login":"shapesecurity","id":7728313,"avatar_url":"https://avatars.githubusercontent.com/u/7728313?v=3","gravatar_id":"","url":"https://api.github.com/users/shapesecurity","html_url":"https://github.com/shapesecurity","followers_url":"https://api.github.com/users/shapesecurity/followers","following_url":"https://api.github.com/users/shapesecurity/following{/other_user}","gists_url":"https://api.github.com/users/shapesecurity/gists{/gist_id}","starred_url":"https://api.github.com/users/shapesecurity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shapesecurity/subscriptions","organizations_url":"https://api.github.com/users/shapesecurity/orgs","repos_url":"https://api.github.com/users/shapesecurity/repos","events_url":"https://api.github.com/users/shapesecurity/events{/privacy}","received_events_url":"https://api.github.com/users/shapesecurity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shapesecurity/shift-java","description":"Shift format ECMAScript 5 AST tooling","fork":false,"url":"https://api.github.com/repos/shapesecurity/shift-java","forks_url":"https://api.github.com/repos/shapesecurity/shift-java/forks","keys_url":"https://api.github.com/repos/shapesecurity/shift-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shapesecurity/shift-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shapesecurity/shift-java/teams","hooks_url":"https://api.github.com/repos/shapesecurity/shift-java/hooks","issue_events_url":"https://api.github.com/repos/shapesecurity/shift-java/issues/events{/number}","events_url":"https://api.github.com/repos/shapesecurity/shift-java/events","assignees_url":"https://api.github.com/repos/shapesecurity/shift-java/assignees{/user}","branches_url":"https://api.github.com/repos/shapesecurity/shift-java/branches{/branch}","tags_url":"https://api.github.com/repos/shapesecurity/shift-java/tags","blobs_url":"https://api.github.com/repos/shapesecurity/shift-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shapesecurity/shift-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shapesecurity/shift-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/shapesecurity/shift-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shapesecurity/shift-java/statuses/{sha}","languages_url":"https://api.github.com/repos/shapesecurity/shift-java/languages","stargazers_url":"https://api.github.com/repos/shapesecurity/shift-java/stargazers","contributors_url":"https://api.github.com/repos/shapesecurity/shift-java/contributors","subscribers_url":"https://api.github.com/repos/shapesecurity/shift-java/subscribers","subscription_url":"https://api.github.com/repos/shapesecurity/shift-java/subscription","commits_url":"https://api.github.com/repos/shapesecurity/shift-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/shapesecurity/shift-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/shapesecurity/shift-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/shapesecurity/shift-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/shapesecurity/shift-java/contents/{+path}","compare_url":"https://api.github.com/repos/shapesecurity/shift-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shapesecurity/shift-java/merges","archive_url":"https://api.github.com/repos/shapesecurity/shift-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shapesecurity/shift-java/downloads","issues_url":"https://api.github.com/repos/shapesecurity/shift-java/issues{/number}","pulls_url":"https://api.github.com/repos/shapesecurity/shift-java/pulls{/number}","milestones_url":"https://api.github.com/repos/shapesecurity/shift-java/milestones{/number}","notifications_url":"https://api.github.com/repos/shapesecurity/shift-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shapesecurity/shift-java/labels{/name}","releases_url":"https://api.github.com/repos/shapesecurity/shift-java/releases{/id}","created_at":"2014-12-08T22:30:40Z","updated_at":"2015-08-11T04:30:44Z","pushed_at":"2015-08-19T02:25:27Z","git_url":"git://github.com/shapesecurity/shift-java.git","ssh_url":"git@github.com:shapesecurity/shift-java.git","clone_url":"https://github.com/shapesecurity/shift-java.git","svn_url":"https://github.com/shapesecurity/shift-java","homepage":"http://shift-ast.org/","size":32901,"stargazers_count":28,"watchers_count":28,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":8,"forks":8,"open_issues":8,"watchers":28,"default_branch":"es6"}},"base":{"label":"shapesecurity:es6","ref":"es6","sha":"dc86b2aa18fd5b8c0f7711476a60e3c7132f10ba","user":{"login":"shapesecurity","id":7728313,"avatar_url":"https://avatars.githubusercontent.com/u/7728313?v=3","gravatar_id":"","url":"https://api.github.com/users/shapesecurity","html_url":"https://github.com/shapesecurity","followers_url":"https://api.github.com/users/shapesecurity/followers","following_url":"https://api.github.com/users/shapesecurity/following{/other_user}","gists_url":"https://api.github.com/users/shapesecurity/gists{/gist_id}","starred_url":"https://api.github.com/users/shapesecurity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shapesecurity/subscriptions","organizations_url":"https://api.github.com/users/shapesecurity/orgs","repos_url":"https://api.github.com/users/shapesecurity/repos","events_url":"https://api.github.com/users/shapesecurity/events{/privacy}","received_events_url":"https://api.github.com/users/shapesecurity/received_events","type":"Organization","site_admin":false},"repo":{"id":27738435,"name":"shift-java","full_name":"shapesecurity/shift-java","owner":{"login":"shapesecurity","id":7728313,"avatar_url":"https://avatars.githubusercontent.com/u/7728313?v=3","gravatar_id":"","url":"https://api.github.com/users/shapesecurity","html_url":"https://github.com/shapesecurity","followers_url":"https://api.github.com/users/shapesecurity/followers","following_url":"https://api.github.com/users/shapesecurity/following{/other_user}","gists_url":"https://api.github.com/users/shapesecurity/gists{/gist_id}","starred_url":"https://api.github.com/users/shapesecurity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shapesecurity/subscriptions","organizations_url":"https://api.github.com/users/shapesecurity/orgs","repos_url":"https://api.github.com/users/shapesecurity/repos","events_url":"https://api.github.com/users/shapesecurity/events{/privacy}","received_events_url":"https://api.github.com/users/shapesecurity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shapesecurity/shift-java","description":"Shift format ECMAScript 5 AST tooling","fork":false,"url":"https://api.github.com/repos/shapesecurity/shift-java","forks_url":"https://api.github.com/repos/shapesecurity/shift-java/forks","keys_url":"https://api.github.com/repos/shapesecurity/shift-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shapesecurity/shift-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shapesecurity/shift-java/teams","hooks_url":"https://api.github.com/repos/shapesecurity/shift-java/hooks","issue_events_url":"https://api.github.com/repos/shapesecurity/shift-java/issues/events{/number}","events_url":"https://api.github.com/repos/shapesecurity/shift-java/events","assignees_url":"https://api.github.com/repos/shapesecurity/shift-java/assignees{/user}","branches_url":"https://api.github.com/repos/shapesecurity/shift-java/branches{/branch}","tags_url":"https://api.github.com/repos/shapesecurity/shift-java/tags","blobs_url":"https://api.github.com/repos/shapesecurity/shift-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shapesecurity/shift-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shapesecurity/shift-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/shapesecurity/shift-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shapesecurity/shift-java/statuses/{sha}","languages_url":"https://api.github.com/repos/shapesecurity/shift-java/languages","stargazers_url":"https://api.github.com/repos/shapesecurity/shift-java/stargazers","contributors_url":"https://api.github.com/repos/shapesecurity/shift-java/contributors","subscribers_url":"https://api.github.com/repos/shapesecurity/shift-java/subscribers","subscription_url":"https://api.github.com/repos/shapesecurity/shift-java/subscription","commits_url":"https://api.github.com/repos/shapesecurity/shift-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/shapesecurity/shift-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/shapesecurity/shift-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/shapesecurity/shift-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/shapesecurity/shift-java/contents/{+path}","compare_url":"https://api.github.com/repos/shapesecurity/shift-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shapesecurity/shift-java/merges","archive_url":"https://api.github.com/repos/shapesecurity/shift-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shapesecurity/shift-java/downloads","issues_url":"https://api.github.com/repos/shapesecurity/shift-java/issues{/number}","pulls_url":"https://api.github.com/repos/shapesecurity/shift-java/pulls{/number}","milestones_url":"https://api.github.com/repos/shapesecurity/shift-java/milestones{/number}","notifications_url":"https://api.github.com/repos/shapesecurity/shift-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shapesecurity/shift-java/labels{/name}","releases_url":"https://api.github.com/repos/shapesecurity/shift-java/releases{/id}","created_at":"2014-12-08T22:30:40Z","updated_at":"2015-08-11T04:30:44Z","pushed_at":"2015-08-19T02:25:27Z","git_url":"git://github.com/shapesecurity/shift-java.git","ssh_url":"git@github.com:shapesecurity/shift-java.git","clone_url":"https://github.com/shapesecurity/shift-java.git","svn_url":"https://github.com/shapesecurity/shift-java","homepage":"http://shift-ast.org/","size":32901,"stargazers_count":28,"watchers_count":28,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":8,"forks":8,"open_issues":8,"watchers":28,"default_branch":"es6"}},"_links":{"self":{"href":"https://api.github.com/repos/shapesecurity/shift-java/pulls/76"},"html":{"href":"https://github.com/shapesecurity/shift-java/pull/76"},"issue":{"href":"https://api.github.com/repos/shapesecurity/shift-java/issues/76"},"comments":{"href":"https://api.github.com/repos/shapesecurity/shift-java/issues/76/comments"},"review_comments":{"href":"https://api.github.com/repos/shapesecurity/shift-java/pulls/76/comments"},"review_comment":{"href":"https://api.github.com/repos/shapesecurity/shift-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/shapesecurity/shift-java/pulls/76/commits"},"statuses":{"href":"https://api.github.com/repos/shapesecurity/shift-java/statuses/4c2146d354fab54370fe03ab2aca733723200dd6"}}}}