示例#1
0
        public void StringPlain()
        {
            var s   = new StringValue("hi");
            var mys = s.Evaluate(new RootContext());

            Assert.AreEqual("hi", mys, "Plain string value");
        }
示例#2
0
        public void StringWithVarNoTrans()
        {
            var s   = new StringValue("hi {there}");
            var mys = s.Evaluate(new RootContext());

            Assert.AreEqual("hi {there}", mys, "string value");
        }
示例#3
0
        public void StringWithBadExpr()
        {
            var s   = new StringValue("hi {1+}");
            var c   = new RootContext();
            var mys = s.Evaluate(c);

            Assert.AreEqual("hi {1+}", mys);
        }
示例#4
0
        public void StringWith1CharVar()
        {
            var s = new StringValue("hi {t}");
            var c = new RootContext();

            c.SetVariableValue("t", "dude");
            var mys = s.Evaluate(c);

            Assert.AreEqual("hi dude", mys, "string value");
        }
示例#5
0
        public void StringWithOpenBAndValue()
        {
            var s = new StringValue("hi{there");
            var c = new RootContext();

            c.SetVariableValue("there", "dude");
            var mys = s.Evaluate(c);

            Assert.AreEqual("hi{there", mys, "string value");
        }
示例#6
0
        public void StringWith2VarNextToEachOtherOneNoTrans()
        {
            var s = new StringValue("hi {there}{t}");
            var c = new RootContext();

            c.SetVariableValue("t", "dude");
            var mys = s.Evaluate(c);

            Assert.AreEqual("hi {there}dude", mys, "string value");
        }
示例#7
0
        public void StringWithDictReference()
        {
            var allvals = new Tuple <IExpression, IExpression>[] {
                new Tuple <IExpression, IExpression>(new StringValue("hi"), new StringValue("there")),
                new Tuple <IExpression, IExpression>(new StringValue("no"), new StringValue("way")),
            };
            var d = new Dictionary <object, object>();

            d["hi"] = "there";
            d["no"] = "way";
            var c = new RootContext();

            //c.SetVariableValue("dict", new DictionaryValue(allvals));
            c.SetVariableValue("dict", d);
            var s   = new StringValue("hi {dict[\"hi\"]} on my {dict[\"no\"]}.");
            var mys = s.Evaluate(c);

            Assert.AreEqual("hi there on my way.", mys);
        }
        static public object GetMeWithIndex2(StringValue expr)
        {
            var r = new RootContext();

            return(expr.Evaluate(r));
        }