namespace Parsley.Tests;

class ParsedTests
{
    public void HasAParsedValue()
    {
        new Parsed<string>("parsed", new(1, 1)).Value.ShouldBe("parsed");
    }

    public void HasNoErrorMessageByDefault()
    {
        new Parsed<string>("x", new(1, 1)).ErrorMessages.ShouldBe(ErrorMessageList.Empty);
    }

    public void CanIndicatePotentialErrors()
    {
        var potentialErrors = ErrorMessageList.Empty
            .With(ErrorMessage.Expected("A"))
            .With(ErrorMessage.Expected("B"));

        new Parsed<object>("x", new(1, 1), potentialErrors).ErrorMessages.ShouldBe(potentialErrors);
    }

    public void HasRemainingUnparsedInput()
    {
        var parsed = new Parsed<string>("parsed", new(12, 34));
        parsed.Position.ShouldBe(new (12, 34));
    }

    public void ReportsNonerrorState()
    {
        new Parsed<string>("parsed", new(1, 1)).Success.ShouldBeTrue();
    }
}

namespace Parsley.Tests;

class ParsedTests
{
    public void CanIndicateSuccessfullyParsedValueAtTheCurrentPosition()
    {
        var parsed = new Parsed<string>("parsed", new(12, 34));
        parsed.Success.ShouldBe(true);
        parsed.Value.ShouldBe("parsed");
        parsed.ErrorMessages.ShouldBe(ErrorMessageList.Empty);
        parsed.Position.ShouldBe(new(12, 34));
    }

    public void CanIndicatePotentialErrorMessagesAtTheCurrentPosition()
    {
        var potentialErrors = ErrorMessageList.Empty
            .With(ErrorMessage.Expected("A"))
            .With(ErrorMessage.Expected("B"));

        var parsed = new Parsed<object>("parsed", new(12, 34), potentialErrors);
        parsed.Success.ShouldBe(true);
        parsed.Value.ShouldBe("parsed");
        parsed.ErrorMessages.ShouldBe(potentialErrors);
        parsed.Position.ShouldBe(new(12, 34));
    }
}

Improve test coverage for Parsed<T> by mirroring the test coverage for Error<T>.
Improve test coverage for Parsed<T> by mirroring the test coverage for Error<T>.
