Example #1
0
        public void Any()
        {
            var a1 = A1();
            var a2 = A2();
            var b1 = B1();
            var b2 = B2();
            var m1 = new MethodType(new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(a2)), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(b1)));
            var m2 = new MethodType(new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(a1)), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(b2)));
            var t1 = new HasMembersType(new WeakScope(new List <WeakMemberDefinition> {
                new WeakMemberDefinition(Access.ReadWrite, new NameKey("a"), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(a1))),
                new WeakMemberDefinition(Access.ReadWrite, new NameKey("b"), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(b1)))
            }));
            var t2 = new HasMembersType(new WeakScope(new List <WeakMemberDefinition> {
                new WeakMemberDefinition(Access.ReadWrite, new NameKey("a"), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(a2))),
                new WeakMemberDefinition(Access.ReadWrite, new NameKey("b"), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(b2)))
            }));
            var or1 = new FrontEndOrType(
                new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(a1)),
                new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(b1)),
                OrType.Make <IReadOnlyList <WeakMemberDefinition>, IError>(Array.Empty <WeakMemberDefinition>()),
                Possibly.IsNot <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > >(),
                Possibly.IsNot <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > >()
                );
            var or2 = new FrontEndOrType(
                new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(b1)),
                new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(a1)),
                OrType.Make <IReadOnlyList <WeakMemberDefinition>, IError>(Array.Empty <WeakMemberDefinition>()),
                Possibly.IsNot <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > >(),
                Possibly.IsNot <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > >()
                );

            var any = new AnyType();

            Assert.All(new[] { a1, a2, b1, b2, m1, m2, t1, t2, or1, or2 }, x => any.TheyAreUs(x, new List <(IFrontendType <IVerifiableType>, IFrontendType <IVerifiableType>)>()));
        }
Example #2
0
        public void InterestingCase2()
        {
            var member1Key      = new NameKey("x");
            var memeber1TypeBox = new Box <IOrType <IFrontendType <IVerifiableType>, IError> >();
            var member1         = new WeakMemberDefinition(Access.ReadWrite, member1Key, memeber1TypeBox);
            var type1           = new HasMembersType(new WeakScope(new List <WeakMemberDefinition> {
                member1
            }));

            memeber1TypeBox.Fill(OrType.Make <IFrontendType <IVerifiableType>, IError>(type1));

            var member2Key      = new NameKey("x");
            var memeber2TypeBox = new Box <IOrType <IFrontendType <IVerifiableType>, IError> >();
            var member2         = new WeakMemberDefinition(Access.ReadWrite, member2Key, memeber2TypeBox);
            var member3Key      = new NameKey("y");
            var member3         = new WeakMemberDefinition(Access.ReadWrite, member3Key, new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(new NumberType())));
            var type2           = new HasMembersType(new WeakScope(new List <WeakMemberDefinition> {
                member2, member3
            }));

            memeber2TypeBox.Fill(OrType.Make <IFrontendType <IVerifiableType>, IError>(type2));

            Assert.False(type1.TheyAreUs(type2, new List <(IFrontendType <IVerifiableType>, IFrontendType <IVerifiableType>)>()).Is1OrThrow());
            Assert.False(type2.TheyAreUs(type1, new List <(IFrontendType <IVerifiableType>, IFrontendType <IVerifiableType>)>()).Is1OrThrow());
        }
Example #3
0
        private IFrontendType <IVerifiableType> B1()
        {
            var member1Key = new NameKey("bm1");
            var member1    = new WeakMemberDefinition(Access.ReadWrite, member1Key, new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(new NumberType())));
            var type1      = new HasMembersType(new WeakScope(new List <WeakMemberDefinition> {
                member1
            }));

            return(type1);
        }
Example #4
0
        public void TypeDontHaveVariance()
        {
            var a1 = A1();
            var a2 = A2();
            var b1 = B1();
            var b2 = B2();

            var t1 = new HasMembersType(new WeakScope(new List <WeakMemberDefinition> {
                new WeakMemberDefinition(Access.ReadWrite, new NameKey("a"), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(a1))),
                new WeakMemberDefinition(Access.ReadWrite, new NameKey("b"), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(b1)))
            }));

            var t2 = new HasMembersType(new WeakScope(new List <WeakMemberDefinition> {
                new WeakMemberDefinition(Access.ReadWrite, new NameKey("a"), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(a2))),
                new WeakMemberDefinition(Access.ReadWrite, new NameKey("b"), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(b2)))
            }));


            Assert.False(t2.TheyAreUs(t1, new List <(IFrontendType <IVerifiableType>, IFrontendType <IVerifiableType>)>()).Is1OrThrow());
            Assert.False(t1.TheyAreUs(t2, new List <(IFrontendType <IVerifiableType>, IFrontendType <IVerifiableType>)>()).Is1OrThrow());
        }