public void TokenStreamParserThrowsForExceptionInSllForSllOnlyMode() { var errorListenerFactory = DummyErrorListenerFactory(); var llFunction = new Func <IParseTree>(() => null); var sllFunction = new Func <IParseTree>(() => throw new TokenStreamParserTestException()); var tokenStreamParser = new TestTokenStreamParser(errorListenerFactory, errorListenerFactory, llFunction, sllFunction); Assert.Throws <TokenStreamParserTestException>(() => tokenStreamParser.Parse("TestModule", null, CodeKind.CodePaneCode, ParserMode.SllOnly)); }
public void TokenStreamParserThrowsPostponedExceptionAfterFinishingWithoutNonPostponedExceptions(ParserMode parseMode) { var exception = new TokenStreamParserTestException(); var errorListenerFactory = ErrorListenerFactoryWithPostponedException(exception); var llFunction = new Func <IParseTree>(() => null); var sllFunction = new Func <IParseTree>(() => null); var tokenStreamParser = new TestTokenStreamParser(errorListenerFactory, errorListenerFactory, llFunction, sllFunction); Assert.Throws <TokenStreamParserTestException>(() => tokenStreamParser.Parse("TestModule", null, CodeKind.CodePaneCode, ParserMode.FallBackSllToLl)); }
public void TokenStreamParserCallsLlModeIfSllFailsInFallBackMode() { var errorListenerFactory = DummyErrorListenerFactory(); var llCount = 0; var sllCount = 0; var llFunction = new Func <IParseTree>(() => { llCount++; return(null); }); var sllFunction = new Func <IParseTree>(() => { sllCount++; throw new Exception(); }); var tokenStreamParser = new TestTokenStreamParser(errorListenerFactory, errorListenerFactory, llFunction, sllFunction); tokenStreamParser.Parse("TestModule", null, CodeKind.CodePaneCode, ParserMode.FallBackSllToLl); Assert.AreEqual(1, llCount); Assert.AreEqual(1, sllCount); }
public void TokenStreamParserCallsParserModesTheExpectedAmountOfTimesWhenThereIsNoException(ParserMode parseMode, int expectedSllCount, int expectedLlCount) { var errorListenerFactory = DummyErrorListenerFactory(); var llCount = 0; var sllCount = 0; var llFunction = new Func <IParseTree>(() => { llCount++; return(null); }); var sllFunction = new Func <IParseTree>(() => { sllCount++; return(null); }); var tokenStreamParser = new TestTokenStreamParser(errorListenerFactory, errorListenerFactory, llFunction, sllFunction); tokenStreamParser.Parse("TestModule", null, CodeKind.CodePaneCode, parseMode); Assert.AreEqual(expectedLlCount, llCount); Assert.AreEqual(expectedSllCount, sllCount); }