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 @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Added support for Delphi 13 `noreturn` directive.
- Added support for Delphi 13 `unmanaged` generic constraint.
- Added support for `if else` ternary expressions.

## [0.7.0] - 2025-11-11

Expand Down
1 change: 1 addition & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added support for Delphi 13 `noreturn` directive.
- Added `KeywordKind::is_generic_constraint`.
- Added support for Delphi 13 `unmanaged` generic constraint.
- Added support for `if else` ternary expressions.

## 0.7.0 - 2025-11-11

Expand Down
20 changes: 20 additions & 0 deletions core/datatests/generators/logical_line_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub fn generate_test_files(root_dir: &Path) {
routine_implementations::generate(root_dir);
control_flows::generate(root_dir);
statements::generate(root_dir);
ternary::generate(root_dir);
attributes::generate(root_dir);
semicolons::generate(root_dir);
regression::generate(root_dir);
Expand Down Expand Up @@ -3258,6 +3259,25 @@ mod statements {
}
}

mod ternary {
use super::*;

pub fn generate(root_dir: &Path) {
generate_test_cases!(
root_dir,
assignment = "
_|A := if A then B else C;
",
nested = "
_|A := if if A then B else C then
if A then B else C
else
if A then B else C;
",
);
}
}

mod attributes {
use super::*;

Expand Down
192 changes: 187 additions & 5 deletions core/datatests/generators/optimising_line_formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,31 @@ mod comments {
and FFFFFFFFFFFF then
;
",
ternary = "
Comment thread
jgardn3r marked this conversation as resolved.
A :=
if A then
B
else //
if C then D else E;
A :=
if A then
B
else //
if CCCCC then
D
else
E;
A :=
if A then
B
else //
if C then
DDDDD //
else if a then
E
else
d;
",
);
}
}
Expand Down Expand Up @@ -3019,16 +3044,16 @@ mod control_flows {
inline = "
if A then
else if AAAAAA and BBBBBB then
Bar;
Bar
else if AAAAAAAAA
and BBBBBBBBB then
Bar;
Bar
else if AAAAAAAAAA
and BBBBBBBBBB
and CCCCCCCCCC then
Bar;
Bar
else if Foo(AAA, BB, CCC) then
Bar;
Bar
else if Foo(
AAAA,
BBBBBB,
Expand Down Expand Up @@ -3058,7 +3083,7 @@ mod control_flows {
end
else if AA(A, B, C) then begin
Bar;
end;
end
else if AAA(AAA, BB, CCC) then
begin
Bar;
Expand Down Expand Up @@ -4244,6 +4269,7 @@ mod expressions {
unary::generate(root_dir);
set::generate(root_dir);
strings::generate(root_dir);
ternary::generate(root_dir);
}

mod boolean {
Expand Down Expand Up @@ -4865,6 +4891,162 @@ mod expressions {
);
}
}

mod ternary {
use super::*;

pub fn generate(root_dir: &Path) {
generate_test_cases!(
root_dir,
basic_assignment = "
A := if B then C else D;
AAAAAAAA :=
if B then C else D;
AAAAAAAA :=
if BBBBBBB then
CC
else
DD;
",
nested_must_wrap = "
// wrap_column=41 |
// A := if B then if C then D else E else F;
A :=
if B then
if C then D else E
else
F;
",
nested = "
A :=
if B then
if CCCCC then D else E
else
F;
A :=
if B then
if CCCCCC then
D
else
E
else
F;
A :=
if BBBBBBB + BBBBBBBB then
if CCCCCC + CCCCC then
DDDDDDDDDD + DDDDD
else
EEEEEEEEE + EEEEEE
else
FFFFFFFF + FFFFFFFFFF;
A :=
if BBBBBBBB
+ BBBBBBBB then
if CCCCC + CCCCCC then
DDDDDDDDDD + DDDDD
else
EEEEEEEEE + EEEEEE
else
FFFFFFFF + FFFFFFFFFF;
A :=
if BBBBBBB + BBBBBBBB then
if CCCCCCC
+ CCCCCCC then
DDDDDDDDDD + DDDDD
else
EEEEEEEEE + EEEEEE
else
FFFFFFFF + FFFFFFFFFF;
A :=
if BBBBBBB + BBBBBBBB then
if CCCCC + CCCCCC then
DDDDDDDDDD
+ DDDDDD
else
EEEEEEEEE + EEEEEE
else
FFFFFFFF + FFFFFFFFFF;
A :=
if BBBBBBB + BBBBBBBB then
if CCCCC + CCCCCC then
DDDDDDDDDD + DDDDD
else
EEEEEEEEE
+ EEEEEEE
else
FFFFFFFF + FFFFFFFFFF;
A :=
if BBBBBBB + BBBBBBBB then
if CCCCCC + CCCCC then
DDDDDDDDDD + DDDDD
else
EEEEEEEEE + EEEEEE
else
FFFFFFFFF
+ FFFFFFFFFF;
A :=
if BBBBBBBB
+ BBBBBBBB then
if CCCCCC
+ CCCCCC then
DDDDDDDDDD + DDDDD
else
EEEEEEEEE
+ EEEEEEE
else
FFFFFFFFF + FFFFFFFFF;
",
anonymous = "
AAAAAAAA :=
if BBBBBBB then
(procedure
begin
A := B;
B := A;
end)()
else
(procedure
begin
A := B;
B := A;
end)();
AAAAAAAA :=
if BBBBBBB then
if True then
(procedure
begin
A := B;
B := A;
end)()
else
(procedure
begin
A := B;
B := A;
end)()
else if True then
(procedure
begin
A := B;
B := A;
end)()
else //
if True then
(procedure
begin
A := B;
B := A;
end)()
else
(procedure
begin
A := B;
B := A;
end)();
",
);
}
}
}

mod attributes {
Expand Down
Loading
Loading