Skip to content

Commit

Permalink
Include paths in test
Browse files Browse the repository at this point in the history
  • Loading branch information
FiniteReality committed May 13, 2023
1 parent 6047038 commit 1750816
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/Compiler/SyntaxTreeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public override IEnumerable<object[]> GetData(MethodInfo testMethod)
foreach (var path in Directory.EnumerateFiles(
_path, "*.dm", SearchOption.AllDirectories))
{
yield return new[] { File.ReadAllText(path) };
yield return new[] { path, File.ReadAllText(path) };
}
}
}
Expand All @@ -31,20 +31,25 @@ public sealed class SyntaxTreeTests
/// <summary>
/// Ensures that a given source code can be parsed without error.
/// </summary>
/// <param name="path">
/// The path of the source code.
/// </param>
/// <param name="source">
/// The source code to parse.
/// </param>
[Theory]
[SyntaxTreeTestData("TestSyntax/ValidCode")]
public async Task SourceCodeCanBeParsedAsync(string source)
public async Task SourceCodeCanBeParsedAsync(string path, string source)
{
Assert.NotEmpty(source);

// Parsing code should not take longer than 3 seconds; if it does there
// is likely a bug in the parser or lexer.
using var token = new CancellationTokenSource(
TimeSpan.FromSeconds(3));
var tree = await SyntaxTree.ParseAsync(source,
var tree = await SyntaxTree.ParseAsync(
text: source,
path: path,
cancellationToken: token.Token);

Assert.NotNull(tree);
Expand Down

0 comments on commit 1750816

Please sign in to comment.