@Test
    public void testCatAndVariableExpression_complex() {
        var tester = new ScriptTester();
        var expression = tester.expressionFrom(
                "input myString | if ((get_var DX | to_bool) == true) { " +
                "(get_var A | to_array) . (get_var B | to_array) . (get_var C | to_array) . (get_var D | to_array) | set_var R; } " +
                "else { if ((get_var CX | to_bool) == true) { " +
                "(get_var A | to_array) . (get_var B | to_array) . (get_var C | to_array) | set_var R; } " +
                "else { if ((get_var BX | to_bool) == true) { (get_var A | to_array) . (get_var B | to_array) | set_var R; } " +
                "else { get_var A | to_array | set_var R; }; }; } | get_var R | for_each { _ } | attribute myStringArray");

        SimpleTestAdapter adapter = new SimpleTestAdapter();
        adapter.createField(new Field("myString", DataType.STRING));
        adapter.createField(new Field("myStringArray", ArrayDataType.getArray(DataType.STRING)));

        var verificationContext = new TypeContext(adapter);
        verificationContext.setVariableType("BX", DataType.STRING);
        verificationContext.setVariableType("CX", DataType.STRING);
        verificationContext.setVariableType("DX", DataType.STRING);
        verificationContext.setVariableType("A", DataType.STRING);
        verificationContext.setVariableType("B", DataType.STRING);
        verificationContext.setVariableType("C", DataType.STRING);
        verificationContext.setVariableType("D", DataType.STRING);
        expression.resolve(verificationContext);

        var context = new ExecutionContext(adapter);
        context.setVariable("BX", new StringFieldValue("value 1"));
        context.setVariable("CX", new StringFieldValue("value 2"));
        context.setVariable("DX", new StringFieldValue("value 3"));
        context.setVariable("A", new StringFieldValue("value 4"));
        context.setVariable("B", new StringFieldValue("value 5"));
        context.setVariable("C", new StringFieldValue("value 6"));
        context.setVariable("D", new StringFieldValue("value 7"));
        expression.execute(context);
        assertEquals("[value 4, value 5, value 6, value 7]", adapter.values.get("myStringArray").toString());
    }
@author Simon Thoresen Hult
@author bratseth
indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/ScriptTestCase.java