Presentation
EuroTcl2018
Munich
Version 1.7
July 2018
brief background
exploring extensions
Better software(-based) systems, through:
See the Wikipedia section on the Gherkin language in the Cucumber (software) article.
It's a little-language — just features, scenarios, and steps.
#starts a comment
Does this all sound familiar?
Features are context for "scenarios".
Feature:Register for EuroTcl 2018 A user wants to register for EuroTcl 2018. Let them.
Scenarios are a sequence of steps.
Scenario:Scenario 1GivenpreconditionsWhenactionsThenresults
Scenario:Scenario 2 ...
Scenario:A user wants to registerGiventhey have a browserWhenthey enter an email addressThenthey get a confirmation
Scenario outlines are clone recipes.
Scenario Outline:Banned users are rejectedGivena denied-persons databaseWhena user submits an <email>Thenthey get a <response>Examples:…
Examples fill scenario-outlines.
Examples: |email | ban? | response ||foo@x.org | yes | rejection ||drk@x.org | no | confirmation ||bar@x.org | yes | rejection |
Giventravel is requestedWhenthe first-line manager approvesAndthe accountant approvesAndthe big boss approves
??? in any order
Thenthe request is approved
J. Fröhlich et al. Reliable Statements About a
Fault-Tolerant X-by-Wire eCar, 2017.
Why use Tcl?
Its size and power — and a fun idea.
proc unknown
A few gotchas.
Scenario:cold start; ArcticArctic conditions require special behavior;as well as certification
Scenario:"cold start; Arctic""Arctic conditions require special behavior; as well as certification"
Givensufficient coolant[DIN 0]
Givensufficient coolant \[DIN 0\]
Feature:Avoiding unsightly layout It is important to avoid so called"widows"and"orphans"in layout.
Feature:Avoiding unsightly layout It is important to avoid so called 'widows' and 'orphans' in layout.
Feature:Packaging Packages must accommodate aset of six;be recyclable.And
Feature:Packaging Packages must accommodate a {} set of six;{} And be recyclable.
Feature:Packaging"""Packages must accommodate a set of six; and be "recyclable"."""
Feature:Packaging{{{Packages must accommodate a set of six; and be "recyclable".}}}
Remember when …
{*}bar
was
"extra characters after close-brace"
Well,
"foo"bar"baz"
is still
"extra characters after close-quote"
We could leapfrog both Python and Lua.
""" pythonic string """
""[ \, $, and [] replacements ]""
""{ no replacements }""
""===" trans-pythonic string "==="" ""==[ Tcl-ish long string ]=="" ""={ Lua-ish long braces }=""
Avoids both long lines and line splicing.
Feature:Enhancement: the "with" adverb Demonstrate the trivial enhancement: the "with" adverb. By the way: this feature file also shows that text can simply be inserted after the Feature line.Scenario:use With as a Given, When, or Then By the way: descriptive text can simply be added after the Scenario line, too.
Giventhat the wheel speed is 1001 rpmWitha confidence of 60%Whenthe wheel speed is reported as 1000 rpmAndthe wheel speed is 1001 RPMWitha confidence of 60%Thenthe wheel speed is 1000 rpmWitha confidence of 80 percent
Feature:Enhancement/Sugar: the A, B, etc. option Demonstrate the automatic handling of single steps that imply multiple tests.Scenario:automatic unfolding of scenariosGiventhe system mode is commissioning or runningWhen10, 20, or 30ms passAnd4, 6ms passThenthe system mode is stopped
Feature:Enhancement: info cascades downward Demonstrate effect on scenarios.|mode | acceleration allowed ||----------------+----------------------||failsafe | no ||normal | yes ||fire | no ||fire in tunnel | yes ||commissioning | no ||shakedown | yes |
Scenario:No power to wheels during an emergencyGiventhe mode is not normal or shakedown# this fails because mode "fire in tunnel" allows motionAndthrottle 0% or not 0%Thenpower to wheels is at most 0 WScenario:Power to wheels is possible when not in troubleGivenmode is neither fire nor failsafe# this fails because mode "fire in tunnel" allows motionAndthrottle is greater than 0%Thenpower to wheels is greater than 0 W
#wheel-motion-indication.featureScenario Outline:Calculation of confidenceGiventhat initially the wheel is turning at w_0 rpmWitha confidence of c_0 percentWhenthe wheel speed is measured as m_1... rpmAnd{ms} ms passThenits computed velocity is w_1... rpmWitha confidence of c_1... percent
@supplier_UGEExamples:{{{SELECT ms, m_*, w_*, c_*, title FROM d:/alfha/bdd/features/dat/wheel-motion-sensor-kennlinien.txt;}}}# | ms | w_0 | c_0 | m_1 | w_1 | c_1 | m_2 | w_2 | c_2 | title | # | ms | rpm | % | rpm | rpm | % | rpm | rpm | % | |
lines LOC #s file ----- ----- ----- ---------------------------- 576 472 75 src/behave.tcl 149 56 76 src/cmd_auxiliaries.tcl 62 25 35 src/cmd_ifnoproc.tcl 58 30 24 src/cmd_perform.tcl 104 74 28 src/cmd_prequel.tcl 97 35 55 src/mix_addin.tcl 473 229 220 src/mix_gherkin.tcl 336 143 175 src/mix_oblist.tcl
141 50 81 src/moc_environment.tcl 154 55 88 src/moc_step.tcl 35 8 25 src/mod_background.tcl 439 165 254 src/mod_behave.tcl 175 92 75 src/mod_context.tcl 27 6 19 src/mod_description.tcl 116 16 90 src/mod_environment.tcl 77 39 34 src/mod_examples.tcl 182 119 56 src/mod_feature.tcl 210 112 85 src/mod_log.tcl
185 116 61 src/mod_scenario.tcl 34 7 25 src/mod_scenario_outline.tcl 141 63 72 src/mod_step.tcl 175 97 67 src/mod_table.tcl 144 71 67 src/mod_tags.tcl ----- ----- ----- ---------------------------- 4090 2080 1787 23
Tcltest test written to test the framework.
lines LOC #s file ----- ----- ----- ------------------------ 42 16 20 tst/all.tcl 365 301 13 tst/behave.test 80 57 11 tst/cmd_prequel.test 23 8 11 tst/mix_addin.test 258 210 16 tst/mix_gherkin.test 337 280 15 tst/mix_oblist.test 76 54 12 tst/mix_perform.test 600 546 11 tst/mod_behave.test
49 28 13 tst/mod_context.test 117 89 14 tst/mod_description.test 206 167 11 tst/mod_examples.test 132 99 17 tst/mod_feature.test 155 118 15 tst/mod_log.test 180 149 11 tst/mod_scenario.test 55 35 11 tst/mod_step.test 224 187 11 tst/mod_table.test 233 184 14 tst/mod_tags.test 3132 2528 226 17 --------------------
There are useful extensions to Gherkin
Tcl is a good platform for enhanced Gherkin