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:
parent
71b1744c08
commit
48be677ea9
|
|
@ -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', () => {
|
describe('multiline', () => {
|
||||||
test('parses multiline strings', () => {
|
test('parses multiline strings', () => {
|
||||||
expect(`'first'\n'second'`).toMatchTree(`
|
expect(`'first'\n'second'`).toMatchTree(`
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user