123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using Avalonia.Data.Core;
- using Xunit;
- namespace Avalonia.Markup.UnitTests.Parsers
- {
- public partial class BindingExpressionGrammarTests
- {
- [Fact]
- public void Identifier_Cannot_Start_With_Digit()
- {
- Assert.Throws<ExpressionParseException>(
- () => Parse("1Foo"));
- }
- [Fact]
- public void Identifier_Cannot_Start_With_Symbol()
- {
- Assert.Throws<ExpressionParseException>(
- () => Parse("Foo.%Bar"));
- }
- [Fact]
- public void Identifier_Cannot_Start_With_QuestionMark()
- {
- Assert.Throws<ExpressionParseException>(
- () => Parse("?Foo"));
- }
- [Fact]
- public void Identifier_Cannot_Start_With_NullConditional()
- {
- Assert.Throws<ExpressionParseException>(
- () => Parse("?.Foo"));
- }
- [Fact]
- public void Expression_Cannot_End_With_Period()
- {
- Assert.Throws<ExpressionParseException>(
- () => Parse("Foo.Bar."));
- }
-
- [Fact]
- public void Expression_Cannot_End_With_QuestionMark()
- {
- Assert.Throws<ExpressionParseException>(
- () => Parse("Foo.Bar?"));
- }
- [Fact]
- public void Expression_Cannot_End_With_Null_Conditional()
- {
- Assert.Throws<ExpressionParseException>(
- () => Parse("Foo.Bar?."));
- }
- [Fact]
- public void Expression_Cannot_Start_With_Period_Then_Token()
- {
- Assert.Throws<ExpressionParseException>(
- () => Parse(".Bar"));
- }
- [Fact]
- public void Expression_Cannot_Have_Empty_Indexer()
- {
- Assert.Throws<ExpressionParseException>(
- () => Parse("Foo.Bar[]"));
- }
- [Fact]
- public void Expression_Cannot_Have_Extra_Comma_At_Start_Of_Indexer()
- {
- Assert.Throws<ExpressionParseException>(
- () => Parse("Foo.Bar[,3,4]"));
- }
- [Fact]
- public void Expression_Cannot_Have_Extra_Comma_In_Indexer()
- {
- Assert.Throws<ExpressionParseException>(
- () => Parse("Foo.Bar[3,,4]"));
- }
- [Fact]
- public void Expression_Cannot_Have_Extra_Comma_At_End_Of_Indexer()
- {
- Assert.Throws<ExpressionParseException>(
- () => Parse("Foo.Bar[3,4,]"));
- }
- [Fact]
- public void Expression_Cannot_Have_Digit_After_Indexer()
- {
- Assert.Throws<ExpressionParseException>(
- () => Parse("Foo.Bar[3,4]5"));
- }
- [Fact]
- public void Expression_Cannot_Have_Letter_After_Indexer()
- {
- Assert.Throws<ExpressionParseException>(
- () => Parse("Foo.Bar[3,4]A"));
- }
- }
- }
|