Esempio n. 1
0
        public void TestFor()
        {
            for (int i = 0; i < testForStatements.Length; ++i)
            {
                var main  = new Interpreter.Sequence();
                var queue = new List <string>();

                queue.AddRange(testForStatements[i]);

                int line = 0;

                while (line < queue.Count)
                {
                    line = main.Execute(queue, line);
                }

                switch (resultForRuns[i].GetType().Name)
                {
                case "Double": Assert.AreEqual((Double)resultForRuns[i], (Double)main.GetNamedValue("sum"), 0.05);
                    break;

                default: Assert.AreEqual(resultForRuns[i], main.GetNamedValue("sum"));
                    break;
                }
            }
        }
Esempio n. 2
0
        public Interpreter.Sequence TestAssignTo()
        {
            var main = new Interpreter.Sequence();

            for (int i = 0; i < testAssignments.Length; ++i)
            {
                Verbs.AssignTo(main, testAssignments[i]);

                Assert.AreEqual(resultAssignValues[i], main.GetNamedValue(resultAssignNames[i]));
            }

            return(main);
        }
Esempio n. 3
0
        public void TestRemainderFrom()
        {
            var main = new Interpreter.Sequence();

            for (int i = 0; i < assignHighComposites.Length; ++i)
            {
                Verbs.AssignTo(main, assignHighComposites[i]);
            }

            for (int i = 0; i < testRemainders.Length; ++i)
            {
                Verbs.RemainderFrom(main, testRemainders[i]);

                Assert.AreEqual(resultRemainders[i], main.GetNamedValue(numerics[i]));
            }
        }
Esempio n. 4
0
        public void TestWhile()
        {
            var queue = new List <string>();

            queue.AddRange(testWhileProcess.Split('\n'));

            for (int i = 0; i < testWhileDeclarations.Length; ++i)
            {
                var main      = new Interpreter.Sequence();
                var testQueue = new List <string>();

                testQueue.Add(testWhileDeclarations[i]);
                testQueue.AddRange(queue);

                int line = 0;

                while (line < testQueue.Count)
                {
                    line = main.Execute(testQueue, line);
                }

                Assert.AreEqual(resultWhileRuns[i], main.GetNamedValue("counter"));
            }
        }