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

Labelled tests #342

Open
byorgey opened this issue Mar 5, 2022 · 1 comment
Open

Labelled tests #342

byorgey opened this issue Mar 5, 2022 · 1 comment
Labels
C-Moderate Effort Should take a moderate amount of time to address. S-Moderate Moderate importance U-Error Reporting U-Parsing U-Testing Z-Feature Request Z-Student Good project for a student.

Comments

@byorgey
Copy link
Member

byorgey commented Mar 5, 2022

For documentation purposes, educational purposes, etc., it may often make sense to put tests after a definition. However, at the moment this is impossible since we attach all tests to the following definition.

  1. One alternative would be to forget the whole idea of attaching specific tests to specific functions. Maybe instead of something like
    Running tests...
      even: OK
      odd: OK
    
    we could instead print something like
    Running tests... 12 tests passed!
    
    
  2. Another alternative would be to create some kind of syntax for specifying which definition a test should be attached to.

I kind of lean towards the first alternative at this point. I can't think of any particularly important benefits of attaching tests to definitions. And I can think of several situations in which the choice of which definition to attach a test to is arbitrary (for example, when expressing the property that two functions are inverses).

@byorgey byorgey added C-Moderate Effort Should take a moderate amount of time to address. Z-Feature Request U-Testing S-Moderate Moderate importance labels Mar 5, 2022
@byorgey
Copy link
Member Author

byorgey commented Apr 28, 2022

Well, I actually thought of one benefit of attaching tests to definitions: it makes it easy to see which definition is wrong.

However, perhaps we could get the same benefit by simply noting (syntactically) which local definitions are mentioned in the definition of property, and mentioning them in the message for a failed test case.

Another benefit is that when trying to fill in definitions to make tests pass, it's easy to see which ones you've gotten right. But perhaps we could get this benefit by the ability to label tests somehow. Labelled tests could be displayed individually with their label. Maybe identically labelled tests would be grouped together. Unlabelled tests would all just be grouped together; essentially "no label" would be a special kind of label. As for syntax, the tricky part is to pick some label syntax that could easily be distinguished from an expression. e.g. [label] property is out because it looks like a list. Maybe something like this?

!!! exp     -- unlabelled
!!! label # exp   -- labelled

Or what if whitespace after !!! and before the property is required, and labels look like this:

!!![label] exp

byorgey added a commit that referenced this issue May 5, 2022
@byorgey byorgey added the Z-Student Good project for a student. label Nov 2, 2024
@byorgey byorgey changed the title Ability to put tests after a definition Labelled tests Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Moderate Effort Should take a moderate amount of time to address. S-Moderate Moderate importance U-Error Reporting U-Parsing U-Testing Z-Feature Request Z-Student Good project for a student.
Projects
None yet
Development

No branches or pull requests

1 participant