From 37badac1d2add41c3f5c1449b5d3d8f119e46fab Mon Sep 17 00:00:00 2001 From: MayerTim Date: Wed, 10 Jun 2026 23:17:36 +0200 Subject: [PATCH] test(formatter): add metadata boundary corpus guards --- ...tadata-inline-header-boundary.expected.sql | 15 ++++++++++ .../metadata-inline-header-boundary.input.sql | 15 ++++++++++ ...ata-multiple-headers-boundary.expected.sql | 30 +++++++++++++++++++ ...tadata-multiple-headers-boundary.input.sql | 30 +++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 test/corpus/watcom/metadata-inline-header-boundary.expected.sql create mode 100644 test/corpus/watcom/metadata-inline-header-boundary.input.sql create mode 100644 test/corpus/watcom/metadata-multiple-headers-boundary.expected.sql create mode 100644 test/corpus/watcom/metadata-multiple-headers-boundary.input.sql diff --git a/test/corpus/watcom/metadata-inline-header-boundary.expected.sql b/test/corpus/watcom/metadata-inline-header-boundary.expected.sql new file mode 100644 index 0000000..ba44f9b --- /dev/null +++ b/test/corpus/watcom/metadata-inline-header-boundary.expected.sql @@ -0,0 +1,15 @@ +CREATE PROCEDURE "fct"."metadata_boundary"() +-- METADATA +-- Description : Keeps CREATE PROCEDURE text in metadata comments untouched. +-- Version : 1.0 +-- Author : Test Author +-- Updated By : Test Author +-- Created : 2026-06-10 +-- Updated : 2026-06-10 +-- History : +-- v1.0: Initial creation mentions SELECT FROM WHERE - 2026-06-10 Test Author +-- METADATA END +BEGIN + SELECT 'CREATE PROCEDURE dbo.fake_object() should stay literal' AS description; + -- CREATE FUNCTION dbo.fake_comment() should stay comment text +END; diff --git a/test/corpus/watcom/metadata-inline-header-boundary.input.sql b/test/corpus/watcom/metadata-inline-header-boundary.input.sql new file mode 100644 index 0000000..63a1c74 --- /dev/null +++ b/test/corpus/watcom/metadata-inline-header-boundary.input.sql @@ -0,0 +1,15 @@ +create procedure "fct"."metadata_boundary"() +-- METADATA +-- Description : Keeps CREATE PROCEDURE text in metadata comments untouched. +-- Version : 1.0 +-- Author : Test Author +-- Updated By : Test Author +-- Created : 2026-06-10 +-- Updated : 2026-06-10 +-- History : +-- v1.0: Initial creation mentions SELECT FROM WHERE - 2026-06-10 Test Author +-- METADATA END +begin +select 'CREATE PROCEDURE dbo.fake_object() should stay literal' as description; +-- CREATE FUNCTION dbo.fake_comment() should stay comment text +end; diff --git a/test/corpus/watcom/metadata-multiple-headers-boundary.expected.sql b/test/corpus/watcom/metadata-multiple-headers-boundary.expected.sql new file mode 100644 index 0000000..8790f45 --- /dev/null +++ b/test/corpus/watcom/metadata-multiple-headers-boundary.expected.sql @@ -0,0 +1,30 @@ +-- CREATE PROCEDURE dbo.comment_decoy() should not affect metadata boundaries +CREATE PROCEDURE dbo.first_metadata_boundary() +-- METADATA +-- Description : First object header mentions CREATE FUNCTION as prose. +-- Version : 1.0 +-- Author : First Author +-- Updated By : First Author +-- Created : 2026-06-10 +-- Updated : 2026-06-10 +-- History : +-- v1.0: Created before the second metadata header - 2026-06-10 First Author +-- METADATA END +BEGIN + SELECT 1; +END; + +CREATE FUNCTION dbo.second_metadata_boundary() RETURNS integer +-- METADATA +-- Description : Second object header mentions CREATE TRIGGER as prose. +-- Version : 1.0 +-- Author : Second Author +-- Updated By : Second Author +-- Created : 2026-06-10 +-- Updated : 2026-06-10 +-- History : +-- v1.0: Created after the first metadata header - 2026-06-10 Second Author +-- METADATA END +BEGIN + RETURN 2; +END; diff --git a/test/corpus/watcom/metadata-multiple-headers-boundary.input.sql b/test/corpus/watcom/metadata-multiple-headers-boundary.input.sql new file mode 100644 index 0000000..0e2ff0d --- /dev/null +++ b/test/corpus/watcom/metadata-multiple-headers-boundary.input.sql @@ -0,0 +1,30 @@ +-- CREATE PROCEDURE dbo.comment_decoy() should not affect metadata boundaries +create procedure dbo.first_metadata_boundary() +-- METADATA +-- Description : First object header mentions CREATE FUNCTION as prose. +-- Version : 1.0 +-- Author : First Author +-- Updated By : First Author +-- Created : 2026-06-10 +-- Updated : 2026-06-10 +-- History : +-- v1.0: Created before the second metadata header - 2026-06-10 First Author +-- METADATA END +begin +select 1; +end; + +create function dbo.second_metadata_boundary() returns integer +-- METADATA +-- Description : Second object header mentions CREATE TRIGGER as prose. +-- Version : 1.0 +-- Author : Second Author +-- Updated By : Second Author +-- Created : 2026-06-10 +-- Updated : 2026-06-10 +-- History : +-- v1.0: Created after the first metadata header - 2026-06-10 Second Author +-- METADATA END +begin +return 2; +end;