Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fixed parsing of logical lines with sequential `<` and `>` comparisons.
- Fixed formatting of `interface` as a generic constraint.
- Fixed formatting of comments in directive blocks.
- Fixed formatting of comments after statements without semicolons.

### Added

Expand Down
1 change: 1 addition & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed parsing of logical lines with sequential `<` and `>` comparisons.
- Fixed formatting of `interface` as a generic constraint.
- Fixed formatting of comments in directive blocks.
- Fixed formatting of comments after statements without semicolons.

### Added

Expand Down
141 changes: 141 additions & 0 deletions core/datatests/generators/logical_line_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ mod comments {
pub fn generate(root_dir: &Path) {
inline::generate(root_dir);
individual::generate(root_dir);
before_context_end::generate(root_dir);
}

mod inline {
Expand Down Expand Up @@ -509,6 +510,146 @@ mod comments {
);
}
}

mod before_context_end {
use super::*;

pub fn generate(root_dir: &Path) {
generate_test_cases!(
root_dir,
compound = "
_|begin
_| A := B + C
_| //
_|end
",
compound_with_conditional = "
_|begin
_|{$IFDEF A}
_| A := B + C
_|{$ENDIF}
_| //
_|end
",
anonymous = "
_1 |A := procedure
_1 |begin{1}
_^1 | A := B + C
_^1 | //
_1 |end;
",
if_else = "
_ |begin
_1 | if A then{1}
_^1 | A := B + C
_^1 | //
_1 | else{2}
_^2 | B := C + D
_ | //
_ |end
Comment thread
jgardn3r marked this conversation as resolved.
",
if_else_begin = "
_ |begin
_1 | if A then{1}
_^1 | //
_^1 | begin
_^1 | //
_^1 | end
_1 | else{2}
_^2 | B := C + D
_ | //
_ |end
",
for_in = "
_ |begin
_1 | for A in B do{1}
_^1 | A := B + C
_ | //
_ |end
",
for_to = "
_ |begin
_1 | for A := B to C do{1}
_^1 | A := B + C
_ | //
_ |end
",
while_do = "
_ |begin
_1 | while A do{1}
_^1 | A := B + C
_ | //
_ |end
",
initialization_finalization = "
_|initialization
_| A := B + C
_| //
_|finalization
_| A := B + C
_| //
_|end.
",
initialization = "
_|initialization
_| A := B + C
_| //
_|end.
",
case = "
_ |case A of
_1 | B:{1}
_^1| A := B + C
_ | //
_ |end.
",
case_else = "
_ |case A of
_1 | B:{1}
_^1| A := B + C
_ | //
_ |else
_ | A := B + C
_ | //
_ |end.
",
repeat = "
_|repeat
_| A := B + C
_| //
_|until False;
",
try_except = "
_ |try
_ | A := B + C
_ | //
_ |except
_1 | on A do{1}
_^1| A := B + C
_ | //
_ |end;
",
try_bare_except = "
_|try
_| A := B + C
_| //
_|except
_| A := B + C
_| //
_|end;
",
try_finally = "
_|try
_| A := B + C
_| //
_|finally
_| A := B + C
_| //
_|end;
",
);
}
}
}

mod child_lines {
Expand Down
191 changes: 191 additions & 0 deletions core/datatests/generators/optimising_line_formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ mod comments {
conditional_directives::generate(root_dir);
individual_block::generate(root_dir);
compound_operators::generate(root_dir);
before_context_end::generate(root_dir);
}

mod midline_line {
Expand Down Expand Up @@ -559,6 +560,25 @@ mod comments {
end
);
",
anonymous_content = "
A(
procedure
begin
//
end,
procedure
begin
A
//
end,
procedure
begin
A;
//
A
end,
);
",
if_else = "
if AAAAAA then //
BBBBBBB;
Expand All @@ -579,6 +599,32 @@ mod comments {
else //
begin
end;
if A then
//
begin
//
end
//
;
if A then
//
begin
A
//
end
//
;
if A then begin
//
end
//
;
if A then begin
A
//
end
//
;
",
after_do = "
try
Expand Down Expand Up @@ -744,6 +790,151 @@ mod comments {
);
}
}

mod before_context_end {
use super::*;

pub fn generate(root_dir: &Path) {
generate_test_cases!(
root_dir,
compound = "
begin
A := B + C
//
end
",
compound_with_conditional = "
begin
{$IFDEF A}
A := B + C
{$ENDIF}
//
end
",
if_else = "
begin
if A then begin
A := B + C
end

//
else
B := C + D;
if A then //
begin
A := B + C
end

//
else
B := C + D;
if A then
//
begin
A := B + C
end

//
else
B := C + D;
if A then
A := B + C

//
else
B := C + D

//
end
",
for_in = "
begin
for A in B do
A := B + C
//
end
",
for_to = "
begin
for A := B to C do
A := B + C
//
end
",
while_do = "
begin
while A do
A := B + C
//
end
",
initialization_finalization = "
initialization
A := B + C
//
finalization
A := B + C
//
end.
",
initialization = "
initialization
A := B + C
//
end.
",
case = "
case A of
B: A := B + C
//
end.
",
case_else = "
case A of
B: A := B + C
//
else
A := B + C
//
end.
",
repeat = "
repeat
A := B + C
//
until False;
",
try_except = "
try
A := B + C
//
except
on A do
A := B + C
//
end;
",
try_bare_except = "
try
A := B + C
//
except
A := B + C
//
end;
",
try_finally = "
try
A := B + C
//
finally
A := B + C
//
end;
",
);
}
}
}

mod anonymous {
Expand Down
Loading
Loading