This repository has been archived by the owner on Aug 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #253 from Trivadis/bugfix/issue-249-format-globals…
…-in-package-spec Align contants and variables in package spec
- Loading branch information
Showing
2 changed files
with
153 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
...com/trivadis/plsql/formatter/settings/tests/issues/Issue_249_globals_in_package_spec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package com.trivadis.plsql.formatter.settings.tests.issues; | ||
|
||
import com.trivadis.plsql.formatter.settings.ConfiguredTestFormatter; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
|
||
import java.io.IOException; | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
public class Issue_249_globals_in_package_spec extends ConfiguredTestFormatter { | ||
@Test | ||
public void constants_only() throws IOException { | ||
var input = """ | ||
create or replace package x as | ||
co_aaaa constant char := 'a'; | ||
co_b constant char := 'b'; | ||
co_cccccccccc constant char := 'c'; | ||
end; | ||
/ | ||
create or replace package body x as | ||
co_aaaa constant char := 'a'; | ||
co_b constant char := 'b'; | ||
co_cccccccccc constant char := 'c'; | ||
end; | ||
/ | ||
"""; | ||
var expected = """ | ||
create or replace package x as | ||
co_aaaa constant char := 'a'; | ||
co_b constant char := 'b'; | ||
co_cccccccccc constant char := 'c'; | ||
end; | ||
/ | ||
create or replace package body x as | ||
co_aaaa constant char := 'a'; | ||
co_b constant char := 'b'; | ||
co_cccccccccc constant char := 'c'; | ||
end; | ||
/ | ||
"""; | ||
var actual = getFormatter().format(input); | ||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
public void variables_only() throws IOException { | ||
var input = """ | ||
create or replace package x as | ||
l_aaaa char := 'a'; | ||
l_b char := 'b'; | ||
l_cccccccccc char := 'c'; | ||
end; | ||
/ | ||
create or replace package body x as | ||
l_aaaa char := 'a'; | ||
l_b char := 'b'; | ||
l_cccccccccc char := 'c'; | ||
end; | ||
/ | ||
"""; | ||
var expected = """ | ||
create or replace package x as | ||
l_aaaa char := 'a'; | ||
l_b char := 'b'; | ||
l_cccccccccc char := 'c'; | ||
end; | ||
/ | ||
create or replace package body x as | ||
l_aaaa char := 'a'; | ||
l_b char := 'b'; | ||
l_cccccccccc char := 'c'; | ||
end; | ||
/ | ||
"""; | ||
var actual = getFormatter().format(input); | ||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
public void constants_and_variables() throws IOException { | ||
var input = """ | ||
create or replace package x as | ||
co_aaaa constant char := 'a'; | ||
co_b constant char := 'b'; | ||
co_cccccccccc constant char := 'c'; | ||
l_aaaa char := 'a'; | ||
l_b char := 'b'; | ||
l_cccccccccc char := 'c'; | ||
end; | ||
/ | ||
create or replace package body x as | ||
co_aaaa constant char := 'a'; | ||
co_b constant char := 'b'; | ||
co_cccccccccc constant char := 'c'; | ||
l_aaaa char := 'a'; | ||
l_b char := 'b'; | ||
l_cccccccccc char := 'c'; | ||
end; | ||
/ | ||
"""; | ||
var expected = """ | ||
create or replace package x as | ||
co_aaaa constant char := 'a'; | ||
co_b constant char := 'b'; | ||
co_cccccccccc constant char := 'c'; | ||
l_aaaa char := 'a'; | ||
l_b char := 'b'; | ||
l_cccccccccc char := 'c'; | ||
end; | ||
/ | ||
create or replace package body x as | ||
co_aaaa constant char := 'a'; | ||
co_b constant char := 'b'; | ||
co_cccccccccc constant char := 'c'; | ||
l_aaaa char := 'a'; | ||
l_b char := 'b'; | ||
l_cccccccccc char := 'c'; | ||
end; | ||
/ | ||
"""; | ||
var actual = getFormatter().format(input); | ||
assertEquals(expected, actual); | ||
} | ||
} |