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

testing lambda functions: block beta testing 08/17 #55

Closed
hugobowne opened this issue Aug 1, 2016 · 4 comments
Closed

testing lambda functions: block beta testing 08/17 #55

hugobowne opened this issue Aug 1, 2016 · 4 comments
Assignees

Comments

@hugobowne
Copy link

can we test the definition and use of lambda function?

E.g.

# Define echo_word as a lambda function: echo_word
echo_word = (lambda word1, echo: word1 * echo)

and

# Create a list of strings: spells
spells = ['protego', 'accio', 'expecto patronum', 'legilimens']

# Use map() to apply a lambda function over spells: shout_spells
shout_spells = map(lambda item: item + '!!!', spells)
@vvnkr
Copy link
Member

vvnkr commented Aug 2, 2016

Testing the definition is not possible ATM but I think you can test the functionality of a lambda function using test_expression_result().

E.g.

test_expression_result(expr_code="echo_word('ECHO!!', 5)")

This will compare the result of expr_code in the student and solution environment (and since these environments contain the defined lambda expression, it tests whether they return the same).

@filipsch
Copy link
Contributor

filipsch commented Aug 2, 2016

@vincentvankrunkelsven thanks for sharing this.
@hugobowne The workaround that Vincent mentions indeed allows you to indirectly test a lambda functions, but it's not ideal.

I'll try to look into a decent way of providing support for lambda functions by start of week next week (August 8).

@filipsch filipsch self-assigned this Aug 2, 2016
@filipsch
Copy link
Contributor

filipsch commented Aug 4, 2016

@hugobowne a function test_lambda_function() that looks very much like test_function_definition() has been added; it'll be on staging soon.
Wiki article will be added here

@filipsch
Copy link
Contributor

filipsch commented Aug 8, 2016

Will go live tomorrow

@filipsch filipsch closed this as completed Aug 8, 2016
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

No branches or pull requests

3 participants