Пример #1
0
        internal void CheckRefinementTest(RefinementTest test)
        {
            //check that the test module is closed with respect to creates
            var notImplementedInterface =
                test.LeftModExpr.ModuleInfo.Creates.Interfaces.Where(i =>
                                                                     !test.LeftModExpr.ModuleInfo.InterfaceDef.Keys.Contains(i));
            var @interface = notImplementedInterface as Interface[] ?? notImplementedInterface.ToArray();

            if (@interface.Any())
            {
                throw handler.NotClosed(test.SourceLocation,
                                        $"LHS test module is not closed with respect to created interfaces; interface {@interface.First()} is created but not implemented inside the module");
            }


            //check that the test module main machine exists
            var hasMainMachine =
                test.LeftModExpr.ModuleInfo.InterfaceDef.Values.Any(m => m.Name == test.Main && !m.IsSpec);

            if (!hasMainMachine)
            {
                throw handler.NoMain(test.SourceLocation,
                                     $"machine {test.Main} does not exist in the LHS test module");
            }

            //check that the test module is closed with respect to creates
            notImplementedInterface =
                test.RightModExpr.ModuleInfo.Creates.Interfaces.Where(i =>
                                                                      !test.RightModExpr.ModuleInfo.InterfaceDef.Keys.Contains(i));
            @interface = notImplementedInterface as Interface[] ?? notImplementedInterface.ToArray();
            if (@interface.Any())
            {
                throw handler.NotClosed(test.SourceLocation,
                                        $"RHS test module is not closed with respect to created interfaces; interface {@interface.First()} is created but not implemented inside the module");
            }


            //check that the test module main machine exists
            hasMainMachine =
                test.RightModExpr.ModuleInfo.InterfaceDef.Values.Any(m => m.Name == test.Main && !m.IsSpec);
            if (!hasMainMachine)
            {
                throw handler.NoMain(test.SourceLocation,
                                     $"machine {test.Main} does not exist in the RHS test module");
            }

            //todo: Implement the checks with respect to refinement relation
            throw new NotImplementedException();
        }