public void Partition_scalar_values() { var expected = new [] { Token.Name("str"), Token.Value("strvalue") }; var result = Scalar.Partition( new [] { Token.Name("str"), Token.Value("strvalue"), Token.Value("freevalue"), Token.Name("x"), Token.Value("freevalue2") }, name => new[] { "str", "int" }.Contains(name) ? Maybe.Just(TypeDescriptor.Create(TargetType.Scalar, Maybe.Nothing<int>())) : Maybe.Nothing<TypeDescriptor>()); expected.ShouldBeEquivalentTo(result); }
public void Partition_sequence_values_from_two_sequneces() { var expected = new[] { Token.Name("seq"), Token.Value("seqval0"), Token.Value("seqval1"), Token.Name("seqb"), Token.Value("seqbval0") }; var result = Sequence.Partition( new[] { Token.Name("str"), Token.Value("strvalue"), Token.Value("freevalue"), Token.Name("seq"), Token.Value("seqval0"), Token.Value("seqval1"), Token.Name("x"), Token.Value("freevalue2"), Token.Name("seqb"), Token.Value("seqbval0") }, name => new[] { "seq", "seqb" }.Contains(name) ? Maybe.Just(TypeDescriptor.Create(TargetType.Sequence, Maybe.Nothing<int>())) : Maybe.Nothing<TypeDescriptor>()); expected.ShouldBeEquivalentTo(result); }