66using FluentAssertions . Primitives ;
77
88namespace Microsoft . Python . Parsing . Tests {
9+ internal static class ErrorResultExtensions {
10+ public static string Format ( this ErrorResult err ) {
11+ var s = err . Span . Start ;
12+ var e = err . Span . End ;
13+ return $ "new ErrorResult(\" { err . Message } \" , new SourceSpan({ s . Line } , { s . Column } , { e . Line } , { e . Column } ))";
14+ }
15+ }
16+
917 internal static class ErrorResultArrayExtensions {
1018 public static ErrorResultArrayAssertions Should ( this ErrorResult [ ] instance ) {
1119 return new ErrorResultArrayAssertions ( instance ) ;
@@ -23,15 +31,15 @@ public AndConstraint<ErrorResultArrayAssertions> HaveErrors(ErrorResult[] expect
2331 for ( var i = 0 ; i < expected . Length ; i ++ ) {
2432 Execute . Assertion
2533 . ForCondition ( Subject . Length > i )
26- . FailWith ( "No error {0}: {1}" , i , FormatError ( expected [ i ] ) ) ;
34+ . FailWith ( "No error {0}: {1}" , i , expected [ i ] . Format ( ) ) ;
2735
2836 Execute . Assertion
2937 . ForCondition ( Subject [ i ] . Message == expected [ i ] . Message )
30- . FailWith ( "Wrong msg for error {0}: expected {1}, got {2}" , i , FormatError ( expected [ i ] ) , FormatError ( Subject [ i ] ) ) ;
38+ . FailWith ( "Wrong msg for error {0}: expected {1}, got {2}" , i , expected [ i ] . Format ( ) , Subject [ i ] . Format ( ) ) ;
3139
3240 Execute . Assertion
3341 . ForCondition ( Subject [ i ] . Span == expected [ i ] . Span )
34- . FailWith ( "Wrong span for error {0}: expected {1}, got {2}" , i , FormatError ( expected [ i ] ) , FormatError ( Subject [ i ] ) ) ;
42+ . FailWith ( "Wrong span for error {0}: expected {1}, got {2}" , i , expected [ i ] . Format ( ) , Subject [ i ] . Format ( ) ) ;
3543 }
3644
3745 Execute . Assertion
@@ -40,11 +48,5 @@ public AndConstraint<ErrorResultArrayAssertions> HaveErrors(ErrorResult[] expect
4048
4149 return new AndConstraint < ErrorResultArrayAssertions > ( this ) ;
4250 }
43-
44- private string FormatError ( ErrorResult err ) {
45- var s = err . Span . Start ;
46- var e = err . Span . End ;
47- return $ "new ErrorResult(\" { err . Message } \" , new SourceSpan({ s . Line } , { s . Column } , { e . Line } , { e . Column } ))";
48- }
4951 }
5052}
0 commit comments