Beispiel #1
0
        private static void ProcessPrograms(List <Program> dafnyPrograms)
        {
            SimpleVerifier verifier = new SimpleVerifier();
            DareSim        dare     = new DareSim(new StopChecker());

            foreach (var program in dafnyPrograms)
            {
                dare.ProcessProgram(program);
                using (TextWriter writer = File.CreateText(_outputDir + "\\processed-" + program.Name)) {
                    PrintProgram(program, writer);
                }
                if (!verifier.IsProgramValid(program))
                {
                    throw new Exception("Program not valid after process");
                }
                var decls   = program.DefaultModuleDef.TopLevelDecls;
                var members = new List <MemberDecl>();
                foreach (var topLevelDecl in decls)
                {
                    var classDec = topLevelDecl as ClassDecl;
                    if (classDec == null)
                    {
                        continue;
                    }
                    members.AddRange(classDec.Members);
                }
                dare.ProcessMembers(program, members);
            }
        }
Beispiel #2
0
        private void TryRemovingItemForOrderingTest(T item, List <T> parent, Method method, int index, List <T> currentSolution, List <List <T> > solutions)
        {
            if (_allRemoved)
            {
                return;
            }
            var assertPos = parent.IndexOf(item);

            parent.Remove(item);
            var validator = new SimpleVerifier();

            if (validator.IsProgramValid(_program))
            {
                var newCurrentSolution = new List <T>(currentSolution)
                {
                    item
                };                                                            //create a copy of the currentSolution and add in the item
                TestRemovalOrdering(index + 1, solutions, newCurrentSolution, method);
                if (_allRemoved)
                {
                    return;
                }
                parent.Insert(assertPos, item);
                TestRemovalOrdering(index + 1, solutions, currentSolution, method);
            }
            else
            {
                parent.Insert(assertPos, item);
                TestRemovalOrdering(index + 1, solutions, currentSolution, method);
            }
        }
Beispiel #3
0
        private long GetVerificationTime(Program program)
        {
            var verifier            = new SimpleVerifier();
            var sw                  = new Stopwatch();
            var origSnapshotSetting = DafnyOptions.O.VerifySnapshots;

            DafnyOptions.O.VerifySnapshots = 0;
            var programClone = SimpleCloner.CloneProgram(program);

            sw.Start();
            verifier.IsProgramValid(programClone);
            sw.Stop();
            DafnyOptions.O.VerifySnapshots = origSnapshotSetting;
            return(sw.ElapsedMilliseconds);
        }
Beispiel #4
0
        public void TestMethodRemoval()
        {
            Initialise();
            var program = GetProgram("ListCopy.dfy");
            var members = GetMembers(program);

            foreach (var member in members)
            {
                if (member.Name == "Copy")
                {
                    var methodRemover = new MethodRemover(program);
                    var removables    = methodRemover.FullSimplify(member);
                    Assert.AreEqual(2, removables.RemovableInvariants.Count);
                    Assert.AreEqual(3, removables.RemovableAsserts.Count);
                    var verifier = new SimpleVerifier();
                    Assert.True(verifier.IsProgramValid(program));
                }
            }
        }
Beispiel #5
0
        public bool IsProgramValid()
        {
            var validator = new SimpleVerifier();

            return(validator.IsProgramValid(Program));
        }
Beispiel #6
0
 public bool IsProgramValid()
 {
     var validator = new SimpleVerifier();
     return validator.IsProgramValid(Program);
 }