@SuppressWarnings("unchecked")
    @Test
    public void testForEachArray() {
        var tester = new ScriptTester();
        var expression = tester.expressionFrom("input myArray | for_each { to_int } | attribute myInts");

        SimpleTestAdapter adapter = new SimpleTestAdapter();
        var myArray = new Array<StringFieldValue>(DataType.getArray(DataType.STRING));
        adapter.createField(new Field("myArray", myArray.getDataType()));
        adapter.setValue("myArray", myArray);
        adapter.createField(new Field("myInts", DataType.getArray(DataType.INT)));

        expression.resolve(adapter);
        ExecutionContext context = new ExecutionContext(adapter);
        expression.execute(context);
        assertTrue(((Array<IntegerFieldValue>)adapter.values.get("myInts")).isEmpty());

        myArray.add(new StringFieldValue("37"));
        adapter.createField(new Field("myArray", myArray.getDataType()));
        adapter.setValue("myArray", myArray);
        adapter.createField(new Field("myInts", DataType.getArray(DataType.INT)));

        expression.resolve(adapter);
        expression.execute(context);
        assertEquals(37, ((Array<IntegerFieldValue>)adapter.values.get("myInts")).get(0).getInteger());
    }
@author Simon Thoresen Hult
@author bratseth
indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/ScriptTestCase.java