示例#1
0
        public void DefTest1()
        {
            UVars target = new UVars();

            Assert.Empty(target.Definitions);
            Assert.Empty(target.Variables);
        }
示例#2
0
        public void IsExistTest3()
        {
            UVars target = new UVars();

            target.SetVariable("name", "project", "val");
            Assert.True(target.IsExist("name", "project"));
        }
示例#3
0
        public void GetTest1()
        {
            UVars target = new UVars();

            Assert.Null(target.GetValue("name"));
            Assert.Null(target.GetValue("name", "project"));
        }
示例#4
0
        public void GetTest3()
        {
            UVars target = new UVars();

            target.SetVariable("name", null, "val");
            Assert.Equal(string.Empty, target.GetValue("name"));
        }
示例#5
0
        public void CatchTest5()
        {
            var uvar   = new UVars();
            var target = SobaAcs.MakeWithTryComponent(uvar);

            Assert.Empty(uvar.Variables);
            target.Eval(@"
                            #[try
                            { 
                                #[notrealcomponentToError]
     
                                #[( true ){
                                    $(test1 = '123')
                                }]
                            }
                            catch
                            {
                                #[( true ){
                                    $(test2 = '456')
                                }]
                            }] 
                        ");

            Assert.Single(uvar.Variables);
            Assert.Null(uvar.GetValue("test1", null));
            Assert.Equal("456", uvar.GetValue("test2", null));
        }
示例#6
0
        public void IsUnevaluatedTest2()
        {
            UVars target = new UVars();

            target.SetVariable("name", null, "val");

            Assert.True(target.IsUnevaluated("name"));
        }
示例#7
0
 public override string GetPropValue(string name, string project)
 {
     if (UVars.IsExist(name, project))
     {
         return(GetUVarValue(name, project));
     }
     return($"[P~{name}~{project}]");
 }
示例#8
0
        public void IsUnevaluatedTest3()
        {
            var target = new UVars();

            target.SetVariable("name", "project", "val");

            Assert.True(target.IsUnevaluated("name", "project"));
        }
示例#9
0
        public void SetTest5()
        {
            var target = new UVars();

            Assert.Throws <ArgumentException>(() => {
                target.SetVariable("na%me", "project", "unevaluated");
            });
        }
示例#10
0
        public void StDataTest9()
        {
            var uvar   = new UVars();
            var target = SobaAcs.MakeWithBoxComponent(uvar);

            Assert.Equal(string.Empty, target.Eval("#[Box data.free(\"test1\")]"));
            Assert.Equal(string.Empty, target.Eval("#[Box data.free(\"test2\")]"));
        }
示例#11
0
        public void UnsetAllTest1()
        {
            UVars target = new UVars();

            target.SetVariable("name", null, "unevaluated");
            target.UnsetAll();
            Assert.Empty(target.Variables);
        }
示例#12
0
        public void ContainerTest1()
        {
            var uvar   = new UVars();
            var target = SobaAcs.MakeNewCoreOnly(uvar);

            Assert.Equal("ne]", target.Eval("#[var name = value\nli]ne]"));
            Assert.Single(uvar.Variables);
            Assert.Equal("value\nli", uvar.GetValue("name"));
        }
示例#13
0
        public void ContainerTest2()
        {
            var uvar   = new UVars();
            var target = SobaAcs.MakeNewCoreOnly(uvar);

            Assert.Equal(string.Empty, target.Eval("#[var name = <#data>value\nli]ne</#data>]"));
            Assert.Single(uvar.Variables);
            Assert.Equal("value\nli]ne", uvar.GetValue("name"));
        }
示例#14
0
        public void ParseMSBuildUnloopingTest3()
        {
            var uvar    = new UVars();
            var msbuild = new EvMSBuilder(uvar);
            var sbe     = SobaAcs.MakeNewCoreOnly(uvar);

            msbuild.Eval(sbe.Eval("#[var p2 = $$(p1)]#[var p6 = $$(p2)]#[var p7 = $$(p5)]#[var p5 = $(p6)]", true));
            // shouldn't throw LimitException, ie. no problems for stack & heap
        }
示例#15
0
        public void ContainerTest6()
        {
            var uvar   = new UVars();
            var target = SobaAcs.MakeNewCoreOnly(uvar);

            Assert.Equal(string.Empty, target.Eval("#[var name = left [box1] right]"));
            Assert.Single(uvar.Variables);
            Assert.Equal("left [box1] right", uvar.GetValue("name"));
        }
示例#16
0
        public void StDataTest6()
        {
            var uvar   = new UVars();
            var target = SobaAcs.MakeWithBoxComponent(uvar);

            Assert.Throws <NotFoundException>(() =>
                                              target.Eval("#[Box data.clone(\"notexists\", 4)]")
                                              );
        }
示例#17
0
        public void StDataTest8()
        {
            var uvar   = new UVars();
            var target = SobaAcs.MakeWithBoxComponent(uvar);

            Assert.Throws <NotSupportedOperationException>(() =>
                                                           target.Eval("#[Box data.free(\"test1\"): 123]")
                                                           );
        }
示例#18
0
        public void ParseTest1()
        {
            var uvar   = new UVars();
            var target = new TryComponent(SobaAcs.MakeWithTryComponent(uvar));

            Assert.Equal(Value.Empty, target.Eval("[try{}catch{ if error }]"));
            Assert.Equal(Value.Empty, target.Eval("[try{}catch(err, msg){ if error }]"));
            Assert.Equal(Value.Empty, target.Eval("[try{}catch(){ }]"));
            Assert.Empty(uvar.Variables);
        }
