Beispiel #1
0
        public void Partition_switch_values()
        {
            var expected = new [] { Token.Name("x") };

            var result = Switch.Partition(
                new []
                    {
                        Token.Name("str"), Token.Value("strvalue"), Token.Value("freevalue"),
                        Token.Name("x"), Token.Value("freevalue2")
                    },
                name =>
                    new[] { "x", "switch" }.Contains(name)
                        ? Maybe.Just(TypeDescriptor.Create(TargetType.Switch, Maybe.Nothing<int>()))
                        : Maybe.Nothing<TypeDescriptor>());

            expected.ShouldAllBeEquivalentTo(result);
        }
Beispiel #2
0
        public void Partition_sequence_values()
        {
            var expected = new[]
                {
                    Token.Name("seq"), Token.Value("seqval0"), Token.Value("seqval1")
                };

            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")
                    },
                name =>
                    new[] { "seq" }.Contains(name)
                        ? Maybe.Just(TypeDescriptor.Create(TypeDescriptorKind.Sequence, Maybe.Nothing<int>()))
                        : Maybe.Nothing<TypeDescriptor>());

            expected.ShouldAllBeEquivalentTo(result);
        }