Exemplo 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);
            }
        }
Exemplo 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);
            }
        }
Exemplo 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());
        }
Exemplo 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());
        }
Exemplo 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());
        }