Exemplo n.º 1
0
        protected void runBasicTest(string program, Dictionary <string, object> variablesIn, VariableMultimap expectedVariables, int expectedIterations,
                                    string[] ignoreVariables)
        {
            var context   = runProgram(program, variablesIn, expectedIterations);
            var variables = new VariableMultimap(context);

            try
            {
                variables.AssertSubsetEquals(expectedVariables);
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
Exemplo n.º 2
0
        public void DeclareConstructor()
        {
            var interpreter = runProgram("a = 1\n" +
                                         "class Foo:\n" +
                                         "   def __init__(self):\n" +
                                         "      global a\n" +
                                         "      a = 2\n" +
                                         "\n" +
                                         "bar = Foo()\n", new Dictionary <string, object>(), 1);
            var variables = new VariableMultimap(interpreter);
            var reference = new VariableMultimap(new TupleList <string, object> {
                { "a", PyInteger.Create(2) }
            });

            Assert.DoesNotThrow(() => variables.AssertSubsetEquals(reference));
        }
Exemplo n.º 3
0
        public void ThreeVariablesMatch()
        {
            VariableMultimap a = new VariableMultimap(new TupleList <string, object>
            {
                { "foo", "bar" },
                { "a", "b" },
                { "x", "y" }
            });

            try
            {
                a.AssertSubsetEquals(a);
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
Exemplo n.º 4
0
        public void BasicVariableTypeMismatch()
        {
            VariableMultimap a = new VariableMultimap(new TupleList <string, object>
            {
                { "foo", "bar" }
            });

            VariableMultimap b = new VariableMultimap(new TupleList <string, object>
            {
                { "foo", 1 }
            });

            // Starting with a vs b; this mismatch will be for an integer
            try
            {
                a.AssertSubsetEquals(b);
                throw new Exception("Mismatch was not detected");
            }
            catch (Exception e)
            {
                if (e.Message != "Missing record for 'foo' of type System.Int32\n")
                {
                    Assert.Fail(e.Message);
                }
            }

            // Trying again with b vs a; this mismatch will be for a string
            try
            {
                b.AssertSubsetEquals(a);
                throw new Exception("Mismatch was not detected");
            }
            catch (Exception e)
            {
                if (e.Message != "Missing record for 'foo' of type System.String\n")
                {
                    Assert.Fail(e.Message);
                }
            }
        }
Exemplo n.º 5
0
        public void BasicVariableMismatch()
        {
            VariableMultimap a = new VariableMultimap(new TupleList <string, object>
            {
                { "foo", "bar" }
            });

            VariableMultimap b = new VariableMultimap(new TupleList <string, object>
            {
                { "foo", "butt" }
            });

            // Starting with a vs b
            try
            {
                a.AssertSubsetEquals(b);
                throw new Exception("Mismatch was not detected");
            }
            catch (Exception e)
            {
                if (e.Message != "Mismatch 'foo' type System.String bar vs butt\n")
                {
                    Assert.Fail(e.Message);
                }
            }

            // Trying again with b vs a
            try
            {
                b.AssertSubsetEquals(a);
                throw new Exception("Mismatch was not detected");
            }
            catch (Exception e)
            {
                if (e.Message != "Mismatch 'foo' type System.String butt vs bar\n")
                {
                    Assert.Fail(e.Message);
                }
            }
        }
Exemplo n.º 6
0
        public void BasicVariableMatch()
        {
            VariableMultimap a = new VariableMultimap(new TupleList <string, object>
            {
                { "foo", "bar" }
            });

            VariableMultimap b = new VariableMultimap(new TupleList <string, object>
            {
                { "foo", "bar" }
            });

            try
            {
                a.AssertSubsetEquals(b);
                b.AssertSubsetEquals(a);
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }