diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-03-12 08:28:24 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-03-12 13:03:14 +0200 |
commit | e3d97f0ce778644a25329d08ba00645039e01447 (patch) | |
tree | 9d2dd2a4b5c701bf61b331d457da5f530ea17c35 /examples | |
parent | 6bd0d5d29953d522446552e2f49757c2481c0b19 (diff) | |
download | subplot-e3d97f0ce778644a25329d08ba00645039e01447.tar.gz |
docs: add example of minimal subplot using Rust step functions
Sponsored-by: author
Diffstat (limited to 'examples')
-rw-r--r-- | examples/seq/Cargo.toml | 12 | ||||
-rw-r--r-- | examples/seq/build.rs | 6 | ||||
-rw-r--r-- | examples/seq/seq.md | 44 | ||||
-rw-r--r-- | examples/seq/tests/seq.rs | 1 |
4 files changed, 63 insertions, 0 deletions
diff --git a/examples/seq/Cargo.toml b/examples/seq/Cargo.toml new file mode 100644 index 0000000..e0f577a --- /dev/null +++ b/examples/seq/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "seq" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +subplotlib = { path = "../../subplotlib" } + +[build-dependencies] +subplot-build = { path = "../../subplot-build" } diff --git a/examples/seq/build.rs b/examples/seq/build.rs new file mode 100644 index 0000000..398ec90 --- /dev/null +++ b/examples/seq/build.rs @@ -0,0 +1,6 @@ +//! Subplot seq example build script. + +fn main() { + println!("cargo:rerun-if-changed=seq.md"); + subplot_build::codegen("seq.md").expect("failed to generate code with Subplot"); +} diff --git a/examples/seq/seq.md b/examples/seq/seq.md new file mode 100644 index 0000000..da51a3f --- /dev/null +++ b/examples/seq/seq.md @@ -0,0 +1,44 @@ +--- +title: "**seq**(1) acceptance tests" +author: The Subplot project +bindings: +- lib/runcmd.yaml +impls: + rust: [] +... + +# Introduction + +**seq**(1) is a Unix command line tool that produces numbers 1, 2, +etc, up until a count given by the user. For example, if the user runs +`seq 3`, the output has the numbers 1, 2, and 3, one per line. + +# No arguments + +_Requirement: If `seq` is run without arguments, it reports an error._ + +```scenario +when I try to run seq +then exit code is 1 +``` + +# No numbers + +_Requirement: If `seq` is run with the argument 0, it writes nothing._ + +```scenario +when I run seq 0 +then stdout is exactly "" +then stderr is exactly "" +``` + +# One number + +_Requirement: If `seq` is run with the argument 1, it writes one line, +with the number 1._ + +```scenario +when I run seq 1 +then stdout is exactly "1\n" +then stderr is exactly "" +``` diff --git a/examples/seq/tests/seq.rs b/examples/seq/tests/seq.rs new file mode 100644 index 0000000..5412848 --- /dev/null +++ b/examples/seq/tests/seq.rs @@ -0,0 +1 @@ +include!(concat!(env!("OUT_DIR"), "/seq.rs")); |