feat(format): Doc-IR core, line_width (120) and where_wrap when_long

This commit is contained in:
Hein
2026-10-06 14:44:45 +02:00
parent 4ff729eeeb
commit 553609e988
7 changed files with 257 additions and 2 deletions
+21
View File
@@ -611,3 +611,24 @@ func TestDMLRecordSpaceBeforeParen(t *testing.T) {
t.Errorf("row() space_before_paren not idempotent:\n--- once ---\n%s\n--- twice ---\n%s", gotSpaced, twice)
}
}
func TestWhereWhenLong(t *testing.T) {
src := "select a from t where a = 1 and b = 2"
st := config.Default()
st.WhereWrap = config.WrapWhenLong
st.LineWidth = 80
short := File(parser.Parse(src), st)
if !strings.Contains(short, "WHERE a = 1 AND b = 2") {
t.Errorf("short clause should stay on one line:\n%s", short)
}
st.LineWidth = 12
long := File(parser.Parse(src), st)
if strings.Contains(long, "WHERE a = 1") || !strings.Contains(long, "AND b = 2") {
t.Errorf("long clause should break per condition:\n%s", long)
}
st.WhereWrap = config.WrapAlways
want := File(parser.Parse(src), st)
if long != want {
t.Errorf("broken when_long should equal always:\n%s\n---\n%s", long, want)
}
}