private static IInput GetInputFromString(string source) { var result = PreLexer.Process(source.Split(new[] { Environment.NewLine }, StringSplitOptions.None)); var output = result.Aggregate((x, y) => x + Environment.NewLine + y); return(new Input(output)); }
public void ShouldHandleTextOnTheFirstLine() { var source = @"onlyLine"; var result = PreLexer.Process(SplitUsingNewline(source)).ToArray(); var expectedResult = SplitUsingNewline(@"onlyLine"); CollectionAssert.AreEqual(expectedResult, result); }
public void ShouldFailOnUnterminatedString() { var source = @" line1 ""i'm unterminated"; var result = PreLexer.Process(SplitUsingNewline(source)); var exception = Assert.Throws <ParsingException>(() => result.ToArray()); Assert.AreEqual(ParsingError.SyntaxError, exception.Error); }
public void ShouldFailOnSingleLineMultilineComment() { var source = @" first line /*something*/ second line"; var result = PreLexer.Process(SplitUsingNewline(source)); var exception = Assert.Throws <ParsingException>(() => result.ToArray()); Assert.AreEqual(ParsingError.SyntaxError, exception.Error); }
private static IInput GetInputFromString(string source) { var result = PreLexer.Process(source); if (!result.Any()) { return(new Input(string.Empty)); } var output = result.Aggregate((x, y) => x + Environment.NewLine + y); return(new Input(output)); }
public void ShouldFailIfTheMultilineCommentFinishesBeforeEndOfLine() { var source = @" line1 /* here we begin here it goes here the comment ends*/ x: 5 line2"; var result = PreLexer.Process(SplitUsingNewline(source)); var exception = Assert.Throws <ParsingException>(() => result.ToArray()); Assert.AreEqual(ParsingError.SyntaxError, exception.Error); }
public void ShouldProcessTwoLinesWithNoIndent() { var source = @" line1 line2"; var result = PreLexer.Process(SplitUsingNewline(source)); var expectedResult = SplitUsingNewline(@" line1; line2"); CollectionAssert.AreEquivalent(expectedResult, result); }
public void ShouldProcessDoubleDedentAtTheEndOfFile() { var source = @"first line second line first indented"; var result = PreLexer.Process(SplitUsingNewline(source)); var expectedResult = SplitUsingNewline(@"first line; second line{ first indented}"); CollectionAssert.AreEquivalent(expectedResult, result); }
public void ShouldHandleInitialIndent() { var source = @" first line second line first indented second indented third line"; var result = PreLexer.Process(SplitUsingNewline(source)); var exception = Assert.Throws <ParsingException>(() => result.ToArray()); Assert.AreEqual(ParsingError.WrongIndent, exception.Error); }
public void ShouldProcessBraceInString() { var source = @" line1 ""{ \"" {"" line2"; var result = PreLexer.Process(SplitUsingNewline(source)); var expectedResult = SplitUsingNewline(@" line1 ""{ \"" {""; line2"); CollectionAssert.AreEqual(expectedResult, result); }
public void ShouldHandleMultilineCommentsInOneLine() { var source = @" line1 used as a ruler1234 123456789 1234 line 2/* first comment*/ ""string with /*"" /* second comment */ something"; var result = PreLexer.Process(SplitUsingNewline(source)); var expectedResult = SplitUsingNewline(@" line1 used as a ruler1234 123456789 1234; line 2 ""string with /*"" something"); CollectionAssert.AreEqual(expectedResult, result); }
public void ShouldHandleLineCommentsAndStrings() { var source = @" line1 ""something with //"" ""another // pseudo comment"" { // and here goes real comment line2 }"; var result = PreLexer.Process(SplitUsingNewline(source)); var expectedResult = SplitUsingNewline(@" line1 ""something with //"" ""another // pseudo comment"" { line2 }"); CollectionAssert.AreEqual(expectedResult, result); }
public void ShouldHandleUncorrectLineComments() { var source = @" line1 {// something line2 }"; var result = PreLexer.Process(SplitUsingNewline(source)); var expectedResult = SplitUsingNewline(@" line1 {// something line2 }"); CollectionAssert.AreEqual(expectedResult, result); }
public void ShouldNotProcessIndentInBraces() { var source = @" line1 { line2 }"; var result = PreLexer.Process(SplitUsingNewline(source)); var expectedResult = SplitUsingNewline(@" line1 { line2 }"); CollectionAssert.AreEqual(expectedResult, result); }
public void ShouldHandleEmptyLinesAtTheEndOfSource() { var source = @" line1 line2 "; var result = PreLexer.Process(SplitUsingNewline(source)); var expectedResult = SplitUsingNewline(@" line1; line2 "); CollectionAssert.AreEquivalent(expectedResult, result); }
public void ShouldProcessSimpleFile() { var source = @"first line second line first indented second indented third line"; var result = PreLexer.Process(SplitUsingNewline(source)); var expectedResult = SplitUsingNewline(@"first line; second line{ first indented; second indented}; third line"); CollectionAssert.AreEquivalent(expectedResult, result); }
public void ShouldHandleMultilineCommentsWithinBraces() { var source = @" line1 { /* here we begin here it goes here the comment ends*/ x: 5 } line2"; var result = PreLexer.Process(SplitUsingNewline(source)); var expectedResult = SplitUsingNewline(@" line1 { x: 5 }; line2"); CollectionAssert.AreEqual(expectedResult, result); }
public void ShouldHandleMultilineComments() { var source = @" line1/* here we begin here it goes more more here we finish*/ line2"; var result = PreLexer.Process(SplitUsingNewline(source)); var expectedResult = SplitUsingNewline(@" line1; line2"); CollectionAssert.AreEqual(expectedResult, result); }
public void ShouldProcessEmptyFile() { var result = PreLexer.Process(string.Empty); CollectionAssert.AreEquivalent(string.Empty, result.First()); }
public void ShouldProcessEmptyFile() { var result = PreLexer.Process(new string[0]); CollectionAssert.AreEquivalent(new string[0], result); }