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

🖊️ Make ask command symmetrical to print command in terms of input #5362

Merged
merged 4 commits into from
Apr 16, 2024

Conversation

boryanagoncharenko
Copy link
Collaborator

Fixes #1938
The ask command now accepts the same input as the print command. In levels 2-3 it supports variables and list access. If the variable is defined after the command or the list is just used by name (without at random or at index), the argument is interpreted as a literal string.

How to test
Automated tests are added to cover all changes. However, to get a sense of how the change looks in Hedy, execute the following snippets in the respective level.
Level 2

name is Hedy
answer is ask are you name?
# the ask command should yield `are you Hedy?`
answer is ask are you name?
name is Hedy
# the ask command should yield `are you name?` because the variable name is defined afterwards
name is what is your name?
# the name on the rhs should be a literal string and not a reference to the variable

Level 3

animals is cat, dog, hamster
answer is ask Do you have a animals at random?
print Do you have a animals at random
# both commands should interpret animals at random
animals is cat, dog, hamster
answer is ask Do you like animals?
print Do you like animals?
# both commands should not interpret animals, so it should be 'Do you like animals?'
animals is cat, dog, hamster
answer is ask Do you like animals at rand?
print Do you like animals at rand?
# both commands should not interpret animals, so it should be 'Do you like animals at rand?'
c is red, green, blue
color c
# should yield a runtime error that the supplied value is not a color
red is 1, 2, 3
color red
# should not yield an error and should correctly show a red turtle

Copy link
Contributor

mergify bot commented Apr 16, 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 a06152e into main Apr 16, 2024
12 checks passed
@mergify mergify bot deleted the ask_1938 branch April 16, 2024 20:48
Copy link
Contributor

mergify bot commented Apr 16, 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[BUG] combining ask with at random does not work (level 3)
2 participants