Esempio n. 1
0
 public void Test_103()
 {
     var e1 = new HypoLambda();
     e1.Compile("5 if not this.S else 4");
     Aux y1 = new Aux();
     y1.S = null;
     e1.Externals["this"] = y1;
     Assert.AreEqual(5.0, Convert.ToDouble(e1.Run()));
 }
Esempio n. 2
0
 public void Test_100()
 {
     var e1 = new HypoLambda();
     e1.Compile("5 if this.S == this.T else 4");
     Aux y1 = new Aux();
     y1.S = null;
     y1.T = "X";
     e1.Externals["this"] = y1;
     Assert.AreEqual(4.0, Convert.ToDouble(e1.Run()));
 }
Esempio n. 3
0
 public void Test_64()
 {
     var exp = new HypoLambda();
     exp.Compile("not ((A < B) or (A < B))");
     exp.Externals["A"] = 2.0;
     exp.Externals["B"] = 1.0;
     Assert.AreEqual(1.0, Convert.ToDouble(exp.Run()));
 }
Esempio n. 4
0
 public void Test_105()
 {
     var e1 = new HypoLambda();
     e1.Compile("5 if this.S and this.S != \"\" else 4");
     Aux y1 = new Aux();
     y1.S = "X";
     e1.Externals["this"] = y1;
     Assert.AreEqual(5.0, Convert.ToDouble(e1.Run()));
 }
Esempio n. 5
0
        public void Test_error_43()
        {
            var error = string.Format(
                            "Unexpected symbol. Waits for {0} comes {1} nearby line {2} position {3}.", "els", "ident", 4, 8);

            var exp = new HypoLambda();
            var prog = @"
            v = 3;
            u = 0;
            3 if v pepe 0
            ";
            try {
                exp.Compile(prog);
            } catch (ApplicationException ex) {
                Assert.AreEqual(error, ex.Message);
                return;
            }
            Assert.Fail();
        }
Esempio n. 6
0
        public void Test_error_41()
        {
            var error = string.Format(
                            "Maximum recursion depth reached nearby line {0} position {1}.", 3, 6);

            var exp = new HypoLambda();
            var prog = @"
            f = lambda: (
            f()
            );
            f()
            ";
            exp.Compile(prog);
            try {
                Convert.ToDouble(exp.Run());
            } catch (StackOverflowException ex) {
                Assert.AreEqual(error, ex.Message);
                return;
            }
            Assert.Fail();
        }
Esempio n. 7
0
 public void Test_builtins_16()
 {
     var exp = new HypoLambda();
     exp.Compile("map(\"-\",[3,4,5],[2,3,4]) == [1,1,1]");
     var s = Convert.ToDouble(exp.Run());
     Assert.AreEqual(1.0, s);
 }
Esempio n. 8
0
 public void Test_builtins_14()
 {
     var exp = new HypoLambda();
     exp.Compile("l1 = map(__add1__, [3,4,5]); l2=[4,5,6]; l1==l2");
     var s = Convert.ToDouble(exp.Run());
     Assert.AreEqual(1.0, s);
 }
Esempio n. 9
0
 public void Test_builtins_12()
 {
     var exp = new HypoLambda();
     exp.Compile("first( rest( rest( [3,4,5] )))");
     var s = Convert.ToDouble(exp.Run());
     Assert.AreEqual(5.0, s);
 }
Esempio n. 10
0
 public void Test_81()
 {
     var exp = new HypoLambda();
     exp.Compile("A + B if C > D else E - F");
     exp.Externals["A"] = 1.0;
     exp.Externals["B"] = 2.0;
     exp.Externals["C"] = 3.0;
     exp.Externals["D"] = 4.0;
     exp.Externals["E"] = 5.0;
     exp.Externals["F"] = 6.0;
     Assert.AreEqual(-1, Convert.ToDouble(exp.Run()));
 }
Esempio n. 11
0
 public void Test_80()
 {
     var exp = new HypoLambda();
     exp.Compile("1 + 2 if 3 > 4 else 5 - 6");
     Assert.AreEqual(-1, Convert.ToDouble(exp.Run()));
 }
Esempio n. 12
0
 public void Test_75()
 {
     var exp = new HypoLambda();
     exp.Compile("\"fail\" if (A != \"A\") else \"ok\"");
     exp.Externals["A"] = "A";
     Assert.AreEqual("ok", exp.Run());
 }
Esempio n. 13
0
 public void Test_74()
 {
     var exp = new HypoLambda();
     exp.Compile("3 if \"A\" != \"A\" else 4");
     Assert.AreEqual(4.0, Convert.ToDouble(exp.Run()));
 }
Esempio n. 14
0
 public void Test_72()
 {
     var exp = new HypoLambda();
     exp.Compile("3 if not 0 else 4");
     Assert.AreEqual(3.0, Convert.ToDouble(exp.Run()));
 }
