diff --git a/src/com/google/javascript/jscomp/ValidityCheck.java b/src/com/google/javascript/jscomp/ValidityCheck.java index 9d4f060b305..5a77b984a94 100644 --- a/src/com/google/javascript/jscomp/ValidityCheck.java +++ b/src/com/google/javascript/jscomp/ValidityCheck.java @@ -76,9 +76,8 @@ private void checkVars(Node externs, Node root) { } /** - * Sanity checks code generation by performing it once, parsing the result, - * then generating code from the second parse tree to verify that it matches - * the code generated from the first parse tree. + * Checks code generation by performing it once, parsing the result, then generating code from the + * second parse tree to verify that it matches the code generated from the first parse tree. * * @return The regenerated parse tree. Null on error. */ @@ -95,26 +94,23 @@ private Node checkCodeGeneration(Node root) { compiler.report(JSError.make(CANNOT_PARSE_GENERATED_CODE, Strings.truncateAtMaxLength(source, 100, true))); - // Throw an exception, so that the infrastructure will tell us - // which pass violated the sanity check. - throw new IllegalStateException("Sanity Check failed"); + // Throw an exception, so that the infrastructure will tell us which pass violated the check. + throw new IllegalStateException("Validity Check failed"); } String source2 = compiler.toSource(root2); if (!source.equals(source2)) { compiler.report(JSError.make(GENERATED_BAD_CODE, source, source2)); - // Throw an exception, so that the infrastructure will tell us - // which pass violated the sanity check. - throw new IllegalStateException("Sanity Check failed"); + // Throw an exception, so that the infrastructure will tell us which pass violated the check. + throw new IllegalStateException("Validity Check failed"); } return root2; } /** - * Sanity checks the AST. This is by verifying the normalization passes do - * nothing. + * Verifies that the normalization pass does nothing on an already-normalized tree. */ private void checkNormalization(Node externs, Node root) { // Verify nothing has inappropriately denormalize the AST. @@ -151,10 +147,9 @@ private void checkExternProperties(Node externs) { EXTERN_PROPERTIES_CHANGED, externProperties.toString(), compiler.getExternProperties().toString())); - // Throw an exception, so that the infrastructure will tell us - // which pass violated the sanity check. + // Throw an exception, so that the infrastructure will tell us which pass violated the check. throw new IllegalStateException( - "Sanity Check failed: Extern properties changed from:\n" + "Validity Check failed: Extern properties changed from:\n" + externProperties + "\nto:\n" + compiler.getExternProperties()); diff --git a/src/com/google/javascript/jscomp/VarCheck.java b/src/com/google/javascript/jscomp/VarCheck.java index 92dde44c637..d4cb497c642 100644 --- a/src/com/google/javascript/jscomp/VarCheck.java +++ b/src/com/google/javascript/jscomp/VarCheck.java @@ -117,7 +117,7 @@ class VarCheck extends AbstractPostOrderCallback implements } /** - * Creates the scope creator used by this pass. If not in sanity check mode, use a {@link + * Creates the scope creator used by this pass. If not in validity check mode, use a {@link * RedeclarationCheckHandler} to check var redeclarations. */ private ScopeCreator createScopeCreator() { diff --git a/test/com/google/javascript/jscomp/NameAnalyzerTest.java b/test/com/google/javascript/jscomp/NameAnalyzerTest.java index 4695a2f4fd4..9ec5e31e8d0 100644 --- a/test/com/google/javascript/jscomp/NameAnalyzerTest.java +++ b/test/com/google/javascript/jscomp/NameAnalyzerTest.java @@ -2157,8 +2157,7 @@ public void testAliasInstanceof5() { "if (y instanceof b) {}")); } - // We cannot leave x.a.prototype there because it will - // fail sanity var check. + // We cannot leave x.a.prototype there because it will fail ValidityCheck.checkVars. public void testBrokenNamespaceWithPrototypeAssignment() { test("var x = {}; x.a.prototype = 1", ""); } diff --git a/test/com/google/javascript/jscomp/VarCheckTest.java b/test/com/google/javascript/jscomp/VarCheckTest.java index 8c4d37ab778..44a722ea41e 100644 --- a/test/com/google/javascript/jscomp/VarCheckTest.java +++ b/test/com/google/javascript/jscomp/VarCheckTest.java @@ -30,7 +30,7 @@ public final class VarCheckTest extends CompilerTestCase { private static final String EXTERNS = "var window; function alert() {}"; private CheckLevel strictModuleDepErrorLevel; - private boolean sanityCheck = false; + private boolean validityCheck = false; private CheckLevel externValidationErrorLevel; @@ -48,7 +48,7 @@ protected void setUp() throws Exception { allowExternsChanges(); strictModuleDepErrorLevel = CheckLevel.OFF; externValidationErrorLevel = null; - sanityCheck = false; + validityCheck = false; declarationCheck = false; } @@ -67,8 +67,8 @@ protected CompilerOptions getOptions() { protected CompilerPass getProcessor(final Compiler compiler) { return new CompilerPass() { @Override public void process(Node externs, Node root) { - new VarCheck(compiler, sanityCheck).process(externs, root); - if (!sanityCheck && !compiler.hasErrors()) { + new VarCheck(compiler, validityCheck).process(externs, root); + if (!validityCheck && !compiler.hasErrors()) { // If the original test turned off sanity check, make sure our synthesized // code passes it. new VarCheck(compiler, true).process(externs, root); @@ -402,23 +402,23 @@ public void testViolatedModuleDependencyLetAndConst() { public void testMissingModuleDependencySkipNonStrict() { - sanityCheck = true; + validityCheck = true; testIndependentModules("var x = 10;", "var y = x++;", null, null); } public void testViolatedModuleDependencySkipNonStrict() { - sanityCheck = true; + validityCheck = true; testDependentModules("var y = x++;", "var x = 10;", null); } public void testMissingModuleDependencySkipNonStrictNotPromoted() { - sanityCheck = true; + validityCheck = true; strictModuleDepErrorLevel = CheckLevel.ERROR; testIndependentModules("var x = 10;", "var y = x++;", null, null); } public void testViolatedModuleDependencyNonStrictNotPromoted() { - sanityCheck = true; + validityCheck = true; strictModuleDepErrorLevel = CheckLevel.ERROR; testDependentModules("var y = x++;", "var x = 10;", null); } @@ -498,8 +498,8 @@ public void testSimple() { checkSynthesizedExtern("var x", ""); } - public void testSimpleSanityCheck() { - sanityCheck = true; + public void testSimpleValidityCheck() { + validityCheck = true; try { checkSynthesizedExtern("x", ""); fail("Expected RuntimeException"); @@ -633,7 +633,7 @@ public void testFunctionScopeArguments() { testError("var f = function (arguments) {}", VarCheck.VAR_ARGUMENTS_SHADOWED_ERROR); testSame("function f() {try {} catch(arguments) {}}"); - sanityCheck = true; + validityCheck = true; testSame("function f() {var arguments}"); } @@ -713,7 +713,7 @@ public void checkSynthesizedExtern( public void checkSynthesizedExtern( String extern, String input, String expectedExtern) { - declarationCheck = !sanityCheck; + declarationCheck = !validityCheck; disableCompareAsTree(); testExternChanges(extern, input, expectedExtern); }