public void TestExpressionParser(string expression, IExpressionSyntax?expected = null) { if (expected is null) { SyntaxAssert.ExpressionThrowsException(expression); } else { var actual = JassPidginParser.ParseExpression(expression); SyntaxAssert.AreEqual(expected, actual); } }
public static void ExpressionThrowsException(string expression) { var message = new BoxedString(); Assert.ThrowsException <ParseException>(() => message.String = GetExpressionDisplayString(JassPidginParser.ParseExpression(expression)), "\r\n{0}", message); }
public static void ExpressionThrowsException(string expression, bool useTokenParser) { var message = new BoxedString(); if (useTokenParser) { try { message.String = GetSyntaxDisplayString(JassPidginTokenParser.ParseExpression(expression)); } catch (Exception e) when(e is not ParseException && e is not InvalidDataException) // InvalidDataException is thrown by tokenizer. { Assert.Fail("\r\n{0}", message); } catch { } } else { Assert.ThrowsException <ParseException>(() => message.String = GetSyntaxDisplayString(JassPidginParser.ParseExpression(expression)), "\r\n{0}", message); } }