@@ -0,0 +1,2021 @@
+package io.parsingdata.metal.data;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport static io.parsingdata.metal.Shorthand.con;%0Aimport static io.parsingdata.metal.Shorthand.def;%0Aimport static io.parsingdata.metal.Shorthand.ref;%0Aimport static io.parsingdata.metal.Shorthand.seq;%0Aimport static io.parsingdata.metal.Shorthand.tie;%0Aimport static io.parsingdata.metal.data.selection.ByName.getValue;%0Aimport static io.parsingdata.metal.util.EncodingFactory.enc;%0Aimport static io.parsingdata.metal.util.EnvironmentFactory.stream;%0Aimport static io.parsingdata.metal.util.TokenDefinitions.any;%0A%0Aimport java.io.IOException;%0A%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.ExpectedException;%0A%0Aimport io.parsingdata.metal.token.Token;%0A%0Apublic class DataExpressionSourceTest %7B%0A%0A    @Rule%0A    public ExpectedException thrown = ExpectedException.none();%0A%0A    public ParseValue setupValue() throws IOException %7B%0A        final ParseResult result = setupResult();%0A        assertTrue(result.succeeded);%0A        return getValue(result.environment.order, %22b%22);%0A    %7D%0A%0A    private ParseResult setupResult() throws IOException %7B%0A        final Token token =%0A            seq(def(%22a%22, con(4)),%0A                tie(def(%22b%22, con(2)), ref(%22a%22)));%0A        return token.parse(stream(1, 2, 3, 4), enc());%0A    %7D%0A%0A    @Test%0A    public void createSliceFromParseValue() throws IOException %7B%0A        final ParseValue value = setupValue();%0A        assertEquals(2, value.slice.source.create(2, 4).size);%0A        assertEquals(0, value.slice.source.create(4, 4).size);%0A    %7D%0A%0A    @Test%0A    public void indexOutOfBounds() throws IOException %7B%0A        thrown.expect(IllegalStateException.class);%0A        thrown.expectMessage(%22ValueExpression dataExpression yields incorrect amount of results.%22);%0A        final ParseResult result = setupResult();%0A        final DataExpressionSource source = new DataExpressionSource(ref(%22a%22), 1, result.environment, enc());%0A        source.getData(0, 4);%0A    %7D%0A%0A%7D%0A

Test coverage for DataExpressionSource.