Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix role_playing_game test according to instructions #444

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GioeleBucci
Copy link

The exercise's instructions say: "If they player's level is below 10, their mana should be untouched."

Since the test checked against None there were unintended solutions that did not account for the player level, such as:

Some(Player(..player, health: 100, mana: option.map(player.mana, fn(_){ 100 })))

The exercise's instructions say: "If they player's level is below 10, their mana should be untouched."

Since the test checked against `None` there were unintended solutions that did not account for the player level, such as:

`Some(Player(..player, health: 100, mana: option.map(player.mana, fn(_){ 100 })))`
Copy link
Sponsor Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! Isn't this unchanged and thus correct both before and after this change?

@GioeleBucci
Copy link
Author

Hello! Isn't this unchanged and thus correct both before and after this change?

It is indeed correct, but the test uses None, which is an unfortunate value to check against since it allows defaulting to None, independently from the previous value of the "mana".
If the value to keep was, for example 7, one could ignore it and set it to None: since the test checks against that same value it would pass when it shouldn't. Changing the value the test uses to an integer would prevent such behaviour.
I don't know if I explained it in the best terms but hopefully it's understandable.

@GioeleBucci GioeleBucci reopened this Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants