Exemple #1
0
        public void TestAssign()
        {
            // Plan
            using var input = "x = 9*9;PRINT x;x = 8;y = 2;z = x*y;PRINT x; PRINT z; PRINT y; PRINT x+y+z;".ToStream();
            var output = "81;8;16;2;26;";

            // Do
            var compiler = new Compiler.CompilerEnvironment();

            compiler.Compile(input);

            // Check
            Assert.AreEqual(output, compiler.Output);
        }
Exemple #2
0
        public void TestTernaryPriority()
        {
            // Plan
            using var input = "x = 5;PRINT x + -4 ? 11 : 12;PRINT (x + -4) ? 11 : 12;".ToStream();
            var output = "17;11;";

            // Do
            var compiler = new Compiler.CompilerEnvironment();

            compiler.Compile(input);

            // Check
            Assert.AreEqual(output, compiler.Output);
        }
Exemple #3
0
        public void TestSum()
        {
            // Plan
            using var input = "PRINT5+5;PRINT 10 + 11  ;".ToStream();
            var output = "10;21;";

            // Do
            var compiler = new Compiler.CompilerEnvironment();

            compiler.Compile(input);

            // Check
            Assert.AreEqual(output, compiler.Output);
        }
Exemple #4
0
        public void TestTernary()
        {
            // Plan
            using var input = "x = 5;z = x ? 10 :x;PRINT z;PRINT 1 ? 8 : 7;".ToStream();
            var output = "5;8;";

            // Do
            var compiler = new Compiler.CompilerEnvironment();

            compiler.Compile(input);

            // Check
            Assert.AreEqual(output, compiler.Output);
        }