Пример #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 });

            Run.CompileAndRun <Empty, Empty>("test",
                                             @"
entry-point [empty; empty;] input {
    new-empty > (in.read-bool) > (out.write-bool);
    new-empty return;
};", new Empty(),
                                             new[] {
                BasicInputOutput.Input(intIn, stringIn, boolIn),
                BasicInputOutput.Output(intOut, stringOut, boolOut)
            });

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
            verifyIntOut();
            verifyStringOut();
            verifyBoolOut();
        }
Пример #2
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[] { });

            Run.CompileAndRun <Empty, Empty>("test",
                                             @"
 entry-point [empty; empty;] input { new-empty return; };", new Empty(), Array.Empty <Backend.Emit.Assembly>());

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
Пример #3
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[] { });

            Run.CompileAndRun <Empty, Empty>("test",
                                             @"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);new-empty return;};", new Empty(), new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            });

            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[] { });

            Run.CompileAndRun <Empty, Empty>("test",
                                             @"
entry-point [empty; empty;] input {
    new-empty > (in.read-number);
    new-empty return;
};", new Empty(),
                                             new[] { BasicInputOutput.Input(intIn, stringIn, boolIn) });

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
Пример #5
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[] { });

            Run.CompileAndRun <Empty, Empty>("test",
                                             @"
 entry-point [empty; empty;] input {
    ((((((((((2)) + ((2))))))) > (((out.write-number))))));
    new-empty return;
 };", new Empty(), new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            });

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
Пример #6
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[] { });

            Run.CompileAndRun <Empty, Empty>("test",
                                             @"
entry-point [empty; empty;] input {
    ""hello world"" > (out.write-string);
    
    new-empty return;
};", new Empty(), new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            });

            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[] { });

            Run.CompileAndRun <Empty, Empty>("test",
                                             @"
 entry-point [empty; empty;] input {
     true else { 1.0 > (out.write-number); };
     false else { 2.0 > (out.write-number); };
     new-empty return;
 };", new Empty(), new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            });

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
Пример #8
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 });

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

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
Пример #9
0
        public void OrType6()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToOutput(new double[] { 5 });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToOutput(new string[] { });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToOutput(new bool[] { });

            Run.CompileAndRun <Empty, Empty>("test",
                                             @"
entry-point  [empty; empty;] input{
    object { true =: bool b; 5 =: number a } =: type { bool b; number a;} | bool x;

    x is type { bool b; number a;} z { z.a > (out.write-number) } ;

    new-empty return;
};", new Empty(), new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            });

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
Пример #10
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 });

            Run.CompileAndRun <Empty, Empty>("test",
                                             @"
entry-point  [empty; empty;] input{
    true =: bool | ( bool| bool) | bool x;

    x  > (out.write-bool) ;

    new-empty return;
};", new Empty(), new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            });

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
Пример #11
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[] { });

            Run.CompileAndRun <Empty, Empty>("test",
                                             @"
 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);
    new-empty return;
 };", new Empty(), new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            });

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
Пример #12
0
        public void OrType1()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToOutput(new double[] { 5 });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToOutput(new string[] { });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToOutput(new bool[] { });

            Run.CompileAndRun <Empty, Empty>("test",
                                             @"
entry-point  [empty; empty;] input{
    5 =: bool | number x;

    x is number y { y > (out.write-number) };
    x is bool y { y > (out.write-bool) };
    
    new-empty return;
};", new Empty(), new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            });

            verifyIntIn();
            verifyStringIn();
            verifyBoolIn();
        }
Пример #13
0
        public void OrType8()
        {
            var(intIn, verifyIntIn)       = BasicInputOutput.ToOutput(new double[] { 5 });
            var(stringIn, verifyStringIn) = BasicInputOutput.ToOutput(new string[] { });
            var(boolIn, verifyBoolIn)     = BasicInputOutput.ToOutput(new bool[] { });

            // x.a is number a { a > out.write-number };
            Run.CompileAndRun <Empty, Empty>("test",
                                             @"
entry-point [empty; empty;] input {
    object { 5 =: number a } =: type { number a;} | type { number a;} x;

    x.a > out.write-number;

    new-empty return;
};",
                                             new Empty(), new[] {
                BasicInputOutput.Output(intIn, stringIn, boolIn)
            });

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