Esempio n. 1
0
        public void ArrayIndexedFunctionCall01()
        {
            string content = @"first[3][-2.3].second[4][5][6].foo(12, false);";

            Parser parser = CreateParserFromText(content);

            parser.Parse();

            FunctionCallPart root = parser.RootFunctionCallPart;

            Assert.AreEqual("first[3][-2.3].second[4][5][6].foo", root.Identifier);

            // Before the first open bracket.
            FunctionCallPart intersection = root.GetIntersectionPart(34, 0);

            Assert.AreEqual(null, intersection);

            // After the first open bracket.
            intersection = root.GetIntersectionPart(35, 0);
            Assert.AreNotEqual(null, intersection);
            Assert.AreEqual(root, intersection.ParentPart);
            Assert.AreEqual(0, root.GetArgumentIndex(intersection));

            // Right before the comma.
            intersection = root.GetIntersectionPart(37, 0);
            Assert.AreNotEqual(null, intersection);
            Assert.AreEqual(root, intersection.ParentPart);
            Assert.AreEqual(0, root.GetArgumentIndex(intersection));

            // Right after the comma.
            intersection = root.GetIntersectionPart(38, 0);
            Assert.AreNotEqual(null, intersection);
            Assert.AreEqual(root, intersection.ParentPart);
            Assert.AreEqual(1, root.GetArgumentIndex(intersection));

            // Right before the closing bracket.
            intersection = root.GetIntersectionPart(44, 0);
            Assert.AreNotEqual(null, intersection);
            Assert.AreEqual(root, intersection.ParentPart);
            Assert.AreEqual(1, root.GetArgumentIndex(intersection));

            // After the closing bracket.
            intersection = root.GetIntersectionPart(46, 0);
            Assert.AreEqual(null, intersection);
        }