示例#19
0
        public void EvaluateTest3()
        {
            UVars  target  = new UVars();
            string name    = "name";
            string project = "project";

            target.SetVariable(name, project, "val");
            target.Evaluate(name, project, new Evaluator1(), true);
            Assert.Equal("[E1:val]", target.GetValue(name, project));
        }
示例#20
0
        public void CatchTest1()
        {
            var uvar   = new UVars();
            var target = SobaAcs.MakeWithTryComponent(uvar);

            target.Eval("#[try{ $(test = '123') }catch{ $(test2 = '456') }]");

            Assert.Single(uvar.Variables);
            Assert.Equal("123", uvar.GetValue("test", null));
        }
示例#21
0
        public void ParseMSBuildUnloopingTest2()
        {
            var uvar    = new UVars();
            var msbuild = new EvMSBuilder(uvar);
            var sbe     = SobaAcs.MakeNewCoreOnly(uvar);

            Assert.Throws <net.r_eg.Varhead.Exceptions.LimitException>(() =>
                                                                       msbuild.Eval(sbe.Eval("#[var p1 = $$(p4)]#[var p2 = $$(p3)]#[var p3 = $$(p1)]#[var p4 = $(p2)]", true))
                                                                       );
        }
示例#22
0
        public void ParseMSBuildUnloopingTest4()
        {
            var uvar    = new UVars();
            var msbuild = new EvMSBuilder(uvar);
            var sbe     = SobaAcs.MakeNewCoreOnly(uvar);

            Assert.Throws <net.r_eg.Varhead.Exceptions.LimitException>(() =>
                                                                       msbuild.Eval(sbe.Eval("#[var p2 = $$(p1) to $$(p8), and new ($$(p7.Replace('1', '2'))) s$$(p9)]#[var p6 = $$(p2)]#[var p7 = $$(p5)]#[var p5 = $(p6)]", true))
                                                                       );
        }
        private Bootloader(IEnvironment env)
        {
            Env = env ?? throw new ArgumentNullException(nameof(env));

            UVars = new UVars();

            Soba = Configure(
                new Soba(MSBuild.MakeEvaluator(env, UVars), UVars)
                );
        }
示例#24
0
        public void ContainerTest9()
        {
            var uvar   = new UVars();
            var target = SobaAcs.MakeNewCoreOnly(uvar);

            Assert.Equal("test - cc", target.Eval("#[var sres = <#data>Data1\n\nEnd</#data>]test - cc#[var sres2 = <#data>Data2\n\nEnd</#data>]"));
            Assert.Equal(2, uvar.Variables.Count());
            Assert.Equal("Data1\n\nEnd", uvar.GetValue("sres"));
            Assert.Equal("Data2\n\nEnd", uvar.GetValue("sres2"));
        }
示例#25
0
        public void VtSignTest2()
        {
            var uvar   = new UVars();
            var target = new EvMSBuilder(new EnvStub(), uvar);

            Assert.Equal(string.Empty, target.Eval("$(i = 0)"));
            Assert.Equal(string.Empty, target.Eval("$(i += 1)"));
            Assert.Equal(string.Empty, target.Eval("$(i += 2)$(i += 1)"));
            Assert.Equal(string.Empty, target.Eval("$(i -= 2)"));
            Assert.Equal("2", uvar.GetValue("i"));
        }
示例#26
0
        public void StDataTest2()
        {
            var uvar   = new UVars();
            var target = SobaAcs.MakeWithBoxComponent(uvar);

            target.Eval("#[Box data.pack(\"test1\", false): 123]");

            Assert.Throws <LimitException>(() =>
                                           target.Eval("#[Box data.pack(\"test1\", true): 123]")
                                           );
        }
示例#27
0
        public void VtSignTest3()
        {
            var uvar   = new UVars();
            var target = new EvMSBuilder(new EnvStub(), uvar);

            Assert.Equal(string.Empty, target.Eval("$(i += 1)"));
            Assert.Equal("1", uvar.GetValue("i"));

            Assert.Equal(string.Empty, target.Eval("$(j -= 1)"));
            Assert.Equal("-1", uvar.GetValue("j"));
        }
示例#28
0
        public void StDataTest7()
        {
            var uvar   = new UVars();
            var target = SobaAcs.MakeWithBoxComponent(uvar);

            Assert.Equal(string.Empty, target.Eval("#[Box data.pack(\"test1\", false): 123 ]"));
            Assert.Equal(string.Empty, target.Eval("#[Box data.free(\"test1\")]"));

            Assert.Throws <NotFoundException>(() =>
                                              target.Eval("#[Box data.get(\"test1\", false)]")
                                              );
        }
示例#29
0
        public void EvaluateTest2()
        {
            UVars  target  = new UVars();
            string name    = "name";
            string project = "project";

            Assert.Throws <ArgumentNullException>(() =>
            {
                target.SetVariable(name, project, "val");
                target.Evaluate(name, project, null, true);
            });
        }
示例#30
0
        public void EvaluateTest1()
        {
            UVars target = new UVars();

            Assert.Throws <DefinitionNotFoundException>(() => {
                target.Evaluate("name", "project", new Evaluator1(), true);
            });

            Assert.Throws <DefinitionNotFoundException>(() => {
                target.Evaluate("name", new Evaluator1(), true);
            });
        }