示例#1
0
 public static MetaProgram.List CreateList_Student([PexAssumeNotNull] int[] arr)
 {
     MetaProgram.List list = new MetaProgram.List();
     for (int i = 0; i < arr.Length; i++)
     {
         list.addToEnd(arr[i]); //Invoke students' addToEnd
     }
     return(list);
 }
示例#2
0
        public static void Check([PexAssumeUnderTest] MetaProgram.List l, [PexAssumeUnderTest] MetaProgram.List l2, int x, int numIterations)
        {
            //Use PexAssume.IsTrue instead of Clone(), as not to give Pex any issues
            PexAssume.IsTrue(l.Equals(l2));
            //Ensure that Pex generates two distinct MetaProgram.List objects
            PexAssume.AreNotSame(l, l2);

            bool firstNull  = false;
            bool secondNull = false;

            try
            {
                for (int i = 0; i < numIterations; i++)
                {
                    l.addToEnd(x);
                }
            }
            catch (NullReferenceException)
            {
                firstNull = true;
            }

            try
            {
                for (int j = 0; j < numIterations; j++)
                {
                    l2.addToEndSolution(x);
                }
            }
            catch (NullReferenceException)
            {
                secondNull = true;
            }

            bool passingCondition = ((firstNull == secondNull && firstNull == true) || (firstNull == secondNull && firstNull == false && l2.Equals(l)));
            bool failingCondition = !passingCondition;

            if (failingCondition)
            {
                throw new Exception();
            }
        }
示例#3
0
        public static void Check([PexAssumeUnderTest] MetaProgram.List l, [PexAssumeUnderTest] MetaProgram.List l2, [PexAssumeUnderTest] MetaProgram.List l3, int x, Boolean b, int numIterations)
        {
            bool firstNull  = false;
            bool secondNull = false;

            PexAssume.IsTrue(l.Equals(l2));
            PexAssume.IsTrue(l.Equals(l3));
            //Ensure that Pex generates three distinct MetaProgram.List objects
            PexAssume.AreNotSame(l, l2);
            PexAssume.AreNotSame(l, l3);


            // List l2 = l.Clone();
            //List l3 = l.Clone();


            try
            {
                for (int i = 0; i < numIterations; i++)
                {
                    l.addToEnd(x);
                }
            }
            catch (NullReferenceException)
            {
                firstNull = true;
            }

            try
            {
                for (int j = 0; j < numIterations; j++)
                {
                    l2.addToEndSolution(x);
                }
            }
            catch (NullReferenceException)
            {
                secondNull = true;
            }

            try
            {
                for (int j = 0; j < numIterations; j++)
                {
                    l3.addToEndSolutionForReal(x);
                }
            }
            catch (NullReferenceException)
            {
                Console.WriteLine("addToEndSolutionForReal got  null refence exception!");
            }

            bool passingCondition = ((firstNull == secondNull && firstNull == true) || (firstNull == secondNull && firstNull == false && l2.Equals(l)));
            bool failingCondition = !passingCondition;

            if (failingCondition)
            {
                throw new Exception("Student submission is equivalent to correct solution, but is not equal to reference submission.");
            }

            //Implement Subsumption PUT
            //Purpose: Determine if subsumption exists across submissions in different child...
            //...clusters within same parent cluster
            if (passingCondition)
            {
                if (b)
                {
                    if (l3.Equals(l))
                    {
                        if (!l2.Equals(l))
                        {
                            throw new Exception("Exception 1: Student submission is equivalent to correct solution, but is not equal to reference submission.");
                        }
                    }
                }
                else
                {
                    if (l3.Equals(l2))
                    {
                        if (!l2.Equals(l))
                        {
                            throw new Exception("Exception 2: Reference submission is equivalent to correct solution, but is not equal to student submission.");
                        }
                    }
                }
            }
        }
示例#4
0
        public static void Check([PexAssumeNotNull] MetaProgram.List l, int x, Boolean b)
        {
            bool firstNull  = false;
            bool secondNull = false;

            List l2 = l.Clone();
            List l3 = l.Clone();

            bool notSubsumption = true;


            try
            {
                l.addToEnd(x);
            }
            catch (NullReferenceException)
            {
                firstNull = true;
            }

            try
            {
                l2.addToEndSolution(x);
            }
            catch (NullReferenceException)
            {
                secondNull = true;
            }

            try
            {
                l3.addToEndSolutionForReal(x);
            }
            catch (NullReferenceException)
            {
                Console.WriteLine("addToEndSolutionForReal got  null refence exception!");
            }

            bool passingCondition = ((firstNull == secondNull && firstNull == true) || (firstNull == secondNull && firstNull == false && l2.isEquals(l)));
            bool failingCondition = !passingCondition;

            if (failingCondition)
            {
                throw new Exception("Student submission is equivalent to correct solution, but is not equal to reference submission.");
            }

            //Implement Subsumption PUT
            //Purpose: Determine if subsumption exists across submissions in different child...
            //...clusters within same parent cluster
            if (passingCondition)
            {
                if (b)
                {
                    //s1 >= s2
                    if (l3.isEquals(l))
                    {
                        if (!l2.isEquals(l))
                        {
                            throw new Exception("Student submission is equivalent to correct solution, but is not equal to reference submission.");
                        }
                    }
                }
                else
                {
                    //s2 >= s1
                    if (!l3.isEquals(l))
                    {
                        if (l3.isEquals(l2))
                        {
                            notSubsumption = false;
                        }
                    }
                }
            }
            //Visualize the val of notSubsumption
            PexObserve.ValueForViewing("notSubsumption", notSubsumption);

            PexAssert.IsTrue(notSubsumption);
        }