Skip to content

Commit

Permalink
better assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
Konrad Jamrozik committed Jul 6, 2024
1 parent eda60b8 commit 8d4f405
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/game-lib/Players/AIPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public AIPlayer(ILog log, Intellect intellect)
_intellect = intellectMap[intellect];
}


public void PlayGameTurn(GameStatePlayerView state, GameTurnController controller)
=> _intellect.PlayGameTurn(state, controller);
}
7 changes: 4 additions & 3 deletions src/lib/Contracts/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ public static void AssertInRange(
$"{subjectName}: Expected value <= {range.End.Value}. value = {subject}. ");
}

// kja2 include in the exception the name of the caller
public static void Assert(
[DoesNotReturnIf(false)] bool condition,
[CallerArgumentExpression("condition")]
string? message = null)
string? message = null,
[CallerMemberName]
string? memberName = null)
{
if (!condition)
throw message != null ? new InvariantException(message) : new InvariantException();
throw message != null ? new InvariantException($"Caller: {memberName}(), Failed condition: {message}") : new InvariantException();
}

public static void AssertImplication(
Expand Down

0 comments on commit 8d4f405

Please sign in to comment.