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