コード例 #1
0
        private static IEnumerable <object[]> GetLiteralExpressionData()
        {
            // simple types
            yield return(CreateRow("null", TestSyntaxFactory.CreateNull()));

            yield return(CreateRow("true", TestSyntaxFactory.CreateBool(true)));

            yield return(CreateRow("false", TestSyntaxFactory.CreateBool(false)));

            yield return(CreateRow("string", TestSyntaxFactory.CreateString("hello")));

            yield return(CreateRow("int", TestSyntaxFactory.CreateInt(42)));

            yield return(CreateRow("negative int", TestSyntaxFactory.CreateUnaryMinus(TestSyntaxFactory.CreateInt(42))));

            yield return(CreateRow("empty object", TestSyntaxFactory.CreateObject(new ObjectPropertySyntax[0])));

            yield return(CreateRow("object literal", TestSyntaxFactory.CreateObject(new[]
            {
                TestSyntaxFactory.CreateProperty("one", TestSyntaxFactory.CreateNull()),
                TestSyntaxFactory.CreateProperty("two", TestSyntaxFactory.CreateBool(true)),
                TestSyntaxFactory.CreateProperty("three", TestSyntaxFactory.CreateBool(false)),
                TestSyntaxFactory.CreateProperty("four", TestSyntaxFactory.CreateString("hello")),
                TestSyntaxFactory.CreateProperty("five", TestSyntaxFactory.CreateInt(42)),
                TestSyntaxFactory.CreateProperty("six", TestSyntaxFactory.CreateObject(new []
                {
                    TestSyntaxFactory.CreateProperty("one", TestSyntaxFactory.CreateNull()),
                    TestSyntaxFactory.CreateProperty("two", TestSyntaxFactory.CreateBool(true)),
                    TestSyntaxFactory.CreateProperty("three", TestSyntaxFactory.CreateBool(false)),
                    TestSyntaxFactory.CreateProperty("four", TestSyntaxFactory.CreateString("test")),
                    TestSyntaxFactory.CreateProperty("five", TestSyntaxFactory.CreateInt(100)),
                    TestSyntaxFactory.CreateProperty("six", TestSyntaxFactory.CreateArray(new SyntaxBase[]
                    {
                        TestSyntaxFactory.CreateNull(),
                        TestSyntaxFactory.CreateBool(true),
                        TestSyntaxFactory.CreateBool(false),
                        TestSyntaxFactory.CreateString("other"),
                        TestSyntaxFactory.CreateInt(103)
                    }))
                }))
            })));

            yield return(CreateRow("empty array", TestSyntaxFactory.CreateArray(new ArrayItemSyntax[0])));

            yield return(CreateRow("array literal", TestSyntaxFactory.CreateArray(new SyntaxBase[]
            {
                TestSyntaxFactory.CreateNull(),
                TestSyntaxFactory.CreateBool(true),
                TestSyntaxFactory.CreateBool(false),
                TestSyntaxFactory.CreateString("other"),
                TestSyntaxFactory.CreateInt(103),
                TestSyntaxFactory.CreateObject(new[]
                {
                    TestSyntaxFactory.CreateProperty("one", TestSyntaxFactory.CreateNull()),
                    TestSyntaxFactory.CreateProperty("two", TestSyntaxFactory.CreateBool(true)),
                    TestSyntaxFactory.CreateProperty("three", TestSyntaxFactory.CreateBool(false)),
                    TestSyntaxFactory.CreateProperty("four", TestSyntaxFactory.CreateString("test")),
                    TestSyntaxFactory.CreateProperty("five", TestSyntaxFactory.CreateInt(100)),
                    TestSyntaxFactory.CreateProperty("six", TestSyntaxFactory.CreateArray(new SyntaxBase[]
                    {
                        TestSyntaxFactory.CreateNull(),
                        TestSyntaxFactory.CreateBool(true),
                        TestSyntaxFactory.CreateBool(false),
                        TestSyntaxFactory.CreateString("other"),
                        TestSyntaxFactory.CreateInt(103)
                    }))
                }),
                TestSyntaxFactory.CreateArray(new SyntaxBase[]
                {
                    TestSyntaxFactory.CreateNull(),
                    TestSyntaxFactory.CreateBool(true),
                    TestSyntaxFactory.CreateBool(false),
                    TestSyntaxFactory.CreateString("other"),
                    TestSyntaxFactory.CreateInt(103)
                })
            })));
        }