hwhitespace

This commit is contained in:
Chris Wanstrath 2025-11-25 11:30:27 -08:00 committed by Chris Wanstrath
parent e38e8d4f1e
commit 3eac0a27a5
4 changed files with 11 additions and 11 deletions

View File

@ -23,15 +23,15 @@ describe('multi line function blocks', () => {
test('work with no args', () => { test('work with no args', () => {
expect(` expect(`
trap = do x: x end trap = do x: x end
trap: trap:
true true
end`).toEvaluateTo(true) end`).toEvaluateTo(true)
}) })
test('work with one arg', () => { test('work with one arg', () => {
expect(` expect(`
trap = do x y: [ x (y) ] end trap = do x y: [ x (y) ] end
trap EXIT: trap EXIT:
true true
end`).toEvaluateTo(['EXIT', true]) end`).toEvaluateTo(['EXIT', true])
}) })
@ -39,7 +39,7 @@ end`).toEvaluateTo(['EXIT', true])
test('work with named args', () => { test('work with named args', () => {
expect(` expect(`
attach = do signal fn: [ signal (fn) ] end attach = do signal fn: [ signal (fn) ] end
attach signal='exit': attach signal='exit':
true true
end`).toEvaluateTo(['exit', true]) end`).toEvaluateTo(['exit', true])
}) })
@ -48,8 +48,8 @@ end`).toEvaluateTo(['exit', true])
test('work with dot-get', () => { test('work with dot-get', () => {
expect(` expect(`
signals = [trap=do x y: [x (y)] end] signals = [trap=do x y: [x (y)] end]
signals.trap 'EXIT': signals.trap 'EXIT':
true true
end`).toEvaluateTo(['EXIT', true]) end`).toEvaluateTo(['EXIT', true])
}) })
}) })

View File

@ -63,7 +63,7 @@ describe('calling functions', () => {
Identifier tail Identifier tail
NamedArg NamedArg
NamedArgPrefix lines= NamedArgPrefix lines=
`) `)
}) })
}) })
@ -73,7 +73,7 @@ describe('Do', () => {
expect('do: 1 end').toMatchTree(` expect('do: 1 end').toMatchTree(`
FunctionDef FunctionDef
Do do Do do
Params Params
colon : colon :
Number 1 Number 1
keyword end`) keyword end`)

View File

@ -76,12 +76,12 @@ end
expect(` expect(`
do: do:
2 2
end end
`).toMatchTree(` `).toMatchTree(`
FunctionDef FunctionDef
Do do Do do
Params Params
colon : colon :
Number 2 Number 2
keyword end keyword end

View File

@ -12,7 +12,7 @@ const nodeToString = (node: SyntaxNode, input: string, depth = 0): string => {
} else { } else {
// Only strip quotes from whole String nodes (legacy DoubleQuote), not StringFragment/EscapeSeq/CurlyString // Only strip quotes from whole String nodes (legacy DoubleQuote), not StringFragment/EscapeSeq/CurlyString
const cleanText = nodeName === 'String' ? text.slice(1, -1) : text const cleanText = nodeName === 'String' ? text.slice(1, -1) : text
return `${indent}${nodeName} ${cleanText}` return cleanText ? `${indent}${nodeName} ${cleanText}` : `${indent}${nodeName}`
} }
} }