Open
Conversation
Since we'll be writing more and more of PlatformScript in
PlatformScript, we need a way to test PlatformScript in
PlatformScript.
This adds a `pls test` command that will find all files ending in the
`.test.yaml` extension in the `test` directory, and runs them as
PlatformScript tests.
Added to stdlib is the "testing.yaml" module where you can find a test
constructor, as well as matchers. The structure of a test is really,
really simple for now. It is just a list of expectations:
```yaml
$test:
- expect:
- subject
- matcher
- matcher
- matcher
- expect:
- subject
- matcher
- matcher
```
Matchers are just functions that run on the subject and return a
result for it. The following functions are shipped initially to create
matchers:
- `toEqual: expected`: takes an expected value and returns a matcher
that passes when the subject is equal to the expected.
- `not: matcher`: takes another matcher and passes only if that
matcher fails.
This is not the end all be all of testing frameworks, but what it
_is_, is something that we can use to write tests for our
PlatformScript as we begin to use it.
ff0e8be to
f5d625c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Since we'll be writing more and more of PlatformScript in PlatformScript, we need a way to test PlatformScript in PlatformScript.
Approach
This adds a
pls testcommand that will find all files ending in the.test.yamlextension in thetestdirectory, and runs them as PlatformScript tests.Added to stdlib is the "testing.yaml" module where you can find a test constructor, as well as matchers. The structure of a test is really, really simple for now. It is just a list of expectations:
Matchers are just functions that run on the subject and return a result for it. The following functions are shipped initially to create matchers:
toEqual: expected: takes an expected value and returns a matcher that passes when the subject is equal to the expected.not: matcher: takes another matcher and passes only if that matcher fails.This is not the end all be all of testing frameworks, but what it is, is something that we can use to write tests for our PlatformScript as we begin to use it.
Screenshots