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

🖊️ Convert input from ask command to booleans #5697

Merged
merged 17 commits into from
Aug 23, 2024
Merged

Conversation

boryanagoncharenko
Copy link
Collaborator

Fixes #5691
Starting with level 12, we try to convert the input from the ask command to a number (first an int, then a float). If that conversion fails, we keep it as a string. Now that we support boolean values starting with level 15, it makes sense to try and convert the input to a boolean too.

How to test
Note that the added automated tests do not cover the full execution of the programs because we cannot fully test the interaction with the 'ask' command. To test this locally, run the following snippet in level 15:

a is true
b is ask 'True or False?'
if a == b
    print 'match ' a ' ' b
else
    print 'mismatch ' a ' ' b

When the input box appears put in the following: true, false, True, False, 15, not_a_boolean. Note that the print statements should output exactly what you typed in, i.e. if you typed true you should not get True.
Change the language to Bulgarian and paste the following input вярно (which is True), невярно (which is False).

Copy link
Member

@jpelay jpelay left a comment

Choose a reason for hiding this comment

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

Hi @boryanagoncharenko! This works great and I love it. I won't approve right away because you say:

we cannot fully test the interaction with the 'ask' command.

But we can! Using Cypress we can add a test to check if the behavior is the expected in the website. I can add the test if you want! We already do it with a couple of commands.

@boryanagoncharenko
Copy link
Collaborator Author

Hi @boryanagoncharenko! This works great and I love it. I won't approve right away because you say:

we cannot fully test the interaction with the 'ask' command.

But we can! Using Cypress we can add a test to check if the behavior is the expected in the website. I can add the test if you want! We already do it with a couple of commands.

Excellent point! Cypress tests are slow so I added only a couple of tests to check the conversion to numbers in level 12 and booleans in level 15.
I saw that there are already tests that use the ask command but they seem to be testing debugging too. So I added a new file and I did some refactoring, but I am not confident of the naming or the tools section. Could you please have a look at these changes? Thanks in advance!

Copy link
Contributor

mergify bot commented Aug 23, 2024

Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 41944b9 into main Aug 23, 2024
12 checks passed
Copy link
Contributor

mergify bot commented Aug 23, 2024

Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot deleted the boolean_from_input branch August 23, 2024 16:13
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.

🖊️ Add support for boolean values in the ask command
2 participants