示例#1
0
        public void LoopWithRealArithmetic()
        {
            var src = Azos.Conf.LaconicConfiguration.CreateFromString(
                @"
root
{
       i=0
       _loop='$(/$i)<=1.2'
       {
           section_$(/$i) {}
           _set{path=/$i to=$(/$i)+0.2}
       }
}
");
            var result = new Azos.Conf.LaconicConfiguration();

            new ScriptRunner().Execute(src, result);

            var got = result.SaveToString();

            Console.WriteLine(got);

            Aver.AreEqual("section_0", result.Root[0].Name);
            Aver.AreEqual("section_0.2", result.Root[1].Name);
            Aver.AreEqual("section_0.4", result.Root[2].Name);
            Aver.AreEqual("section_0.6", result.Root[3].Name);
            Aver.AreEqual("section_0.8", result.Root[4].Name);
            Aver.AreEqual("section_1", result.Root[5].Name);
            Aver.AreEqual("section_1.2", result.Root[6].Name);
            Aver.IsFalse(result.Root[7].Exists);
        }
示例#2
0
        public void SectionNameWithVar()
        {
            var src = Azos.Conf.LaconicConfiguration.CreateFromString(
                @"
root
{
       i=0
       _loop=$(/$i)<10
       {
           section_$(/$i) {}
           _set{path=/$i to=$(/$i)+1}
       }
}
");
            var result = new Azos.Conf.LaconicConfiguration();

            new ScriptRunner().Execute(src, result);

            var got = result.SaveToString();

            Console.WriteLine(got);

            Aver.AreEqual("section_0", result.Root[0].Name);
            Aver.AreEqual("section_9", result.Root[9].Name);
            Aver.IsFalse(result.Root[10].Exists);
        }
示例#3
0
        public void ExprEval1_TernaryIfWithMixingTypes()
        {
            var src = Azos.Conf.LaconicConfiguration.CreateFromString(
                @"
root
{
   a=12
   b=true

   var1=0{script-only=true}
   var2=175.4{script-only=true}
   var3=true{script-only=true}

   _block
   {
       _set{ path=/var1 to='((?$(/var3);$(/var2);-10)+100)+kozel' }
       RESULT=$(/var1){}
   }
}
");
            var result = new Azos.Conf.LaconicConfiguration();

            new ScriptRunner().Execute(src, result);

            var got = result.SaveToString();

            Console.WriteLine(got);

            Aver.AreEqual("275.4kozel", result.Root["RESULT"].Value);
        }
示例#4
0
        public void ExprEval1_TernaryIf()
        {
            var src = Azos.Conf.LaconicConfiguration.CreateFromString(
                @"
root
{
   a=12
   b=true

   var1=0{script-only=true}
   var2=175.4{script-only=true}
   var3=true{script-only=true}

   _block
   {
       _set{ path=/var1 to=(?$(/var2)>10;15;-10)+100 }
       RESULT=$(/var1){}
   }
}
");
            var result = new Azos.Conf.LaconicConfiguration();

            new ScriptRunner().Execute(src, result);

            var got = result.SaveToString();

            got.See();

            Aver.AreEqual(115, result.Root["RESULT"].ValueAsInt());
        }
示例#5
0
        public void RSchema()
        {
            var src    = Azos.Conf.LaconicConfiguration.CreateFromString(rschema);
            var result = new Azos.Conf.LaconicConfiguration();

            new ScriptRunner().Execute(src, result);

            var got = result.SaveToString();

            Console.WriteLine(got);
            Aver.AreEqual(rschemaExpected, got);
        }
示例#6
0
        public void VarsLoopIfElseCall()
        {
            var src    = Azos.Conf.LaconicConfiguration.CreateFromString(src1);
            var result = new Azos.Conf.LaconicConfiguration();

            new ScriptRunner().Execute(src, result);

            var got = result.SaveToString();

            Console.WriteLine(got);
            Aver.AreEqual(expected1, got);
        }
示例#7
0
        public void RSchema()
        {
            var src    = Azos.Conf.LaconicConfiguration.CreateFromString(rschema);
            var result = new Azos.Conf.LaconicConfiguration();

            new ScriptRunner().Execute(src, result);

            var got = result.SaveToString();

            got.See();
            Aver.AreEqual(rschemaExpected.ToWindowsLines(), got.ToWindowsLines());
        }
示例#8
0
        public void VarsLoopIfElseCall()
        {
            var src    = Azos.Conf.LaconicConfiguration.CreateFromString(src1);
            var result = new Azos.Conf.LaconicConfiguration();

            new ScriptRunner().Execute(src, result);

            var got = result.SaveToString();

            got.See();
            Aver.AreEqual(expected1.ToWindowsLines(), got.ToWindowsLines());
        }