https://github.com/sogaiu/judge-gen
https://github.com/sogaiu/judge-gen
examples janet testing
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sogaiu/judge-gen
- Owner: sogaiu
- Created: 2020-06-24T08:35:05.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-12-31T23:28:47.000Z (over 4 years ago)
- Last Synced: 2025-10-06T03:57:22.794Z (9 months ago)
- Topics: examples, janet, testing
- Homepage:
- Size: 485 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.adoc
- Support: support/build.janet
Awesome Lists containing this project
README
= judge-gen - Generate and Run Tests from Usage Examples
:toc:
== Aims
* Make simple testing low-cost and automatable especially during
exploratory coding when using Janet.
* Encourage the creation of illustrative examples to help potential users
form appropriate mental models.
== Status and Warnings
This is an early stage project. The author uses it in a number of
projects though. Be sure to examine the link:doc/warning.adoc[fine print].
== How
* Within `comment` blocks, put expressions / forms to be tested along
with brief records of expected values:
+
[source,janet]
----
(comment
(- 1 1)
# => 0
)
----
+
Note the use of a single line comment and `=>` to express an
expected return value.
+
One might call the form + expected value comment a "comment block
test".
+
See link:doc/tips.adoc[Usage / Test Writing Tips] for more details.
* Once some setup steps are followed, tests can be run by: `jpm test`
== Example Setup
Suppose there's a project directory like:
----
.
├── my-src-dir
│ └── fun.janet
├── project.janet
└── test
└── test.janet
----
0. Decide on a name for the directory to hold comment block tests,
e.g. `examples`.
1. Copy the file `test/judge-gen.janet` from this repository to the
target project's `test` subdirectory and rename it to
`examples.janet`.
3. Create a direct subdirectory of the project root directory named
`examples` to house comment block tests.
4. Within the `examples` directory, create at least one file with a
comment block test in it.
Now it should look something like:
----
.
├── examples
│ └── nice-samples.janet
├── my-src-dir
│ └── fun.janet
├── project.janet
└── test
├── examples.janet
└── test.janet
----
See link:doc/details.adoc[Details] for additional information regarding the
various files and directories.
== Usage
To run the tests and get a report: `jpm test`
Add more tests / examples by creating more comment block tests in
files that live in an appropriate directory.
== Sample Repositories
This repository can serve as an example, but here are some others:
* https://github.com/sogaiu/clojure-peg[clojure-peg]
* https://github.com/sogaiu/detect-clj-ns[detect-clj-ns]
* https://github.com/sogaiu/janet-zip[janet-zip]
* https://github.com/sogaiu/mal-peg[mal-peg]
* https://gitlab.com/sogaiu/margaret[margaret]
== Acknowledgments
* andrewchambers - suggestion and explanation
* bakpakin - janet, jpm, helper.janet, path.janet, peg for janet, etc.
* pepe - discussion, One-Shot Power Util Solver ™ motivation, and naming
* pyrmont - discussion and exploration
* rduplain - bringing to light customization of `jpm test`
* Saikyun - discussion and testing
* srnb@gitlab - suggestion