Ejemplo n.º 1
0
        public void parser_should_understand_simple_double_value1()
        {
            var script1 = @" 4324234.66 ";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                "4324234.66",
                result.ToJson());
        }
Ejemplo n.º 2
0
        public void parser_should_understand_inner_object_and_arrays5()
        {
            var script1 = @"[{d:[{a:['gg']}]},9,1]";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                script1,
                result.ToJson());
        }
Ejemplo n.º 3
0
        public void parser_should_understand_inner_object_and_arrays4()
        {
            var script1 = @"{d:[{@f:6}],c:'aaa',d:[{a:['gg']}],e:'b'}";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                script1,
                result.ToJson());
        }
Ejemplo n.º 4
0
        public void parser_should_understand_inner_object()
        {
            var script1 = @"{a : 'cos', d : { a : 1, b : 2, c : 'abc'}, c: 'aaa' }";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                @"{a:'cos',d:{a:1,b:2,c:'abc'},c:'aaa'}",
                result.ToJson());
        }
Ejemplo n.º 5
0
        public void parser_should_understand_invalid_object_version2()
        {
            var script1 = @" { ""a"" , ""b""  } ";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                @"{""a"",""b""}",
                result.ToJson());
        }
Ejemplo n.º 6
0
        public void parser_should_understand_root_name_and_few_parameters()
        {
            var script1 = @" a( p, c : int, b : string ) { 1 } ";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                "a(p,c:int,b:string){1}",
                result.ToJson());
        }
Ejemplo n.º 7
0
        public void parser_should_ignore_comment_in_comment()
        {
            var script1 = @" 4324234.66 /* abc /* abc */ abc */ ";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                "4324234.66",
                result.ToJson());
        }
Ejemplo n.º 8
0
        public void parser_should_understand_simple_sql_function_wth_getdate()
        {
            var script1 = @"{ b : sql( select getdate())   }";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                @"{b:sql(select getdate())}",
                result.ToJson());
        }
Ejemplo n.º 9
0
        public void parser_should_ignore_comment_inside_table()
        {
            var script1 = @"[1 , 2 , /* /* abc */ */ 3 , 'abc' ]";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                @"[1,2,3,'abc']",
                result.ToJson());
        }
Ejemplo n.º 10
0
        public void parser_should_understand_simple_json_array_test1()
        {
            var script1 = @"[1 , 2 , 3 , 'abc' ]";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                @"[1,2,3,'abc']",
                result.ToJson());
        }
Ejemplo n.º 11
0
        public void parser_should_understand_root_name()
        {
            var script1 = @" a( p ) { 1 } ";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                "a(p){1}",
                result.ToJson());
        }
Ejemplo n.º 12
0
        public void parser_should_understand_simple_json_object_test2()
        {
            var script1 = @"{a : 'cos', sql( select 1 as val ), c: 'aaa' }";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                @"{a:'cos',sql(select 1 as val),c:'aaa'}",
                result.ToJson());
        }
Ejemplo n.º 13
0
        public void parser_should_understand_simple_function_with_outer_comments()
        {
            var script1 = @"{ b : /*sql( select 1 /* abc */ )*/   }";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                @"{b:}",
                result.ToJson());
        }
Ejemplo n.º 14
0
        public void parser_should_understand_function_with_quotation1_inside_quotation2()
        {
            var script1 = @"{ b : sql(select abc(""d'ff'ef""))   }";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                @"{b:sql(select abc(""d'ff'ef""))}",
                result.ToJson());
        }
Ejemplo n.º 15
0
        public void parser_should_ignore_comment_inside_object()
        {
            var script1 = @"{a : 'cos', /* abc*/  sql( select 1 as val ), c: 'aaa' }";

            var result = new S4JParserForTests().
                         Parse(script1);

            var txt = result.ToJson();

            Assert.AreEqual(
                @"{a:'cos',sql(select 1 as val),c:'aaa'}",
                result.ToJson());
        }
Ejemplo n.º 16
0
        public void parser_should_understand_simple_string_value1()
        {
            var script1 = @" 'ab c ' ";

            var result = new S4JParserForTests().
                         Parse(script1);

            var txt = result.ToJson();

            Assert.AreEqual(
                "'ab c '",
                result.ToJson());
        }
Ejemplo n.º 17
0
        public void parser_should_understand_quotation_with_sql_function()
        {
            var script1 = @"{ b : "" sql( select getdate()   )  "" }";

            var result = new S4JParserForTests().
                         Parse(script1);

            var txt = result.ToJson();

            Assert.AreEqual(
                @"{b:"" sql( select getdate()   )  ""}",
                result.ToJson());
        }
Ejemplo n.º 18
0
        public void parser_should_understand_simple_object()
        {
            var script1 = @" {  a: 1, b: 2, c: 3 } ";

            var result = new S4JParserForTests().
                         Parse(script1);

            var txt = result.ToJson();

            Assert.AreEqual(
                "{a:1,b:2,c:3}",
                result.ToJson());
        }
Ejemplo n.º 19
0
        async public Task test_simple_value_tag()
        {
            var script1 = @" 
#permission:admin
method ( a : int, b : string!, c: any ) 
'ok'
";

            var result = new S4JParserForTests().
                         Parse(script1) as S4JTokenRoot;

            Assert.AreEqual(1, result.Tags.Count);

            Assert.AreEqual("admin", result.Tags["permission"]);
        }
Ejemplo n.º 20
0
        public void parser_should_ignore_root_tags()
        {
            var script1 = @"
#tag1 #tag2
{  
    d: [ {@f : 6} ] , 
    c: 'aaa' }
";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                @"{d:[{@f:6}],c:'aaa'}",
                result.ToJson());
        }
Ejemplo n.º 21
0
        public void parser_should_ignore_inner_tags()
        {
            var script1 = @"
{  
    #permission:admin
    d: [ {@f : 6} ] , 
    c: 'aaa' 
}
";

            var result = new S4JParserForTests().
                         Parse(script1);

            Assert.AreEqual(
                @"{d:[{@f:6}],c:'aaa'}",
                result.ToJson());
        }
Ejemplo n.º 22
0
        async public Task test_simple_inner_tag()
        {
            var script1 = @" 
{
    a : 1, 
    #tagb
    b : 2,
    c: 3
}
";

            var result = new S4JParserForTests().
                         Parse(script1) as S4JTokenRoot;

            Assert.AreEqual(1, result[0][2].Tags.Count);

            Assert.AreEqual("tagb", result[0][2].Tags.Keys.FirstOrDefault());
        }
Ejemplo n.º 23
0
        async public Task test_simple_inner_tag3()
        {
            var script1 = @" 
{
    a : 1, 
    b : 2,
    c: 3,
    #tagb
}
";

            var result = new S4JParserForTests().
                         Parse(script1) as S4JTokenRoot;

            Assert.AreEqual(6, result[0].Children.Count);

            Assert.AreEqual("{a:1,b:2,c:3}", result.ToJson());
        }
Ejemplo n.º 24
0
        async public Task test_simple_tags_with_nospaces()
        {
            var script1 = @" 
(#post)(#get)
method ( a : int, b : string!, c: any ) 
'ok'
";

            var result = new S4JParserForTests().
                         Parse(script1) as S4JTokenRoot;

            Assert.AreEqual(2, result.Tags.Count);

            if (!result.Tags.ContainsKey("post"))
            {
                throw new Exception("Tag 'post' is missing");
            }

            if (!result.Tags.ContainsKey("get"))
            {
                throw new Exception("Tag 'get' is missing");
            }
        }