Skip to content

Commit

Permalink
Add Parameters:value
Browse files Browse the repository at this point in the history
  • Loading branch information
ko1nksm committed Aug 14, 2019
1 parent 884f62c commit 4444694
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/libexec/grammar.sh
Expand Up @@ -69,6 +69,7 @@ mapping() {
Parameters:block ) parameters block "$2" ;;
Parameters:dynamic) parameters dynamic "$2" ;;
Parameters:matrix ) parameters matrix "$2" ;;
Parameters:value ) parameters value "$2" ;;
Include ) include "$2" ;;
%text ) text_begin raw "$2" ;;
%text:raw ) text_begin raw "$2" ;;
Expand Down
20 changes: 20 additions & 0 deletions lib/libexec/translator.sh
Expand Up @@ -316,6 +316,26 @@ parameters_matrix_code() {
code="${code}${1}${LF}"
}

parameters_value() {
trans parameters_begin

code=''
trim line "$line"
parameters_matrix_code "for shellspex_matrix in ${line#* }"
until case $line in (*\\) false; esac; do
lineno=$(($lineno + 1))
IFS= read -r line
parameters_matrix_code "$line"
done
parameters_matrix_code "do"
trans parameters "\"\$shellspex_matrix\""
code="${code}count=\$((\$count + 1))${LF}"
parameters_matrix_code "done"

eval "parameter_count=\$(count=0${LF}${code}echo \"\$count\")"
trans parameters_end "$parameter_count"
}

constant() {
if [ "$_block_no_stack" ]; then
syntax_error "Constant should be defined outside of Example Group/Example"
Expand Down
9 changes: 9 additions & 0 deletions spec/core/dsl/parameters_spec.sh
Expand Up @@ -49,4 +49,13 @@ Describe 'Parameters helper'
The output should be present
End
End

Describe 'value style'
Parameters:value foo bar baz

It "example $1"
When call echo "$1"
The output should be present
End
End
End

0 comments on commit 4444694

Please sign in to comment.