Esempio n. 1
0
        public void TestFindFunctionInClass()
        {
            string code = "class MyClass { function foo() { } }";

            LookAheadLangParser textParser = LookAheadLangParser.CreateJavascriptParser(TestUtil.GetTextStream(code));
            var parser = new JSParser(textParser);

            try
            {
                parser.AdvanceToNextFunction();
                Assert.Fail();
            }
            catch (CCCParserSuccessException function)
            {
                Assert.AreEqual("MyClass::foo()", function.Function);
            }
        }
Esempio n. 2
0
        public void TestNextFunctionIsWiredUpAndReturnsName()
        {
            string code = "function Test(segmentA, segmentB) { }";

            LookAheadLangParser textParser = LookAheadLangParser.CreateJavascriptParser(TestUtil.GetTextStream(code));
            var parser = new JSParser(textParser);

            try
            {
                parser.AdvanceToNextFunction();

                Assert.Fail(); // should not get here
            }
            catch (CCCParserSuccessException function)
            {
                Assert.AreEqual("Test(segmentA,segmentB)", function.Function);
            }
        }
Esempio n. 3
0
        public void TestFindsFunctionAfterInterfaceDefinition()
        {
            string code = "interface Thing { member: ();  foo() {} } boo() {}";

            LookAheadLangParser textParser = LookAheadLangParser.CreateJavascriptParser(TestUtil.GetTextStream(code));
            var parser = new JSParser(textParser);

            try
            {
                parser.AdvanceToNextFunction();
                Assert.Fail();
            }
            catch (CCCParserSuccessException function)
            {
                Assert.AreEqual("boo()", function.Function);
            }

            Assert.AreEqual("{", textParser.NextKeyword());
        }
Esempio n. 4
0
        public void TestModulesRecognizedAsContext()
        {
            string code = "module MyNamespace { export class X { grey() {} } }";

            LookAheadLangParser textParser = LookAheadLangParser.CreateJavascriptParser(TestUtil.GetTextStream(code));
            var parser = new JSParser(textParser);

            try
            {
                parser.AdvanceToNextFunction();
                Assert.Fail();
            }
            catch (CCCParserSuccessException function)
            {
                Assert.AreEqual("MyNamespace::X::grey()", function.Function);
            }

            Assert.AreEqual("{", textParser.PeekNextKeyword());
        }
Esempio n. 5
0
        public void TestNestedClassesWithFunctionFindFunction()
        {
            string code = "class MyClass { class MyClass2 { function foo() { } } }";

            LookAheadLangParser textParser = LookAheadLangParser.CreateJavascriptParser(TestUtil.GetTextStream(code));
            var parser = new JSParser(textParser);

            try
            {
                parser.AdvanceToNextFunction();
                Assert.Fail();
            }
            catch (CCCParserSuccessException function)
            {
                Assert.AreEqual("MyClass::MyClass2::foo()", function.Function);
            }

            Assert.AreEqual("{", textParser.PeekNextKeyword());
        }