use of com.google.javascript.jscomp.serialization.NodeProperty in project closure-compiler by google.
the class NodeTest method testSerializeProperties_isDeclaredConstant.
@Test
public void testSerializeProperties_isDeclaredConstant() {
Node node = new Node(Token.NAME);
node.setDeclaredConstantVar(true);
EnumSet<NodeProperty> result = node.serializeProperties();
assertThat(result).containsExactly(NodeProperty.IS_DECLARED_CONSTANT);
}
use of com.google.javascript.jscomp.serialization.NodeProperty in project closure-compiler by google.
the class PropTranslator method setProps.
private static final void setProps() {
for (Prop rhinoProp : Prop.values()) {
NodeProperty protoProp = serializeProp(rhinoProp);
if (protoProp != null) {
protoToRhinoProp[protoProp.ordinal()] = rhinoProp;
rhinoToProtoProp[rhinoProp.ordinal()] = protoProp;
}
}
}
use of com.google.javascript.jscomp.serialization.NodeProperty in project closure-compiler by google.
the class NodeTest method testSerializeProperties_untranslatableRhinoProp.
@Test
public void testSerializeProperties_untranslatableRhinoProp() {
Node node = getCall("A");
node.setSideEffectFlags(2);
EnumSet<NodeProperty> result = node.serializeProperties();
// Rhino node prop SIDE_EFFECT_FLAGS does not have a corresponding NodeProperty
assertThat(node.getSideEffectFlags()).isEqualTo(2);
assertThat(result).isEmpty();
}
use of com.google.javascript.jscomp.serialization.NodeProperty in project closure-compiler by google.
the class NodeTest method testSerializeProperties.
@Test
public void testSerializeProperties() {
Node node = IR.function(IR.name(""), IR.paramList(), IR.block());
node.setIsAsyncFunction(true);
node.setIsGeneratorFunction(true);
EnumSet<NodeProperty> result = node.serializeProperties();
assertThat(result).containsExactly(NodeProperty.GENERATOR_FN, NodeProperty.ASYNC_FN);
}
use of com.google.javascript.jscomp.serialization.NodeProperty in project closure-compiler by google.
the class NodeTest method testSerializeProperties_typeBeforeCast.
@Test
public void testSerializeProperties_typeBeforeCast() {
TestErrorReporter testErrorReporter = new TestErrorReporter();
JSTypeRegistry registry = new JSTypeRegistry(testErrorReporter);
Node node = Node.newString(Token.NAME, "f");
node.setJSTypeBeforeCast(registry.getNativeType(JSTypeNative.NUMBER_TYPE));
EnumSet<NodeProperty> result = node.serializeProperties();
// Special case: Rhino node prop TYPE_BEFORE_CAST is converted to NodeProperty.COLOR_FROM_CAST
assertThat(result).containsExactly(NodeProperty.COLOR_FROM_CAST);
}
Aggregations