summaryrefslogtreecommitdiff
path: root/subplotlib
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2021-01-23 13:18:05 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2021-01-23 13:18:05 +0000
commitffe41e0d0a4f8c4b03d733a6aed30aad4cc0b33a (patch)
treef0503a905ca0615d82ae0411ce59f99fe901d19a /subplotlib
parent854d78e02d501c6c8f1a469b3eae1087fec46855 (diff)
downloadsubplot-ffe41e0d0a4f8c4b03d733a6aed30aad4cc0b33a.tar.gz
subplotlib: Verify cleanup function argument support
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'subplotlib')
-rw-r--r--subplotlib/helpers/subplotlib_impl.rs6
-rw-r--r--subplotlib/subplotlib.md2
-rw-r--r--subplotlib/subplotlib.yaml4
-rw-r--r--subplotlib/tests/subplotlib.rs10
4 files changed, 12 insertions, 10 deletions
diff --git a/subplotlib/helpers/subplotlib_impl.rs b/subplotlib/helpers/subplotlib_impl.rs
index e0d8ad1..767e122 100644
--- a/subplotlib/helpers/subplotlib_impl.rs
+++ b/subplotlib/helpers/subplotlib_impl.rs
@@ -1,10 +1,10 @@
#[step]
-fn a_trivial_setup(context: &mut Context) {
- context.counter = 0;
+fn a_trivial_setup(context: &mut Context, initial: usize) {
+ context.counter = initial;
}
#[step]
-fn a_trivial_cleanup(context: &mut Context) {}
+fn a_trivial_cleanup(context: &mut Context, _initial: usize) {}
#[step]
fn increment_counter(context: &mut Context) {
diff --git a/subplotlib/subplotlib.md b/subplotlib/subplotlib.md
index 237ad03..872bd62 100644
--- a/subplotlib/subplotlib.md
+++ b/subplotlib/subplotlib.md
@@ -23,7 +23,7 @@ All fundamental keywords are properly supported in subplotlib and the rust
template.
```scenario
-given a trivial setup
+given a counter starting at 0
when the counter is incremented
then the counter is 1
when the counter is incremented
diff --git a/subplotlib/subplotlib.yaml b/subplotlib/subplotlib.yaml
index c676922..78090c3 100644
--- a/subplotlib/subplotlib.yaml
+++ b/subplotlib/subplotlib.yaml
@@ -1,6 +1,8 @@
-- given: a trivial setup
+- given: a counter starting at {initial}
function: a_trivial_setup
cleanup: a_trivial_cleanup
+ types:
+ initial: int
- when: the counter is incremented
function: increment_counter
- then: the counter is {num}
diff --git a/subplotlib/tests/subplotlib.rs b/subplotlib/tests/subplotlib.rs
index 174f5a1..cc2cf23 100644
--- a/subplotlib/tests/subplotlib.rs
+++ b/subplotlib/tests/subplotlib.rs
@@ -35,12 +35,12 @@ impl ContextElement for Context {
// This came from helpers/subplotlib_impl.rs
#[step]
-fn a_trivial_setup(context: &mut Context) {
- context.counter = 0;
+fn a_trivial_setup(context: &mut Context, initial: usize) {
+ context.counter = initial;
}
#[step]
-fn a_trivial_cleanup(context: &mut Context) {}
+fn a_trivial_cleanup(context: &mut Context, _initial: usize) {}
#[step]
fn increment_counter(context: &mut Context) {
@@ -108,8 +108,8 @@ lazy_static! {
fn fundamentals() {
let mut scenario = Scenario::new(&base64_decode("RnVuZGFtZW50YWxz"));
- let step = a_trivial_setup::Builder::default().build();
- let cleanup = a_trivial_cleanup::Builder::default().build();
+ let step = a_trivial_setup::Builder::default().initial(0).build();
+ let cleanup = a_trivial_cleanup::Builder::default().initial(0).build();
scenario.add_step(step, Some(cleanup));
let step = increment_counter::Builder::default().build();