Skip to content

Commit

Permalink
Add test for multiple unions with same name. (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
domn1995 authored Jul 8, 2022
1 parent c0e0430 commit baa29d2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/GenerateUnionRecord/GenerationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ partial record Error();
}

[Fact]
public void UnionTypeMayHaveNoMembers()
public void UnionMemberTypesMayBeEmpty()
{
// Arrange.
var programCs =
Expand Down
44 changes: 44 additions & 0 deletions test/GenerateUnionRecord/NamespaceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,48 @@ public static void Main()
result.CompilationErrors.Should().BeEmpty();
result.GenerationDiagnostics.Should().BeEmpty();
}

[Fact]
public void CanHaveMultipleUnionsWithSameNameInSeparateNamespaces()
{
// Arrange.
var resultCs =
@"
using Dunet;
namespace Foo;
[Union]
partial record Result
{
partial record Success();
partial record Failure();
}";
var otherResultCs =
@"
using Dunet;
namespace Bar;
[Union]
partial record Result
{
partial record Ok();
partial record Error();
}";
var programCs =
@"
Foo.Result success = new Foo.Result.Success();
Foo.Result failure = new Foo.Result.Failure();
Bar.Result ok = new Bar.Result.Ok();
Bar.Result error = new Bar.Result.Error();
";

// Act.
var result = Compile.ToAssembly(resultCs, otherResultCs, programCs);

// Assert.
result.CompilationErrors.Should().BeEmpty();
result.GenerationDiagnostics.Should().BeEmpty();
}
}

0 comments on commit baa29d2

Please sign in to comment.