예제 #1
0
        public void BoolInputOutput()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToInput(new double[] {  });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToInput(new string[] { });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToInput(new bool[] { true });

            var(intOut, verifyIntOut)       = BasicInputOutput.ToOutput(new double[] { });
            var(stringOut, verifyStringOut) = BasicInputOutput.ToOutput(new string[] { });
            var(boolOut, verifyBoolOut)     = BasicInputOutput.ToOutput(new bool[] { true });

            Tac.Interpreted.Runner.Runner.RunInterpeted("test",
                                                        new[] {
                BasicInputOutput.Input(intIn, stringIn, boolIn),
                BasicInputOutput.Output(intOut, stringOut, boolOut)
            },
                                                        @"
entry-point [empty; empty;] input {
    new-empty > (in.read-bool) > (out.write-bool);
};");

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
            verifyIntOut();
            verifyStringOut();
            verifyBoolOut();
        }
예제 #2
0
        public void MultiplyCompact()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToOutput(new double[] { 4.0, 6.0, 8.0, 10.0 });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToOutput(new string[] { });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToOutput(new bool[] { });

            Tac.Interpreted.Runner.Runner.RunInterpeted("test", new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            },
                                                        @"entry-point[empty; empty;] input {2*2>(out.write-number);3*2>(out.write-number);4*2>(out.write-number);5*2>(out.write-number);};");

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
예제 #3
0
        public void Simple()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToOutput(new double[] {  });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToOutput(new string[] { });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToOutput(new bool[] { });

            Tac.Interpreted.Runner.Runner.RunInterpeted("test", new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            },
                                                        @"
 entry-point [empty; empty;] input { };");

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
예제 #4
0
        public void NumberInput()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToInput(new double[] { 1.0 });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToInput(new string[] { });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToInput(new bool[] { });

            Tac.Interpreted.Runner.Runner.RunInterpeted("test",
                                                        new[] { BasicInputOutput.Input(intIn, stringIn, boolIn) },
                                                        @"
entry-point [empty; empty;] input {
    new-empty > (in.read-number);
};");

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
예제 #5
0
        public void StringOutput()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToOutput(new double[] { });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToOutput(new string[] { "hello world" });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToOutput(new bool[] { });

            Tac.Interpreted.Runner.Runner.RunInterpeted("test", new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            },
                                                        @"
entry-point [empty; empty;] input {
   ""hello world"" > (out.write-string);
};");

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
예제 #6
0
        public void NestedParn()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToOutput(new double[] { 4.0 });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToOutput(new string[] { });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToOutput(new bool[] { });

            Tac.Interpreted.Runner.Runner.RunInterpeted("test", new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            },
                                                        @"
 entry-point [empty; empty;] input {
     ((((((((((2)) + ((2))))))) > (((out.write-number))))));
 };");

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
예제 #7
0
        public void Else()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToOutput(new double[] { 2.0 });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToOutput(new string[] { });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToOutput(new bool[] { });

            Tac.Interpreted.Runner.Runner.RunInterpeted("test", new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            },
                                                        @"
 entry-point [empty; empty;] input {
     true else { 1.0 > (out.write-number); };
     false else { 2.0 > (out.write-number); };
 };");

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
예제 #8
0
        public void OrType7()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToOutput(new double[] { 5 });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToOutput(new string[] { });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToOutput(new bool[] {  });

            Tac.Interpreted.Runner.Runner.RunInterpeted("test", new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            },
                                                        @"
entry-point [empty; empty;] input {
    object { true =: bool b; 5 =: number a } =: type { bool b; number a;} | type { bool b; number a;} x;

    x.a is number a { a > out.write-number };
};");

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
예제 #9
0
        public void OrType5()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToOutput(new double[] { });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToOutput(new string[] { });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToOutput(new bool[] { true });

            Tac.Interpreted.Runner.Runner.RunInterpeted("test", new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            },
                                                        @"
entry-point  [empty; empty;] input{
    true =: bool | ( bool| bool) | bool x;

    x  > (out.write-bool) ;
};");

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
예제 #10
0
        public void LessThen()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToOutput(new double[] { });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToOutput(new string[] { });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToOutput(new bool[] { true, false, false });

            Tac.Interpreted.Runner.Runner.RunInterpeted("test", new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            },
                                                        @"
 entry-point [empty; empty;] input {
     1 <? 2 > (out.write-bool);
     2 <? 2 > (out.write-bool);
     3 <? 2 > (out.write-bool);
 };");

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
예제 #11
0
        public void OrType2()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToOutput(new double[] { });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToOutput(new string[] { });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToOutput(new bool[] { true });

            Tac.Interpreted.Runner.Runner.RunInterpeted("test", new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            },
                                                        @"
entry-point [empty; empty;] input {
    true =: (bool|number) x;

    x is number y { y > (out.write-number) };
    x is bool z { z > (out.write-bool) } ;
};");

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
예제 #12
0
        public void Add()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToOutput(new double[] { 4.0, 5.0, 6.0, 7.0 });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToOutput(new string[] { });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToOutput(new bool[] { });

            Tac.Interpreted.Runner.Runner.RunInterpeted("test", new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            },
                                                        @"
 entry-point [empty; empty;] input {
     2 + 2 > (out . write-number);
     3 + 2 > (out . write-number);
     4 + 2 > (out . write-number);
     5 + 2 > (out . write-number);
 };");

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
예제 #13
0
        public void Subtract()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToOutput(new double[] { 0.0, 1.0, 2.0, 3.0 });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToOutput(new string[] { });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToOutput(new bool[] { });

            Tac.Interpreted.Runner.Runner.RunInterpeted("test", new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            },
                                                        @"
 entry-point [empty; empty;] input {
     2 - 2 > (out.write-number);
     3 - 2 > (out.write-number);
     4 - 2 > (out.write-number);
     5 - 2 > (out.write-number);
 };");

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }