use of org.elasticsearch.painless.Location in project elasticsearch by elastic.
the class NodeToStringTests method testPSubBrace.
public void testPSubBrace() {
Location l = new Location(getTestName(), 0);
PSubBrace node = new PSubBrace(l, Definition.INT_TYPE, new ENumeric(l, "1", 10));
node.prefix = new EVariable(l, "a");
assertEquals("(PSubBrace (EVariable a) (ENumeric 1))", node.toString());
}
use of org.elasticsearch.painless.Location in project elasticsearch by elastic.
the class NodeToStringTests method testPSubArrayLength.
public void testPSubArrayLength() {
Location l = new Location(getTestName(), 0);
PSubArrayLength node = new PSubArrayLength(l, "int", "a");
node.prefix = new EVariable(l, "a");
assertEquals("(PSubArrayLength (EVariable a))", node.toString());
assertEquals("(PSubNullSafeField (PSubArrayLength (EVariable a)))", new PSubNullSafeField(l, node).toString());
}
use of org.elasticsearch.painless.Location in project elasticsearch by elastic.
the class NodeToStringTests method testPSubMapShortcut.
public void testPSubMapShortcut() {
Location l = new Location(getTestName(), 0);
Struct s = Definition.getType(Map.class.getSimpleName()).struct;
PSubMapShortcut node = new PSubMapShortcut(l, s, new EConstant(l, "cat"));
node.prefix = new EVariable(l, "a");
assertEquals("(PSubMapShortcut (EVariable a) (EConstant String 'cat'))", node.toString());
assertEquals("(PSubNullSafeCallInvoke (PSubMapShortcut (EVariable a) (EConstant String 'cat')))", new PSubNullSafeCallInvoke(l, node).toString());
l = new Location(getTestName(), 1);
s = Definition.getType(Map.class.getSimpleName()).struct;
node = new PSubMapShortcut(l, s, new EBinary(l, Operation.ADD, new EConstant(l, 1), new EConstant(l, 4)));
node.prefix = new EVariable(l, "a");
assertEquals("(PSubMapShortcut (EVariable a) (EBinary (EConstant Integer 1) + (EConstant Integer 4)))", node.toString());
}
use of org.elasticsearch.painless.Location in project elasticsearch by elastic.
the class NodeToStringTests method testPSubShortcut.
public void testPSubShortcut() {
Location l = new Location(getTestName(), 0);
Struct s = Definition.getType(FeatureTest.class.getName()).struct;
Method getter = s.methods.get(new MethodKey("getX", 0));
Method setter = s.methods.get(new MethodKey("setX", 1));
PSubShortcut node = new PSubShortcut(l, "x", FeatureTest.class.getName(), getter, setter);
node.prefix = new EVariable(l, "a");
assertEquals("(PSubShortcut (EVariable a) x)", node.toString());
assertEquals("(PSubNullSafeCallInvoke (PSubShortcut (EVariable a) x))", new PSubNullSafeCallInvoke(l, node).toString());
}
use of org.elasticsearch.painless.Location in project elasticsearch by elastic.
the class NodeToStringTests method testPSubListShortcut.
public void testPSubListShortcut() {
Location l = new Location(getTestName(), 0);
Struct s = Definition.getType(List.class.getSimpleName()).struct;
PSubListShortcut node = new PSubListShortcut(l, s, new EConstant(l, 1));
node.prefix = new EVariable(l, "a");
assertEquals("(PSubListShortcut (EVariable a) (EConstant Integer 1))", node.toString());
assertEquals("(PSubNullSafeCallInvoke (PSubListShortcut (EVariable a) (EConstant Integer 1)))", new PSubNullSafeCallInvoke(l, node).toString());
l = new Location(getTestName(), 0);
s = Definition.getType(List.class.getSimpleName()).struct;
node = new PSubListShortcut(l, s, new EBinary(l, Operation.ADD, new EConstant(l, 1), new EConstant(l, 4)));
node.prefix = new EVariable(l, "a");
assertEquals("(PSubListShortcut (EVariable a) (EBinary (EConstant Integer 1) + (EConstant Integer 4)))", node.toString());
}
Aggregations