示例#1
0
 public void TestExpressionTokenParser(string expression, IExpressionSyntax?expected = null)
 {
     if (expected is null)
     {
         SyntaxAssert.ExpressionThrowsException(expression, true);
     }
     else
     {
         var actual = JassPidginTokenParser.ParseExpression(expression);
         SyntaxAssert.AreEqual(expected, actual);
     }
 }
示例#2
0
        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);
            }
        }