Files
tree-sitter-shellspec/test/spec/15.data_helper_spec.sh
Ismo Vuorinen c8ba576b4e feat: implement complete tree-sitter-shellspec grammar with comprehensive testing
- Add full ShellSpec grammar extending tree-sitter-bash
- Support all ShellSpec constructs: Describe, Context, It, hooks, utilities
- Include Data block parsing with statements and argument styles
- Add 61 comprehensive test cases covering real-world patterns
- Implement optimized GitHub workflows with CI/CD automation
- Configure complete development tooling (linting, formatting, pre-commit)
- Add comprehensive documentation and contribution guidelines
- Optimize grammar conflicts to zero warnings
- Support editor integration for Neovim, VS Code, Emacs

Breaking Changes:
- Initial release, no previous API to break

BREAKING CHANGE: Initial implementation of tree-sitter-shellspec grammar

# Conflicts:
#	.github/workflows/codeql.yml
#	.github/workflows/pr-lint.yml
#	.pre-commit-config.yaml

# Conflicts:
#	.github/workflows/pr-lint.yml

# Conflicts:
#	.github/workflows/pr-lint.yml
2026-01-04 15:32:39 +02:00

86 lines
1.9 KiB
Bash

#shellcheck shell=sh disable=SC2016
# Data helper is easy way to input data from stdin for evaluation.
# Removes `#|` from the beginning of the each line in the Data helper,
# the rest is the input data.
Describe 'Data helper'
Example 'provide with Data helper block style'
Data
#|item1 123
#|item2 456
#|item3 789
End
When call awk '{total+=$2} END{print total}'
The output should eq 1368
End
Example 'provide string with Data helper'
Data '123 + 456 + 789'
When call bc
The output should eq 1368
End
Example 'provide from function with Data helper'
data() {
echo item1 123
echo item2 456
echo item3 789
}
Data data
When call awk '{total+=$2} END{print total}'
The output should eq 1368
End
Describe 'Data helper with filter'
Example 'from block'
Data | tr 'abc' 'ABC'
#|aaa
#|bbb
End
When call cat -
The first line of output should eq 'AAA'
The second line of output should eq 'BBB'
End
Example 'from function'
foo() { printf '%s\n' "$@"; }
Data foo a b c | tr 'abc' 'ABC' # comment
When call cat -
The first line of output should eq 'A'
The second line of output should eq 'B'
The third line of output should eq "C"
The lines of entire output should eq 3
End
Example 'from string'
Data 'abc'| tr 'abc' 'ABC' # comment
When call cat -
The output should eq ABC
End
End
Describe 'variable expansion'
Before 'item=123'
Example 'not expand variable (default)'
Data:raw
#|item $item
End
When call cat -
The output should eq 'item $item'
End
Example 'expand variable'
Data:expand
#|item $item
End
When call cat -
The output should eq 'item 123'
End
# variable expansion is supported by block style only.
End
End