Exemplo n.º 1
0
        public void TestPredefinedFunctions()
        {
            var node   = Parser.Parse(new Lexer(new StringReader("lower(a) < 'a'"), "{test}"));
            var result = SetToString(FreeVars.Get(node, new Interpreter().GetBaseEnvironment()));

            Assert.AreEqual("{a}", result);
        }
Exemplo n.º 2
0
        private void Verify(string free, string script)
        {
            var node                = Parser.Parse(new Lexer(new StringReader(script), "{test}"));
            var freeVars            = new SortedSet <string>();
            var boundVars           = new SortedSet <string>();
            var additionalBoundVars = new SortedSet <string>();

            node.CollectVars(freeVars, boundVars, additionalBoundVars);
            Assert.AreEqual(free, SetToString(FreeVars.Get(node, Environment.GetBaseEnvironment())));
        }
Exemplo n.º 3
0
        public void TestFreeVars()
        {
            var interpreter = new Interpreter();
            var env         = Environment.GetBaseEnvironment();
            var parseTree1  = Parser.Parse(new Lexer(new StringReader("def say_hello = fn(obj) \"Hello \" + obj;"), "{test}"));

            interpreter.Interpret(parseTree1, env);

            var parseTree2 = Parser.Parse(new Lexer(new StringReader("say_hello(\"du\") + unknown_func()"), "{test}"));
            var freeVars   = FreeVars.Get(parseTree2, env);

            Assert.IsTrue(freeVars.Contains("unknown_func"));
            Assert.IsFalse(freeVars.Contains("say_hello"));
        }
Exemplo n.º 4
0
        public int CompareTo(OtpErlangFun other)
        {
            if (other is null)
            {
                return(1);
            }
            int res = Pid.CompareTo(other.Pid);

            if (res == 0)
            {
                res = Module.CompareTo(other.Module);
            }
            if (res == 0)
            {
                res = Arity.CompareTo(other.Arity);
            }
            if (res == 0)
            {
                res = Md5.CompareTo(other.Md5);
            }
            if (res == 0)
            {
                res = Index.CompareTo(other.Index);
            }
            if (res == 0)
            {
                res = OldIndex.CompareTo(other.OldIndex);
            }
            if (res == 0)
            {
                res = Uniq.CompareTo(other.Uniq);
            }
            if (res == 0)
            {
                res = FreeVars.CompareTo(other.FreeVars);
            }
            return(res);
        }