datacamp / testwhat

Write Submission Correctness Tests for R exercises
https://datacamp.github.io/testwhat
GNU Affero General Public License v3.0
33 stars 25 forks source link

check_body() should allow check_object() to look inside the function body #210

Open richierocks opened 5 years ago

richierocks commented 5 years ago

To test a function definition, it is sometime helpful to see if the student defined a particular variable.

At the moment, it seems that check_object() always looks in the global environment.

Here's an example exercise showing the SCT I want to write and a hacky workaround.

https://www.datacamp.com/teach/repositories/986/branches/scope-of-check_object

hermansje commented 5 years ago

In pythonwhat, this is possible as shown in the second example under check_object, but as a feature of the equality check instead of the object check. There is an important difference: check_object checks the final process state, while the equality check is done on a repeated evaluation. Since not all needed functionality from pythonwhat is available in testwhat, you approach might be a good approach until it is.

Either way it is a good idea to add an example of the current best approach to the documentation.