Skip to content

Commit

Permalink
Laws tests
Browse files Browse the repository at this point in the history
  • Loading branch information
louthy committed Oct 16, 2024
1 parent bf0f5e2 commit c3e7591
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 1 deletion.
20 changes: 20 additions & 0 deletions LanguageExt.Tests/TraitTests/ApplicativeLawTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@ namespace LanguageExt.Tests.TraitTests;

public class ApplicativeFunctorLawTests
{
[Fact]
public void Arr() =>
ApplicativeLaw<Arr>.assert();

[Fact]
public void HashSet() =>
ApplicativeLaw<HashSet>.assert();

[Fact]
public void Iterable() =>
ApplicativeLaw<Iterable>.assert();

[Fact]
public void Lst() =>
ApplicativeLaw<Lst>.assert();

[Fact]
public void Seq() =>
ApplicativeLaw<Seq>.assert();

[Fact]
public void EffRT()
{
Expand Down
51 changes: 50 additions & 1 deletion LanguageExt.Tests/TraitTests/FunctorLawTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,58 @@
using LanguageExt.Common;
using Xunit;
using LanguageExt.Common;
namespace LanguageExt.Tests.TraitTests;

public class FunctorLawTests
{
[Fact]
public void Arr()
{
Arr<int> fa = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
FunctorLaw<Arr>.assert(fa);
}

[Fact]
public void HashMap()
{
HashMap<string, int> fa = [("one", 1), ("two", 2), ("three", 3), ("four", 4), ("five", 5)];
FunctorLaw<HashMap<string>>.assert(fa);
}

[Fact]
public void HashSet()
{
HashSet<int> fa = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
FunctorLaw<HashSet>.assert(fa);
}

[Fact]
public void Iterable()
{
Iterable<int> fa = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
FunctorLaw<Iterable>.assert(fa);
}

[Fact]
public void Lst()
{
Lst<int> fa = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
FunctorLaw<Lst>.assert(fa);
}

[Fact]
public void Map()
{
Map<string, int> fa = [("one", 1), ("two", 2), ("three", 3), ("four", 4), ("five", 5)];
FunctorLaw<Map<string>>.assert(fa);
}

[Fact]
public void Seq()
{
Seq<int> fa = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
FunctorLaw<Seq>.assert(fa);
}

[Fact]
public void EffRT()
{
Expand Down
20 changes: 20 additions & 0 deletions LanguageExt.Tests/TraitTests/MonadLawsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ namespace LanguageExt.Tests.TraitTests;

public class MonadLawsTest
{
[Fact]
public void Arr() =>
MonadLaw<Arr>.assert();

[Fact]
public void HashSet() =>
MonadLaw<HashSet>.assert();

[Fact]
public void Iterable() =>
MonadLaw<Iterable>.assert();

[Fact]
public void Lst() =>
MonadLaw<Lst>.assert();

[Fact]
public void Seq() =>
MonadLaw<Seq>.assert();

[Fact]
public void EffRT()
{
Expand Down

0 comments on commit c3e7591

Please sign in to comment.