Ejemplo n.º 1
0
    public string Puzzle(int in_1, string in_2, int in_3)
    {
        PexAssume.IsTrue(in_1 > 1 & in_1 <= 50);
        PexAssume.IsTrue(in_3 > 1 & in_3 <= 50);
        // 12/13/19: Commenting below line to see if it gets rid of FP in cluster 0
        // if (in_1 == 10 || in_1 == 20 || in_1 == 30);

        PexAssume.IsNotNull(in_2);
        PexAssume.IsTrue(in_2.Length >= 3);
        int len = in_2.Length;

        if (in_2 == "codehunt")
        {
            ;
        }
        if (in_2 == "abcabc")
        {
            ;
        }
        for (int x = 0; x < len; x++)
        {
            PexAssume.IsTrue(in_2[x] >= 'a' & in_2[x] <= 'z');
        }


        string result = global::GlobalMembers.Main(in_1, in_2, in_3);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <string>(result));
    }
Ejemplo n.º 2
0
    public string Puzzle(int i)
    {
        PexAssume.IsTrue(i >= 0 & i < 1000);

        int[] result = global::Program.Puzzle(i);
        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <int[]>(result));
    }
Ejemplo n.º 3
0
    public string Puzzle(int input)
    {
        PexAssume.IsTrue(input >= 0 & input < 1000);

        int result = global::Program.Puzzle(input);
        return PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString<int>(result);
    }
        public void Unions(int elementCount, [PexAssumeNotNull] KeyValuePair <int, int>[] unions)
        {
            PexAssume.IsTrue(0 < elementCount);
            PexSymbolicValue.Minimize(elementCount);
            PexAssertEx.TrueForAll(
                unions,
                u => 0 <= u.Key && u.Key < elementCount &&
                0 <= u.Value && u.Value < elementCount
                );

            var target = new ForestDisjointSet <int>();

            // fill up with 0..elementCount - 1
            for (int i = 0; i < elementCount; i++)
            {
                target.MakeSet(i);
                Assert.IsTrue(target.Contains(i));
                Assert.AreEqual(i + 1, target.ElementCount);
                Assert.AreEqual(i + 1, target.SetCount);
            }

            // apply Union for pairs unions[i], unions[i+1]
            for (int i = 0; i < unions.Length; i++)
            {
                var left  = unions[i].Key;
                var right = unions[i].Value;

                var  setCount = target.SetCount;
                bool unioned  = target.Union(left, right);
                // should be in the same set now
                Assert.IsTrue(target.AreInSameSet(left, right));
                // if unioned, the count decreased by 1
                PexAssertEx.ImpliesIsTrue(unioned, () => setCount - 1 == target.SetCount);
            }
        }
Ejemplo n.º 5
0
    public string Puzzle(string s, char x)
    {
        PexAssume.IsNotNull(s);
        PexAssume.IsNotNull(x);
        PexAssume.IsTrue(s.Length >= 3);
        int len = s.Length;

        if (s == "codehunt")
        {
            ;
        }
        if (s == "abcabc")
        {
            ;
        }
        for (int i = 0; i < len; i++)
        {
            PexAssume.IsTrue(s[i] == ' ' | (s[i] >= 'a' & s[i] <= 'z'));
        }
        PexAssume.IsTrue(x == ' ' | (x >= 'a' & x <= 'z'));

        int result = global::Program.Puzzle(s, x);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <int>(result));
    }
Ejemplo n.º 6
0
 public void AddImport([PexAssumeUnderTest] AphidInterpreter target, string name)
 {
     PexSymbolicValue.Ignore(target.OwnerThread);
     PexSymbolicValue.Ignore(target.AsmBuilder.AssemblyName);
     PexSymbolicValue.Ignore(target.AsmBuilder.AssemblyFilename);
     target.AddImport(name);
     // TODO: add assertions to method AphidInterpreterTest.AddImport(AphidInterpreter, String)
 }
Ejemplo n.º 7
0
    public string Puzzle(int x, int y)
    {
        PexAssume.IsTrue(x >= 0 & y > 0);

        bool result = global::Program.Puzzle(x, y);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <bool>(result));
    }
Ejemplo n.º 8
0
    public string Puzzle(int t)
    {
        PexAssume.IsTrue(t >= 0 & t < 1000);

        string result = global::Program.Puzzle(t);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <string>(result));
    }
Ejemplo n.º 9
0
    public string Puzzle(int upperBound)
    {
        PexAssume.IsTrue(upperBound >= 0 & upperBound < 1000);

        int result = global::Program.Puzzle(upperBound);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <int>(result));
    }
Ejemplo n.º 10
0
    public string Puzzle(int n, int m)
    {
        PexAssume.IsTrue(n > 0 & n < 10 & m >= 0 & m <= n);

        int result = global::Program.Puzzle(n, m);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <int>(result));
    }
