package io.parsingdata.metal.data;

import static io.parsingdata.metal.Shorthand.*;
import static junit.framework.TestCase.assertFalse;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import io.parsingdata.metal.token.Token;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class ParseRefTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    private Token _definition;
    private ParseRef _ref;

    @Before
    public void setUp() {
        _definition = sub(def("value", 1), con(0));
        _ref = new ParseRef(0L, _definition);
    }

    @Test
    public void state() {
        assertThat(_ref.location, is(0L));
        assertThat(_ref.getDefinition(), is(_definition));
    }

    @Test
    public void refIsARef() {
        assertTrue(_ref.isRef());
        assertThat(_ref.asRef(), is(sameInstance(_ref)));
    }

    @Test
    public void refIsNotAValue() {
        assertFalse(_ref.isValue());

        thrown.expect(UnsupportedOperationException.class);
        thrown.expectMessage("Cannot convert ParseRef to ParseValue");
        _ref.asValue();
    }

    @Test
    public void refIsNotAGraph() {
        assertFalse(_ref.isGraph());

        thrown.expect(UnsupportedOperationException.class);
        thrown.expectMessage("Cannot convert ParseRef to ParseGraph");
        _ref.asGraph();
    }

}
@@ -912,32 +912,138 @@
 ition));%0A    %7D%0A%0A
+    @Test%0A    public void toStringTest() %7B%0A        assertThat(_ref.toString(), is(%22ParseRef(0)%22));%0A    %7D%0A%0A
     @Test%0A    pu

Complete ParseRef test.