Esempio n. 15
0
 public void Test_65()
 {
     var exp = new HypoLambda();
     exp.Compile("(not 0) * 2");
     Assert.AreEqual(2.0, Convert.ToDouble(exp.Run()));
 }
Esempio n. 16
0
 public void Test_97()
 {
     var exp = new HypoLambda();
     exp.Compile("\"Hola \" + ( \"amigo\" if {x} == 2 else \"enemigo\")");
     exp.Externals["x"] = 1.0;
     Assert.AreEqual("Hola enemigo", exp.Run());
 }
Esempio n. 17
0
 public void Test_builtins_10()
 {
     var exp = new HypoLambda();
     exp.Compile("print(4,5,6)");
     var s = exp.Run() as string;
     Assert.AreEqual("4 5 6", s);
 }
Esempio n. 18
0
 public void Test_90()
 {
     var exp = new HypoLambda();
     exp.Compile("\"Hola\"");
     Assert.AreEqual("Hola", exp.Run());
 }
Esempio n. 19
0
 public void Test_builtins_13()
 {
     var exp = new HypoLambda();
     exp.Compile("__add1__(4)");
     var s = Convert.ToDouble(exp.Run());
     Assert.AreEqual(5.0, s);
 }
Esempio n. 20
0
 public void Test_91()
 {
     var exp = new HypoLambda();
     exp.Compile("\"A\" * 3");
     Assert.AreEqual("AAA", exp.Run());
 }
Esempio n. 21
0
 public void Test_builtins_15()
 {
     var exp = new HypoLambda();
     exp.Compile("add=lambda (a,b): a+b; map(add,[3,4,5],[2,3,4]) == [5,7,9]");
     var s = Convert.ToDouble(exp.Run());
     Assert.AreEqual(1.0, s);
 }
Esempio n. 22
0
 public void Test_92()
 {
     var exp = new HypoLambda();
     exp.Compile("\"A\" + \"B\"");
     Assert.AreEqual("AB", exp.Run());
 }
Esempio n. 23
0
 public void Test_error_40()
 {
     var exp = new HypoLambda();
     var prog = @"
     f = lambda: (
     f()
     );
     f()
     ";
     exp.Compile(prog);
     Assert.Throws<StackOverflowException>(() => Convert.ToDouble(exp.Run()));
 }
Esempio n. 24
0
 public void Test_93()
 {
     var exp = new HypoLambda();
     exp.Compile("  \"Hola \\\"Juan\\\"!\"  ");
     Assert.AreEqual("Hola \"Juan\"!", exp.Run());
 }
Esempio n. 25
0
        public void Test_error_42()
        {
            var error = string.Format(
                            "Division by zero error nearby line {0} position {1}.", 4, 2);

            var exp = new HypoLambda();
            var prog = @"
            v = 3;
            u = 0;
            v/u
            ";
            exp.Compile(prog);
            Convert.ToDouble(exp.Run());
            Assert.AreEqual(error, exp.ErrorMessage);
        }
Esempio n. 26
0
        public void Test_94()
        {
            var ocul = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("es-ES");

            var exp = new HypoLambda();
            exp.Compile(" \"A = {0:##.#}\" % a ");
            exp.Externals["a"] = 100.0 / 3.0;
            var res = exp.Run();

            System.Threading.Thread.CurrentThread.CurrentCulture = ocul;

            Assert.AreEqual("A = 33,3", res);
        }
Esempio n. 27
0
        public void Test_error_44()
        {
            var error = string.Format(
                            "Syntax error nearby line {0} position {1}.", 4, 6);

            var exp = new HypoLambda();
            var prog = @"
            v = 3;
            u = 0;
            v + u;
            ";
            try {
                exp.Compile(prog);
            } catch (ApplicationException ex) {
                Assert.AreEqual(error, ex.Message);
                return;
            }
            Assert.Fail();
        }
Esempio n. 28
0
 public void Test_95()
 {
     var exp = new HypoLambda();
     exp.Compile(" \"Ahora: {0:dd/M/yyyy}\" % now ");
     exp.Externals["now"] = new System.DateTime(2010, 3, 31, 14, 55, 58);
     Assert.AreEqual("Ahora: 31/3/2010", exp.Run());
 }
Esempio n. 29
0
 public void Test_error_46()
 {
     var exp = new HypoLambda();
     Assert.Throws<ApplicationException>(() => exp.Compile("f(3; 2)"));
 }
Esempio n. 30
0
 public void Test_96()
 {
     var exp = new HypoLambda();
     exp.Compile(" ( \"Punto = ({0};{{0}})\" % x ) % y");
     exp.Externals["x"] = 1.0;
     exp.Externals["y"] = 2.0;
     Assert.AreEqual("Punto = (1;2)", exp.Run());
 }