Ejemplo n.º 11
0
 public int[][] Puzzle(int x, int y)
 {
     PexAssume.IsTrue(1 <= x & x <= 8 & 1 <= y & y <= 8);
     if (x == 5 & y == 1 | x == 3 & y == 8)
     {
         ;                        // Hint to user
     }
     int[][] result = global::Program.Puzzle(x, y);
     return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <int[][]>(result));
 }
Ejemplo n.º 12
0
        public static void Iteration([PexAssumeUnderTest] IVertexListGraph <T, E> g)
        {
            int i = 0;

            foreach (T v in PexSymbolicValue.IgnoreEnumeration(g.Vertices))
            {
                ++i;
            }
            Assert.AreEqual(g.VertexCount, i);
        }
Ejemplo n.º 13
0
    public string Puzzle(int[] a)
    {
        PexAssume.IsNotNull(a);
        PexAssume.IsTrue(a.Length >= 2 & a.Length <= 20);
        foreach (int v in a)
        {
            PexAssume.IsTrue(v >= -50 & v <= 50);
        }
        int result = global::Program.Puzzle(a);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <int>(result));;
    }
Ejemplo n.º 14
0
    public string Puzzle(int number, int power)
    {
        PexAssume.IsTrue(0 < number & number < 100);
        PexAssume.IsTrue(0 < power & power < 100);
        if ((number == 21 & power == 6) | (number == 23 & power == 14))
        {
            ;
        }

        int result = global::Program.Puzzle(number, power);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <int>(result));
    }
Ejemplo n.º 15
0
    public string Puzzle(int[] a, int k)
    {
        PexAssume.IsNotNull(a);
        PexAssume.IsTrue(a.Length >= 4 & k >= 0 & k < a.Length);
        foreach (int v in a)
        {
            PexAssume.IsTrue(v >= -100 & v <= 100);
        }

        int result = global::Program.Puzzle(a, k);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <int>(result));
    }
Ejemplo n.º 16
0
    public string Puzzle(int i, int j)
    {
        PexAssume.IsTrue(0 < i & i < 100);
        PexAssume.IsTrue(0 < j & j < 100);
        if ((i == 21 & j == 6) | (i == 23 & j == 14))
        {
            ;
        }

        bool result = global::Program.Puzzle(i, j);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <bool>(result));
    }
Ejemplo n.º 17
0
    public string Puzzle(int[] a)
    {
        PexAssume.IsNotNull(a);
        PexAssume.IsTrue(a.Length > 2);
        if (a.Length == 3 & a[0] == 17 & a[1] == 31 & a[2] == 48)
        {
            ;
        }

        int result = global::Program.Puzzle(a);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <int>(result));
    }
Ejemplo n.º 18
0
    public string Puzzle(int i, int x)
    {
        PexAssume.IsTrue(0 < i & i < 100);
        PexAssume.IsTrue(0 < x & x < 100);
        if ((i == 21 & x == 6) | (i == 23 & x == 14))
        {
            ;
        }

        string result = global::Program.Puzzle(i, x);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <string>(result));
    }
Ejemplo n.º 19
0
    public string Sort(int[] a)
    {
        // PexAssume.IsTrue(x >= 0 & x < 1000);
        PexAssume.IsNotNull(a);
        PexAssume.IsTrue(a.Length >= 2 & a.Length <= 4);
        foreach (int v in a)
        {
            PexAssume.IsTrue(v >= -10 & v <= 10);
        }

        int[] result = global::Program.Sort(a);
        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <int[]>(result));
    }
Ejemplo n.º 20
0
    public string Puzzle(int a, int b)
    {
        PexAssume.IsTrue(0 < a & a < 100);
        PexAssume.IsTrue(0 < b & b < 100);
        if ((a == 21 & b == 6) | (a == 23 & b == 14))
        {
            ;
        }

        int result = global::Program.Puzzle(a, b);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <int>(result));
    }
Ejemplo n.º 21
0
    public string Puzzle(int[] numbers)
    {
        PexAssume.IsNotNull(numbers);
        PexAssume.IsTrue(numbers.Length >= 2 & numbers.Length <= 5);
        foreach (int v in numbers)
        {
            PexAssume.IsTrue(v >= -50 & v <= 50);
        }

        bool result = global::Program.Puzzle(numbers);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <bool>(result));
    }
Ejemplo n.º 22
0
    public string Puzzle(int lowerBound, int upperBound)
    {
        PexAssume.IsTrue(0 < lowerBound & lowerBound < 100);
        PexAssume.IsTrue(0 < upperBound & upperBound < 100);
        if ((lowerBound == 21 & upperBound == 6) | (lowerBound == 23 & upperBound == 14))
        {
            ;
        }

        int result = global::Program.Puzzle(lowerBound, upperBound);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <int>(result));
    }
