public void Should_Be_Specific_First_Error_Within_ParseErrors_Property() { var assembly = Assembly.GetExecutingAssembly(); var resourceName = "Sylvre.Tests.Core.TestData.quickSort_bad_three_errors.syl"; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) using (StreamReader reader = new StreamReader(stream)) { SylvreProgram result = Parser.ParseSylvreInput(reader.ReadToEnd()); SylvreParseError firstError = (SylvreParseError)result.ParseErrors.ElementAt(0); Assert.IsFalse(firstError.IsMismatchedInput); StringAssert.Contains("create temp num_array", firstError.Message); Assert.AreEqual(32, firstError.Line); Assert.AreEqual(13, firstError.CharPositionInLine); } }
public void Should_Be_Specific_Second_Error_Within_Parse_Exception() { var assembly = Assembly.GetExecutingAssembly(); var resourceName = "Sylvre.Tests.Core.TestData.quickSort_bad_three_errors.syl"; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) using (StreamReader reader = new StreamReader(stream)) { SylvreProgram result = Parser.ParseSylvreInput(reader.ReadToEnd()); SylvreParseError secondError = (SylvreParseError)result.ParseErrors.ElementAt(1); Assert.IsTrue(secondError.IsMismatchedInput); Assert.AreEqual(";", secondError.Symbol); Assert.AreEqual(46, secondError.Line); Assert.AreEqual(17, secondError.CharPositionInLine); } }
public void Should_Be_Specific_Third_Error_Within_Parse_Exception() { var assembly = Assembly.GetExecutingAssembly(); var resourceName = "Sylvre.Tests.Core.TestData.quickSort_bad_three_errors.syl"; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) using (StreamReader reader = new StreamReader(stream)) { SylvreProgram result = Parser.ParseSylvreInput(reader.ReadToEnd()); SylvreParseError thirdError = (SylvreParseError)result.ParseErrors.ElementAt(2); Assert.IsFalse(thirdError.IsMismatchedInput); StringAssert.Contains("quickSort", thirdError.Message); Assert.AreEqual(53, thirdError.Line); Assert.AreEqual(9, thirdError.CharPositionInLine); } }