Skip to content

Commit

Permalink
Puts FunctionToBlockMutatorTest test setup into a valid state for sco…
Browse files Browse the repository at this point in the history
…pe creation.

Previously it did not synthesize correct root nodes and connect
the Compiler object to them.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=160461612
  • Loading branch information
stalcup authored and brad4d committed Jun 29, 2017
1 parent af285b5 commit cbad9ee
Showing 1 changed file with 8 additions and 6 deletions.
Expand Up @@ -21,6 +21,7 @@


import com.google.javascript.jscomp.AbstractCompiler.LifeCycleStage; import com.google.javascript.jscomp.AbstractCompiler.LifeCycleStage;
import com.google.javascript.jscomp.NodeTraversal.Callback; import com.google.javascript.jscomp.NodeTraversal.Callback;
import com.google.javascript.rhino.IR;
import com.google.javascript.rhino.Node; import com.google.javascript.rhino.Node;
import com.google.javascript.rhino.Token; import com.google.javascript.rhino.Token;
import junit.framework.TestCase; import junit.framework.TestCase;
Expand Down Expand Up @@ -210,15 +211,16 @@ public void helperMutate(
Node expectedRoot = parse(compiler, expectedResult); Node expectedRoot = parse(compiler, expectedResult);
checkState(compiler.getErrorCount() == 0); checkState(compiler.getErrorCount() == 0);
final Node expected = expectedRoot.getFirstChild(); final Node expected = expectedRoot.getFirstChild();
final Node tree = parse(compiler, code); final Node script = parse(compiler, code);
checkState(compiler.getErrorCount() == 0); checkState(compiler.getErrorCount() == 0);


Node externsRoot = new Node(Token.EMPTY); compiler.externsRoot = new Node(Token.ROOT);
Node mainRoot = tree; compiler.jsRoot = IR.root(script);
compiler.externAndJsRoot = IR.root(compiler.externsRoot, compiler.jsRoot);
MarkNoSideEffectCalls mark = new MarkNoSideEffectCalls(compiler); MarkNoSideEffectCalls mark = new MarkNoSideEffectCalls(compiler);
mark.process(externsRoot, mainRoot); mark.process(compiler.externsRoot, compiler.jsRoot);


final Node fnNode = findFunction(tree, fnName); final Node fnNode = findFunction(script, fnName);


// Fake precondition. // Fake precondition.
compiler.setLifeCycleStage(LifeCycleStage.NORMALIZED); compiler.setLifeCycleStage(LifeCycleStage.NORMALIZED);
Expand All @@ -242,7 +244,7 @@ public boolean call(NodeTraversal t, Node n, Node parent) {


compiler.resetUniqueNameId(); compiler.resetUniqueNameId();
TestCallback test = new TestCallback(fnName, tester); TestCallback test = new TestCallback(fnName, tester);
NodeTraversal.traverseEs6(compiler, tree, test); NodeTraversal.traverseEs6(compiler, script, test);
} }


interface Method { interface Method {
Expand Down

0 comments on commit cbad9ee

Please sign in to comment.