Search in sources :

Example 6 with Location

use of org.elasticsearch.painless.Location in project elasticsearch by elastic.

the class NodeToStringTests method testPSubField.

public void testPSubField() {
    Location l = new Location(getTestName(), 0);
    Struct s = Definition.getType(Boolean.class.getSimpleName()).struct;
    Field f = s.staticMembers.get("TRUE");
    PSubField node = new PSubField(l, f);
    node.prefix = new EStatic(l, "Boolean");
    assertEquals("(PSubField (EStatic Boolean) TRUE)", node.toString());
    assertEquals("(PSubNullSafeCallInvoke (PSubField (EStatic Boolean) TRUE))", new PSubNullSafeCallInvoke(l, node).toString());
}
Also used : Field(org.elasticsearch.painless.Definition.Field) Location(org.elasticsearch.painless.Location) Struct(org.elasticsearch.painless.Definition.Struct)

Example 7 with Location

use of org.elasticsearch.painless.Location in project elasticsearch by elastic.

the class NodeToStringTests method testPSubDefField.

public void testPSubDefField() {
    Location l = new Location(getTestName(), 0);
    PSubDefField node = new PSubDefField(l, "ok");
    node.prefix = new EVariable(l, "a");
    assertEquals("(PSubDefField (EVariable a) ok)", node.toString());
    assertEquals("(PSubNullSafeCallInvoke (PSubDefField (EVariable a) ok))", new PSubNullSafeCallInvoke(l, node).toString());
}
Also used : Location(org.elasticsearch.painless.Location)

Example 8 with Location

use of org.elasticsearch.painless.Location in project elasticsearch by elastic.

the class NodeToStringTests method testSSubEachIterable.

public void testSSubEachIterable() {
    Location l = new Location(getTestName(), 0);
    Variable v = new Variable(l, "test", Definition.INT_TYPE, 5, false);
    AExpression e = new EListInit(l, Arrays.asList(new EConstant(l, 1), new EConstant(l, 2), new EConstant(l, 3)));
    SBlock b = new SBlock(l, singletonList(new SReturn(l, new EConstant(l, 5))));
    SSubEachIterable node = new SSubEachIterable(l, v, e, b);
    assertEquals("(SSubEachIterable int test (EListInit (EConstant Integer 1) (EConstant Integer 2) (EConstant Integer 3)) (SBlock " + "(SReturn (EConstant Integer 5))))", node.toString());
}
Also used : Variable(org.elasticsearch.painless.Locals.Variable) Location(org.elasticsearch.painless.Location)

Example 9 with Location

use of org.elasticsearch.painless.Location in project elasticsearch by elastic.

the class NodeToStringTests method testPSubDefArray.

public void testPSubDefArray() {
    Location l = new Location(getTestName(), 0);
    PSubDefArray node = new PSubDefArray(l, new EConstant(l, 1));
    node.prefix = new EVariable(l, "a");
    assertEquals("(PSubDefArray (EVariable a) (EConstant Integer 1))", node.toString());
}
Also used : Location(org.elasticsearch.painless.Location)

Example 10 with Location

use of org.elasticsearch.painless.Location in project elasticsearch by elastic.

the class NodeToStringTests method testEConstant.

public void testEConstant() {
    assertEquals("(EConstant String '121')", new EConstant(new Location(getTestName(), 0), "121").toString());
    assertEquals("(EConstant String '92 ')", new EConstant(new Location(getTestName(), 0), "92 ").toString());
    assertEquals("(EConstant Integer 1237)", new EConstant(new Location(getTestName(), 1), 1237).toString());
    assertEquals("(EConstant Boolean true)", new EConstant(new Location(getTestName(), 2), true).toString());
}
Also used : Location(org.elasticsearch.painless.Location)

Aggregations

Location (org.elasticsearch.painless.Location)18 Struct (org.elasticsearch.painless.Definition.Struct)4 Token (org.antlr.v4.runtime.Token)2 Method (org.elasticsearch.painless.Definition.Method)2 MethodKey (org.elasticsearch.painless.Definition.MethodKey)2 Variable (org.elasticsearch.painless.Locals.Variable)2 Collections.emptyList (java.util.Collections.emptyList)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Map (java.util.Map)1 CharStream (org.antlr.v4.runtime.CharStream)1 InputMismatchException (org.antlr.v4.runtime.InputMismatchException)1 NoViableAltException (org.antlr.v4.runtime.NoViableAltException)1 Cast (org.elasticsearch.painless.Definition.Cast)1 Field (org.elasticsearch.painless.Definition.Field)1 RuntimeClass (org.elasticsearch.painless.Definition.RuntimeClass)1 FeatureTest (org.elasticsearch.painless.FeatureTest)1 EFunctionRef (org.elasticsearch.painless.node.EFunctionRef)1 ENewArray (org.elasticsearch.painless.node.ENewArray)1 EString (org.elasticsearch.painless.node.EString)1