Skip to content

Commit 908d86f

Browse files
test: pin dense output around a negative operand
Add an exact-output assertion for the default dialect so the regression also proves the left side still denses ("a- -b" / "1- -1"), not just that no "--" forms. Kept the shared cross-dialect check invariant-only since dialects with dashed identifiers (e.g. BigQuery) keep the "-" spaced.
1 parent 3256b55 commit 908d86f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

test/sqlFormatter.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,19 @@ describe('sqlFormatter', () => {
8383
}).toThrow('commaPosition config is no more supported.');
8484
});
8585

86+
it('keeps the boundary space before a negative operand but stays dense elsewhere', () => {
87+
// The "--" that "a - -b" would dense into re-parses as a line comment, so that
88+
// one boundary keeps its space; everything else still denses ("a-" / "1-").
89+
expect(format('SELECT a - -b', { denseOperators: true })).toBe(dedent`
90+
SELECT
91+
a- -b
92+
`);
93+
expect(format('SELECT 1 - -1', { denseOperators: true })).toBe(dedent`
94+
SELECT
95+
1- -1
96+
`);
97+
});
98+
8699
describe('formatDialect()', () => {
87100
it('allows passing Dialect config object as a dialect parameter', () => {
88101
expect(formatDialect('SELECT [foo], `bar`;', { dialect: sqlite })).toBe(dedent`

0 commit comments

Comments
 (0)