Ejemplo n.º 23
0
    public string Puzzle(int i, int j, int k)
    {
        PexAssume.IsTrue(0 < i & i < 100);
        PexAssume.IsTrue(0 < j & j < 100);
        PexAssume.IsTrue(0 < k & k < 100);
        if ((i == 21 & j == 6 & k == 11) | (i == 23 & j == 14 & k == 20))
        {
            ;
        }

        string result = global::Program.Puzzle(i, j, k);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <string>(result));
    }
Ejemplo n.º 24
0
    public string Puzzle(int a, int b, int c)
    {
        PexAssume.IsTrue(0 < a & a < 100);
        PexAssume.IsTrue(0 < b & b < 100);
        PexAssume.IsTrue(0 < c & c < 100);
        if ((a == 21 & b == 6 & c == 11) | (a == 23 & b == 14 & c == 20))
        {
            ;
        }

        bool result = global::Program.Puzzle(a, b, c);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <bool>(result));
    }
Ejemplo n.º 25
0
    public string Puzzle(int[] a, int t)
    {
        PexAssume.IsNotNull(a);
        PexAssume.IsTrue(a.Length >= 2 & a.Length <= 5);
        foreach (int v in a)
        {
            PexAssume.IsTrue(v >= -50 & v <= 50);
        }
        PexAssume.IsTrue(t >= 1 & t <= 50);
        // 12/13/19: Commenting below line to see if it gets rid of FP in cluster 0
        // if (t == 10 || t == 20 || t == 30);

        int[] result = global::Program.Puzzle(a, t);
        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <int[]>(result));
    }
Ejemplo n.º 26
0
    public string Puzzle(int slope1, int yintercept1, int slope2)
    {
        PexAssume.IsTrue(0 < slope1 & slope1 < 100);
        PexAssume.IsTrue(0 < yintercept1 & yintercept1 < 100);
        PexAssume.IsTrue(0 < slope2 & slope2 < 100);
        PexAssume.IsTrue(0 < yintercept2 & yintercept2 < 100);
        if ((slope1 == 21& yintercept1 == 6& slope2 == 11& yintercept2 = 14) | (slope1 == 23& yintercept1 == 14& slope2 == 20& yintercept2 = 18))
        {
            ;
        }

        string result = global::Program.Puzzle(slope1, yintercept1, slope2, yintercept2);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <string>(result));
    }
Ejemplo n.º 27
0
    public string Puzzle(int[] numbers, int x)
    {
        PexAssume.IsNotNull(numbers);
        PexAssume.IsTrue(numbers.Length >= 2 & numbers.Length <= 5);
        foreach (int v in numbers)
        {
            PexAssume.IsTrue(v >= -50 & v <= 50);
        }
        PexAssume.IsTrue(x >= 1 & x <= 50);
        // 12/13/19: Commenting below line to see if it gets rid of FP in cluster 0
        // if (x == 10 || x == 20 || x == 30);

        int[] result = global::Program.Puzzle(numbers, x);
        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <int[]>(result));
    }
Ejemplo n.º 28
0
    public string Puzzle(int loop_len, double[] loop_input)
    {
        PexAssume.IsNotNull(loop_input);
        PexAssume.IsTrue(loop_input.Length >= 2 & loop_input.Length <= 5);
        PexAssume.IsTrue(loop_len >= 1 & loop_len < loop_input.Length);
        foreach (double v in loop_input)
        {
            PexAssume.IsTrue(v >= -50 & v <= 50);
        }
        // 12/13/19: Commenting below line to see if it gets rid of FP in cluster 0
        // if (loop_len == 10 || loop_len == 20 || loop_len == 30);

        double result = global::GlobalMembers.Main(loop_len, loop_input);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <double>(result));
    }
Ejemplo n.º 29
0
    public string Puzzle(int[] a)
    {
        PexAssume.IsNotNull(a);
        PexAssume.IsTrue(a.Length > 0);
        if (a.Length == 3 && (a[0] == 13 & a[1] == -5 && a[2] == 7))
        {
            ;
        }
        foreach (var n in a)
        {
            PexAssume.IsTrue(n >= -100 & n <= 100);
        }
        int result = global::Program.Puzzle(a);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <int>(result));
    }
Ejemplo n.º 30
0
    public string Puzzle(int[] list, int i)
    {
        PexAssume.IsNotNull(list);
        PexAssume.IsTrue(list.Length >= 2 & list.Length <= 5);
        foreach (int v in list)
        {
            PexAssume.IsTrue(v >= -50 & v <= 50);
        }
        PexAssume.IsTrue(i >= 1 & i <= 50);
        // 12/13/19: Commenting below line to see if it gets rid of FP in cluster 0
        // if (i == 10 || i == 20 || i == 30);

        bool result = global::Program.Puzzle(list, i);

        return(PexSymbolicValue.GetPathConditionString() + " RET_DIV " + PexSymbolicValue.ToString <bool>(result));
    }