public void Test()
        {
            var testCase          = new MirrorPointImplementation();
            var conversionContext = new Definitions();
            var module            = testCase.RootScope.Convert(conversionContext).SafeCastTo(out Tac.Backend.Interpreted.Syntaz_Model_Interpeter.Elements.InterpetedRootScope _);

            var(scope, res) = module.InterpetWithExposedScope(InterpetedContext.Root());

            Assert.False(res.IsReturn(out var _, out var value));

            var implementation = scope.GetMember(new NameKey("mirror")).Value.Has <IInterpetedMethod>();

            var context = TypeManager.InstanceScope(
                (new NameKey("x"), TypeManager.AnyMember(TypeManager.Double(5))),
                (new NameKey("y"), TypeManager.AnyMember(TypeManager.Double(7))));

            {
                Assert.False(implementation.Invoke(TypeManager.Member(context.Convert(TransformerExtensions.NewConversionContext()), context)).IsReturn(out var _, out var method));

                method !.Value.Has <IInterpetedMethod>().Invoke(TypeManager.EmptyMember(TypeManager.Empty()));
            }

            Assert.Equal(7, context.GetMember(new NameKey("x")).Value.Has <IBoxedDouble>().Value);
            Assert.Equal(5, context.GetMember(new NameKey("y")).Value.Has <IBoxedDouble>().Value);

            {
                Assert.False(implementation.Invoke(TypeManager.Member(context.Convert(TransformerExtensions.NewConversionContext()), context)).IsReturn(out var _, out var method));

                method !.Value.Has <IInterpetedMethod>().Invoke(TypeManager.EmptyMember(TypeManager.Empty()));
            }

            Assert.Equal(5, context.GetMember(new NameKey("x")).Value.Has <IBoxedDouble>().Value);
            Assert.Equal(7, context.GetMember(new NameKey("y")).Value.Has <IBoxedDouble>().Value);
        }
Esempio n. 2
0
        public void Test()
        {
            var testCase          = new MirrorPointImplementation();
            var conversionContext = new Definitions();
            var module            = testCase.Module.Convert(conversionContext);

            var res = module.Interpet(InterpetedContext.Root());

            Assert.False(res.IsReturn(out var _, out var value));

            var scope          = value.Value.Cast <IInterpetedScope>();
            var implementation = scope.GetMember <IInterpetedAnyType>(new NameKey("mirror")).Value.Cast <IInterpetedImplementation <IInterpetedScope, IInterpedEmpty, IInterpedEmpty> >();

            var context = TypeManager.InstanceScope(
                (new NameKey("x"), TypeManager.AnyMember(TypeManager.Double(5))),
                (new NameKey("y"), TypeManager.AnyMember(TypeManager.Double(7))));

            {
                Assert.False(implementation.Invoke(TypeManager.Member <IInterpetedScope>(context.Convert(TransformerExtensions.NewConversionContext()), context)).IsReturn(out var _, out var method));

                method.Value.Invoke(TypeManager.EmptyMember(TypeManager.Empty()));
            }

            Assert.Equal(7, context.GetMember <IInterpetedAnyType>(new NameKey("x")).Value.Cast <IBoxedDouble>().Value);
            Assert.Equal(5, context.GetMember <IInterpetedAnyType>(new NameKey("y")).Value.Cast <IBoxedDouble>().Value);

            {
                Assert.False(implementation.Invoke(TypeManager.Member <IInterpetedScope>(context.Convert(TransformerExtensions.NewConversionContext()), context)).IsReturn(out var _, out var method));

                method.Value.Invoke(TypeManager.EmptyMember(TypeManager.Empty()));
            }

            Assert.Equal(5, context.GetMember <IInterpetedAnyType>(new NameKey("x")).Value.Cast <IBoxedDouble>().Value);
            Assert.Equal(7, context.GetMember <IInterpetedAnyType>(new NameKey("y")).Value.Cast <IBoxedDouble>().Value);
        }