use of com.google.javascript.jscomp.type.FlowScope in project closure-compiler by google.
the class SemanticReverseAbstractInterpreterTest method testShneCondition1.
/**
* Tests reverse interpretation of a SHNE(NAME, NUMBER) expression.
*/
@SuppressWarnings("unchecked")
public void testShneCondition1() throws Exception {
FlowScope blind = newScope();
testBinop(blind, Token.SHNE, createVar(blind, "a", createUnionType(STRING_TYPE, NUMBER_TYPE)), createNumber(56), ImmutableSet.of(new TypedName("a", createUnionType(STRING_TYPE, NUMBER_TYPE))), ImmutableSet.of(new TypedName("a", NUMBER_TYPE)));
}
use of com.google.javascript.jscomp.type.FlowScope in project closure-compiler by google.
the class SemanticReverseAbstractInterpreterTest method testEqCondition1.
/**
* Tests reverse interpretation of a EQ(NAME, NULL) expression.
*/
@SuppressWarnings("unchecked")
public void testEqCondition1() throws Exception {
FlowScope blind = newScope();
testBinop(blind, Token.EQ, createVar(blind, "a", createUnionType(BOOLEAN_TYPE, VOID_TYPE)), createNull(), ImmutableSet.of(new TypedName("a", VOID_TYPE)), ImmutableSet.of(new TypedName("a", BOOLEAN_TYPE)));
}
use of com.google.javascript.jscomp.type.FlowScope in project closure-compiler by google.
the class SemanticReverseAbstractInterpreterTest method testInstanceOf3.
@SuppressWarnings("unchecked")
public void testInstanceOf3() {
FlowScope blind = newScope();
testBinop(blind, Token.INSTANCEOF, createVar(blind, "x", OBJECT_TYPE), createVar(blind, "s", STRING_OBJECT_FUNCTION_TYPE), ImmutableSet.of(new TypedName("x", STRING_OBJECT_TYPE), new TypedName("s", STRING_OBJECT_FUNCTION_TYPE)), ImmutableSet.of(new TypedName("x", OBJECT_TYPE), new TypedName("s", STRING_OBJECT_FUNCTION_TYPE)));
}
use of com.google.javascript.jscomp.type.FlowScope in project closure-compiler by google.
the class LinkedFlowScopeTest method testLongChain2.
/**
* Create a long chain of flow scopes where each link in the chain
* contains 7 slots.
*/
public void testLongChain2() {
FlowScope chainA = localEntry.createChildFlowScope();
FlowScope chainB = localEntry.createChildFlowScope();
for (int i = 0; i < LONG_CHAIN_LENGTH * 7; i++) {
localScope.declare("local" + i, null, null, null);
chainA.inferSlotType("local" + i, i % 2 == 0 ? NUMBER_TYPE : BOOLEAN_TYPE);
chainB.inferSlotType("local" + i, i % 3 == 0 ? STRING_TYPE : BOOLEAN_TYPE);
if (i % 7 == 0) {
chainA = chainA.createChildFlowScope();
chainB = chainB.createChildFlowScope();
}
}
verifyLongChains(chainA, chainB);
}
use of com.google.javascript.jscomp.type.FlowScope in project closure-compiler by google.
the class SemanticReverseAbstractInterpreterTest method testEqCondition2.
/**
* Tests reverse interpretation of a NE(NULL, NAME) expression.
*/
@SuppressWarnings("unchecked")
public void testEqCondition2() throws Exception {
FlowScope blind = newScope();
testBinop(blind, Token.NE, createNull(), createVar(blind, "a", createUnionType(BOOLEAN_TYPE, VOID_TYPE)), ImmutableSet.of(new TypedName("a", BOOLEAN_TYPE)), ImmutableSet.of(new TypedName("a", VOID_TYPE)));
}
Aggregations