test(parser): add tests for pipe expressions

Added three parser tests to verify pipe expressions parse correctly:
- Simple two-stage pipe (echo hello | grep h)
- Multi-stage pipe chain (find files | filter active | sort)
- Pipe with identifiers (get-value | process)

All tests pass and verify the PipeExpr grammar rules work as expected.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Corey Johnson 2025-10-12 16:46:18 -07:00
parent 71b1744c08
commit 48be677ea9

View File

@ -537,6 +537,52 @@ describe('if/elsif/else', () => {
})
})
describe('pipe expressions', () => {
test('simple pipe expression', () => {
expect('echo hello | grep h').toMatchTree(`
PipeExpr
FunctionCall
Identifier echo
PositionalArg
Identifier hello
operator |
FunctionCall
Identifier grep
PositionalArg
Identifier h
`)
})
test('multi-stage pipe chain', () => {
expect('find files | filter active | sort').toMatchTree(`
PipeExpr
FunctionCall
Identifier find
PositionalArg
Identifier files
operator |
FunctionCall
Identifier filter
PositionalArg
Identifier active
operator |
FunctionCallOrIdentifier
Identifier sort
`)
})
test('pipe with identifier', () => {
expect('get-value | process').toMatchTree(`
PipeExpr
FunctionCallOrIdentifier
Identifier get-value
operator |
FunctionCallOrIdentifier
Identifier process
`)
})
})
describe('multiline', () => {
test('parses multiline strings', () => {
expect(`'first'\n'second'`).toMatchTree(`