Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit 3b14020

Browse files
brianbokjakebailey
authored andcommitted
Delete error info and unused index numbers from parser tests (#895)
* Adding test * Fixed tests * Delete error info * cleanup * Delete using * Only one FormatError method
1 parent 435108d commit 3b14020

2 files changed

Lines changed: 787 additions & 819 deletions

File tree

src/Parsing/Test/ErrorAssertions.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
using FluentAssertions.Primitives;
77

88
namespace 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

Comments
 (0)