From 8f73d4a5a1c48dbf1b2a75a6a01ee37b28381e9e Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 6 Jun 2020 15:52:59 +0100 Subject: test: Add no-binding and multiple-binding check scenarios Signed-off-by: Daniel Silverstone --- subplot.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/subplot.md b/subplot.md index b2cdecf..b99f397 100644 --- a/subplot.md +++ b/subplot.md @@ -1811,6 +1811,66 @@ This is another embedded file, and has the same name in uppercase. ``` ~~~~ +## Steps must match bindings + +Subplot permits the binding author to define arbitrarily complex regular +expressions for binding matches. In order to ensure that associating steps +to bindings is both reliable and tractable, a step must match _exactly one_ +binding. + +```{#badbindings.yaml .file .yaml} +- given: a binding + function: a_binding +- given: a (?:broken)? binding + function: a_broken_binding + regex: true +``` + +### Steps which do not match bindings do not work + +~~~~{#nobinding.md .file .markdown} +--- +title: No bindings available +bindings: +- badbindings.yaml +... +# Broken scenario because step has no binding + +```scenario +given a missing binding +then nothing works +``` +~~~~ + +```scenario +given file nobinding.md +and file badbindings.yaml +when I try to run sp-codegen --run nobinding.md -o test.py +then exit code is non-zero +``` + +### Steps which match more than one binding do not work + +~~~~{#twobindings.md .file .markdown} +--- +title: Two bindings match +bindings: +- badbindings.yaml +... +# Broken scenario because step has two possible bindings + +```scenario +given a binding +``` +~~~~ + +```scenario +given file twobindings.md +and file badbindings.yaml +when I try to run sp-codegen --run twobindings.md -o test.py +then exit code is non-zero +``` + ## Embedded graphs -- cgit v1.2.1