Skip to content

Commit

Permalink
Add a unit test for constructor with complicated multiline expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
FirentisTFW committed Nov 16, 2024
1 parent 56d852b commit f2735d0
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/test/dart_class_parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,41 @@ describe("parseLinesToConstructors", () => {
),
]);
});

test("with complicated multiline expressions in initializer list", () => {
const lines = [
" Loader.small(",
" this.active, {",
" super.key,",
" bool big = false,",
" required bool animated,",
" }) : semanticsLabel = List.filled(40, '*').join(",
" 'lala',",
" ),",
];
const classFields = [
new DartClassField("active", "bool"),
new DartClassField("semanticsLabel", "String"),
new DartClassField("text", "String"),
new DartClassField("icon", "IconData"),
];

expect(parseLinesToConstructors(lines, "Loader", classFields)).toEqual([
new DartClassConstructor(
true,
[
new DartClassConstructorField(
"active",
"bool",
DartClassConstructorFieldPositionType.positional
),
new DartClassConstructorField("big", "bool"),
new DartClassConstructorField("animated", "bool"),
],
"small"
),
]);
});
});

describe("factory constructor", () => {
Expand Down

0 comments on commit f2735d0

Please sign in to comment.