File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 3
3
using jsonparser . JsonModel ;
4
4
using NFluent ;
5
5
using sly . lexer ;
6
+ using sly . lexer . fluent ;
6
7
using sly . parser ;
7
8
using sly . parser . generator ;
8
9
using Xunit ;
9
10
10
11
namespace ParserTests
11
12
{
13
+
14
+ [ Lexer ( KeyWordIgnoreCase = true ) ]
15
+ public enum ContextualToken
16
+ {
17
+ A ,
18
+ B ,
19
+ C
20
+ }
21
+
12
22
public class ErrorTests
13
23
{
14
24
[ Fact ]
@@ -154,13 +164,21 @@ public void TestContextualError()
154
164
Check . That ( parsed . Errors ) . CountIs ( 1 ) ;
155
165
var error = parsed . Errors [ 0 ] ;
156
166
var message = error . ContextualErrorMessage ;
167
+ var lines = message . GetLines ( ) ;
168
+ Check . That ( lines ) . CountIs ( 4 ) ;
169
+ Check . That ( lines [ 2 ] ) . Contains ( "1 |a c b" ) ;
170
+ Check . That ( lines [ 3 ] ) . Contains ( " | ^^^ expected B" ) ;
157
171
158
172
source = "a , c b" ;
159
173
parsed = build . Result . Parse ( source ) ;
160
174
Check . That ( parsed ) . Not . IsOkParsing ( ) ;
161
175
Check . That ( parsed . Errors ) . CountIs ( 1 ) ;
162
176
error = parsed . Errors [ 0 ] ;
163
177
message = error . ContextualErrorMessage ;
178
+ lines = message . GetLines ( ) ;
179
+ Check . That ( lines ) . CountIs ( 4 ) ;
180
+ Check . That ( lines [ 2 ] ) . Contains ( "0 |a , c b" ) ;
181
+ Check . That ( lines [ 3 ] ) . Contains ( " | ^^^ unexpected char ','" ) ;
164
182
165
183
166
184
You can’t perform that action at this time.
0 commit comments