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

Assert statements in GOOL #3911

Open
B-rando1 opened this issue Aug 6, 2024 · 1 comment
Open

Assert statements in GOOL #3911

B-rando1 opened this issue Aug 6, 2024 · 1 comment
Assignees

Comments

@B-rando1
Copy link
Collaborator

B-rando1 commented Aug 6, 2024

I made a comment about this a bit ago in #3557. Python has the assert keyword that checks a condition and throws an error if it is not met. If we could add this idea to GOOL, we could use it to improve our testing methods.

In particular, we could use it in drasil-code/test to improve our GOOL tests in stable/gooltest. Currently a lot of those tests just run, without checking any values; and at most they print out values without telling us what the values should be. Using assert statements would really help with that.

Here's an outline of what we need to do:

  • Add assert :: SValue r -> MSStatement r to InterfaceCommon.hs. Most likely the ControlStatement typeclass would be where we want to add it.
  • Research what we can use as assert in different languages. In Python this would be the most straightforward - assert(cond); in other languages we might just have to do if (!cond) {throw error} or something like that. It would depend on whether the language has something like assert built-in or not.
  • Implement assert in each of the renderers.

Once we have that in place, we can start using it in drasil-code/test to improve our testing.

@Xinlu-Y you said you were interested in working with GOOL. This could be a good medium-sized project that should be fairly beginner-friendly.

@B-rando1
Copy link
Collaborator Author

@Xinlu-Y good work!

One place where assert would be particularly helpful is with the listSlice tests. There's a lot of nuance to that function, so knowing right away that a renderer failed a test would be helpful.

With listSlice, you can treat Python as the standard: we want every renderer's listSlice to behave like Python's.

I'm not sure if GOOL currently has equality checking with lists, so we might need to figure that out first. I don't think that should be too hard to add if necessary, though.

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

2 participants