summaryrefslogtreecommitdiff
path: root/subplot.md
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2021-08-14 09:49:17 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2021-09-07 17:32:20 +0100
commit4436b7ee28b0318a96d98833d85d712c8a18850d (patch)
treeca8c124284b7585b310fa4340d6a63be498ccba6 /subplot.md
parent70461d3af84d1f5363df67f2f50f10b9dce86812 (diff)
downloadsubplot-4436b7ee28b0318a96d98833d85d712c8a18850d.tar.gz
bindings: Parse polyglot bindings
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'subplot.md')
-rw-r--r--subplot.md110
1 files changed, 81 insertions, 29 deletions
diff --git a/subplot.md b/subplot.md
index b7169c7..aef5808 100644
--- a/subplot.md
+++ b/subplot.md
@@ -654,16 +654,24 @@ expresssions ([PCRE][]).
~~~{.yaml .numberLines}
- given: "a standard setup"
- function: create_standard_setup
+ impl:
+ python:
+ function: create_standard_setup
- when: "{thing} happens"
- function: make_thing_happen
+ impl:
+ python:
+ function: make_thing_happen
types:
thing: word
- when: "I say (?P<sentence>.+) with a smile"
regex: true
- function: speak
+ impl:
+ python:
+ function: speak
- then: "everything is OK"
- function: check_everything_is_ok
+ impl:
+ python:
+ function: check_everything_is_ok
~~~
In the example above, there are four bindings:
@@ -925,17 +933,29 @@ then bar was done
~~~{#b.yaml .file .yaml .numberLines}
- given: precondition foo
- function: precond_foo
+ impl:
+ python:
+ function: precond_foo
- when: I do bar
- function: do_bar
+ impl:
+ python:
+ function: do_bar
- when: I do foobar
- function: do_foobar
+ impl:
+ python:
+ function: do_foobar
- then: bar was done
- function: bar_was_done
+ impl:
+ python:
+ function: bar_was_done
- then: foobar was done
- function: foobar_was_done
+ impl:
+ python:
+ function: foobar_was_done
- given: file {filename}
- function: provide_file
+ impl:
+ python:
+ function: provide_file
types:
filename: file
~~~
@@ -1152,14 +1172,20 @@ test this for every language template we support.
~~~{#cleanup.yaml .file .yaml .numberLines}
- given: foo
- function: foo
- cleanup: foo_cleanup
+ impl:
+ python:
+ function: foo
+ cleanup: foo_cleanup
- given: bar
- function: bar
- cleanup: bar_cleanup
+ impl:
+ python:
+ function: bar
+ cleanup: bar_cleanup
- given: failure
- function: failure
- cleanup: failure_cleanup
+ impl:
+ python:
+ function: failure
+ cleanup: failure_cleanup
~~~
~~~{#cleanup.py .file .python .numberLines}
@@ -1370,7 +1396,9 @@ then TMPDIR is set
~~~{#tmpdir.yaml .file .yaml .numberLines}
- then: TMPDIR is set
- function: tmpdir_is_set
+ impl:
+ python:
+ function: tmpdir_is_set
~~~
~~~{#tmpdir.py .file .python .numberLines}
@@ -1420,7 +1448,9 @@ given I am Tomjon
~~~{#simplepattern.yaml .file .yaml .numberLines}
- given: I am {name}
- function: func
+ impl:
+ python:
+ function: func
~~~
~~~{#capture.py .file .python .numberLines}
@@ -1462,7 +1492,9 @@ given I* am Tomjon
~~~{#confusedpattern.yaml .file .yaml .numberLines}
- given: I* am {name}
- function: func
+ impl:
+ python:
+ function: func
~~~
### Simple patterns with regex metacharacters: allowed case
@@ -1493,7 +1525,9 @@ given I* am Tomjon
~~~{#confusedbutok.yaml .file .yaml .numberLines}
- given: I* am {name}
- function: func
+ impl:
+ python:
+ function: func
regex: false
~~~
@@ -1528,7 +1562,9 @@ given I am Tomjon
~~~{#regex.yaml .file .yaml .numberLines}
- given: I am (?P<name>\S+)
- function: func
+ impl:
+ python:
+ function: func
regex: true
~~~
@@ -1577,10 +1613,14 @@ then expanded "${foo}" is bar
~~~{#values.yaml .file .yaml .numberLines}
- when: I remember {name} as {value}
- function: remember
+ impl:
+ python:
+ function: remember
- then: expanded "{actual}" is {expected}
- function: check
+ impl:
+ python:
+ function: check
~~~
~~~{#values.py .file .python .numberLines}
@@ -1643,7 +1683,9 @@ then environment variable FOO is set to "bar"
~~~{#env.yaml .file .yaml .numberLines}
- then: environment variable {name} is set to "{value:text}"
- function: is_set_to
+ impl:
+ python:
+ function: is_set_to
~~~
~~~{#env.py .file .python .numberLines}
@@ -2541,12 +2583,18 @@ binding.
```{#badbindings.yaml .file .yaml}
- given: a binding
- function: a_binding
+ impl:
+ python:
+ function: a_binding
- given: a (?:broken)? binding
- function: a_broken_binding
+ impl:
+ python:
+ function: a_broken_binding
regex: true
- given: a capitalised Binding
- function: os.getcwd
+ impl:
+ python:
+ function: os.getcwd
case_sensitive: true
```
@@ -2618,9 +2666,13 @@ given a binding
~~~{#twobindings.yaml .file .yaml}
- given: a {xyzzy}
- function: a_function
+ impl:
+ python:
+ function: a_function
- given: a {plugh}
- function: a_function
+ impl:
+ python:
+ function: a_function
~~~
~~~{#a_function.py .file .python}