Beispiel #1
0
        private static List <Step> CrawlForward(List <Step> initialSteps, int maxSteps, Location exit)
        {
            // keep track of terminals
            var terminalSteps = new List <Step>();

            // initialize BFS
            var queue        = new Queue <Step>(initialSteps);
            int visitedSteps = 0;

            // crawl!
            var recorder = new Recorder("Execute");

            while (queue.Count > 0 && (visitedSteps < maxSteps))
            {
                // fetch step
                Step step = queue.Dequeue();
                visitedSteps++;

                // track terminals
                if (step.Location == exit)
                {
                    terminalSteps.Add(step);
                }

                // try every transition
                var location = step.Location;
                var state    = step.State;
                int nextDistanceFromEntrance = step.DistanceFromEntrance + 1;
                foreach (var transition in location.Transitions)
                {
                    // execute transition
                    Location nextLocation = transition.Destination;
                    recorder.Begin();
                    State nextState = transition.Execute(state);
                    recorder.End();
                    if (nextState == null)
                    {
                        continue;                    // transition impassable
                    }
                    // location reached with new state -> enqueue
                    if (nextLocation.AddStep(nextState, nextDistanceFromEntrance, out Step nextStep))
                    {
                        queue.Enqueue(nextStep);
                    }

                    // connect steps
                    nextStep.AddPredecessor(step);
                    step.AddSuccessor(nextStep);
                }
            }
            recorder.Submit();

            return(terminalSteps);
        }
Beispiel #2
0
        public void PreventWriteTestMore()
        {
            var recorder = new Recorder <stAllTypes, PlainstAllTypes>(connector.MAIN.InheritanceRw.level_0, RecorderModeEnum.Graver, 100).Actor;

            recorder.Begin(SquashTestFile);


            for (int i = 0; i < 254; i++)
            {
                if (i % 10 == 0)
                {
                    connector.MAIN.InheritanceRw.level_0.STRING_val.Cyclic = i.ToString();
                    connector.MAIN.InheritanceRw.level_0.Write();
                }

                recorder.Act();
            }

            Assert.Throws <InsufficientNumberOfFramesException>(() => recorder.End(SquashTestFile));
        }