From 9101fad30e1f0cbb1839fc5fb189761001857e8f Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 24 May 2020 12:25:50 +0300 Subject: test: add test scenarios for mixing regex and simple patterns --- subplot.md | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/subplot.md b/subplot.md index 74e23cf..f16c6fe 100644 --- a/subplot.md +++ b/subplot.md @@ -919,6 +919,71 @@ def func(ctx, name=None): print('function got argument name as', name) ~~~ +### Simple patterns with regex metacharacters: forbidden case + +Help use to avoid accidental regular expression versus simple pattern +confusion. The rule is that a simple pattern mustn't contain regular +expression meta characters unless the rule is explicitly marked as not +being a regular expression pattern. + +~~~scenario +given file confusedpattern.md +and file confusedpattern.yaml +and file capture.py +when I try to run sp-codegen --run confusedpattern.md -o test.py +then exit code is non-zero +and stderr matches /simple pattern contains regex/ +~~~ + +~~~~{#confusedpattern.md .file .markdown .numberLines} +--- +title: Simple pattern capture +bindings: confusedpattern.yaml +functions: capture.py +... + +# Simple pattern + +~~~scenario +given I* am Tomjon +~~~ +~~~~ + +~~~{#confusedpattern.yaml .file .yaml .numberLines} +- given: I* am {name} + function: func +~~~ + +### Simple patterns with regex metacharacters: allowed case + +~~~scenario +given file confusedbutok.md +and file confusedbutok.yaml +and file capture.py +when I run sp-codegen --run confusedbutok.md -o test.py +then program finished successfully +~~~ + +~~~~{#confusedbutok.md .file .markdown .numberLines} +--- +title: Simple pattern capture +bindings: confusedbutok.yaml +functions: capture.py +... + +# Simple pattern + +~~~scenario +given I* am Tomjon +~~~ +~~~~ + +~~~{#confusedbutok.yaml .file .yaml .numberLines} +- given: I* am {name} + function: func + regex: false +~~~ + ### Capture using regular expressions ~~~scenario -- cgit v1.2.1