Skip to content

Commit

Permalink
Remove lingering references to "sanity"
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171847609
  • Loading branch information
tbreisacher committed Oct 11, 2017
1 parent 6fd75a2 commit f7a9ddb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 29 deletions.
23 changes: 9 additions & 14 deletions src/com/google/javascript/jscomp/ValidityCheck.java
Expand Up @@ -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.
*/
Expand All @@ -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.
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/VarCheck.java
Expand Up @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions test/com/google/javascript/jscomp/NameAnalyzerTest.java
Expand Up @@ -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", "");
}
Expand Down
24 changes: 12 additions & 12 deletions test/com/google/javascript/jscomp/VarCheckTest.java
Expand Up @@ -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;

Expand All @@ -48,7 +48,7 @@ protected void setUp() throws Exception {
allowExternsChanges();
strictModuleDepErrorLevel = CheckLevel.OFF;
externValidationErrorLevel = null;
sanityCheck = false;
validityCheck = false;
declarationCheck = false;
}

Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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}");
}

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit f7a9ddb

Please sign in to comment.