Skip to content

Commit

Permalink
added section to CONTRIBUTING.md about snippet tests
Browse files Browse the repository at this point in the history
  • Loading branch information
slightknack committed Dec 11, 2020
1 parent ac3f74e commit a682a84
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
41 changes: 39 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ If you're reading this, thanks for taking a look! If you would like to contribut
## Code of Conduct
If you find any bugs or would like to request any features, please open an issue. Once the issue is open, feel free to put in a pull request to fix the issue. Small corrections, like fixing spelling errors, or updating broken urls are appreciated. All pull requests must have adequate testing and review to assure proper function before being accepted.

We encourage an open, friendly, and supportive environment around the development of Passerine. If you disagree with someone for any reason, discuss the issue and express you opinions, don't attack the person. Discrimination of any kind against any person is not permitted. If you detract from this project's collaborative environment, you'll be prevented from participating in the future development of this project until you prove you can behave yourself adequately. Please provide arguments based on anecdotes and reasoning to support your suggestions - don't rely on arguments based on 'years of experience,' supposed skill, job title, etc. to get your points across.
We encourage an open, friendly, and supportive environment around the development of Passerine. If you disagree with someone for any reason, discuss the issue and express you opinions, don't attack the person. Discrimination of any kind against any person is not permitted. If you detract from this project's collaborative environment, you'll be prevented from participating in the future development of this project until you prove you can behave yourself adequately. Please use sound reasoning to support your suggestions - don't rely on arguments based on 'years of experience,' supposed skill, job title, etc. to get your points across.

# General Guidelines
Readable code with clear behavior works better than illegible optimized code. For things that are very performance-oriented, annotations describing what, how, and why are essential.
Expand All @@ -30,4 +30,41 @@ Passerine strives to implement a modern compiler pipeline. Passerine is currentl
- The command line interface and the package repository, [Aspen](https://github.com/vrtbl/aspen).

> TODO: write about project structure
> TODO: integration tests
# Integration Tests
If you notice any unsound behavior, like an internal compile error or an incorrect,

1. Reduce the behavior to the minimum required amount of passerine code that causes that error
2. Open an issue explaining what led to the error, what you expected to happen, and the minimum reproducible example.
3. Optionally, add the snippet to `tests/snippets` and test that the test fails (by running `cargo test snippets`).

## What is a test snippet?
A test snippet is some Passerine code that tests a specific outcome. Here's a simple test snippet:

```passerine
-- action: run
-- outcome: success
-- expect: "Banana"
print "Hello, World!"
"Banana"
```

A test snippet starts with a series of comments, each one forming a key-value pair. The `action` is what the compiler should do with the snippet:

- `lex`
- `parse`
- `desugar`
- `compile`
- `run`

The outcome specifies the spefic result:

- No errors are raised: `success`
- A syntax error is raised: `syntax`
- A runtime error is raised: `trace`

Optionally, if the action is `run` an `outcome` may be specified. This treats the snippet like a function body, and compares the returned value with the expected value.

Whenever you add a feature, add snippet tests that demonstrate how this feature should (and should not) work.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "passerine"
version = "0.8.0"
version = "0.8.1"
authors = [
"Isaac Clayton (slightknack) <[email protected]>",
"The Passerine Community",
Expand Down
4 changes: 2 additions & 2 deletions tests/snippets/chaining.pn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- action: run
-- action: run
-- outcome: success
-- expect: "Bye"
-- expect: "Bye"

i = x -> x
bye = x -> "Bye"
Expand Down

0 comments on commit a682a84

Please sign in to comment.