summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-05-24 12:25:50 +0300
committerDaniel Silverstone <dsilvers@digital-scurf.org>2020-05-24 13:26:34 +0100
commit9101fad30e1f0cbb1839fc5fb189761001857e8f (patch)
treed7489b95ad2a70a1b79906dc19706a74c8aa7704
parentc6ea6589bac4312501ff50bc157ddc8ee8c3dfdb (diff)
downloadsubplot-9101fad30e1f0cbb1839fc5fb189761001857e8f.tar.gz
test: add test scenarios for mixing regex and simple patterns
-rw-r--r--subplot.md65
1 files changed, 65 insertions, 0 deletions
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