public Property Token_lexes() { return(Prop.ForAll(Arbitrary.PsuedoToken(), token => { var result = Lex(token.Text); var outputAsPsuedoTokens = result.ToPsuedoTokens(); var expectedPsuedoTokens = token.Yield().Append(PsuedoToken.EndOfFile()).ToList(); return expectedPsuedoTokens.SequenceEqual(outputAsPsuedoTokens) .Label($"Actual: {outputAsPsuedoTokens.DebugFormat()}") .Label($"Expected: {expectedPsuedoTokens.DebugFormat()}") .Collect(token.TokenType.Name); })); }
public Property Valid_token_sequence_lexes_back_to_itself() { return(Prop.ForAll(Arbitrary.PsuedoTokenList(), tokens => { var input = string.Concat(tokens.Select(t => t.Text)); var result = Lex(input); var outputAsPsuedoTokens = result.ToPsuedoTokens(); var expectedPsuedoTokens = tokens.Append(PsuedoToken.EndOfFile()).ToFixedList(); return expectedPsuedoTokens.SequenceEqual(outputAsPsuedoTokens) .Label($"Text: „{input.Escape()}„") .Label($"Actual: {outputAsPsuedoTokens.DebugFormat()}") .Label($"Expected: {expectedPsuedoTokens.DebugFormat()}"); })); }