Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gmickus committed Oct 30, 2024
1 parent 119223b commit 6f47c21
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 5 deletions.
12 changes: 12 additions & 0 deletions resources/functionalTests/using/6optional-statements/input.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* formatterSettingsOverride */
/* { "AblFormatter.usingFormatting": true,
"abl.completion.upperCase": false}*/

using Common.* from propath.
using Exceptions.* from propath.
using Framework.* from propath.
using Framework.Ccs.* from propath.
using Framework.Enum.* from propath.
using Framework.Exceptions.* from propath.
using Util.* from propath.
using Lang.* from propath.
12 changes: 12 additions & 0 deletions resources/functionalTests/using/6optional-statements/target.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* formatterSettingsOverride */
/* { "AblFormatter.usingFormatting": true,
"abl.completion.upperCase": false}*/

using Common.* from propath.
using Exceptions.* from propath.
using Framework.* from propath.
using Framework.Ccs.* from propath.
using Framework.Enum.* from propath.
using Framework.Exceptions.* from propath.
using Lang.* from propath.
using Util.* from propath.
11 changes: 11 additions & 0 deletions resources/functionalTests/using/6optional-statements2/input.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* formatterSettingsOverride */
/* { "AblFormatter.usingFormatting": true,
"abl.completion.upperCase": false}*/

using Alpha.Beta.* from propath.
using Gamma.Delta.* from propath.
using Epsilon.Zeta.* from propath.
using Theta.Iota.* from assembly.
using Kappa.Lambda.* from propath.
using Mu.Nu.* from propath.
using Xi.Omicron.* from assembly.
11 changes: 11 additions & 0 deletions resources/functionalTests/using/6optional-statements2/target.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* formatterSettingsOverride */
/* { "AblFormatter.usingFormatting": true,
"abl.completion.upperCase": false}*/

using Alpha.Beta.* from propath.
using Epsilon.Zeta.* from propath.
using Gamma.Delta.* from propath.
using Kappa.Lambda.* from propath.
using Mu.Nu.* from propath.
using Theta.Iota.* from assembly.
using Xi.Omicron.* from assembly.
11 changes: 11 additions & 0 deletions resources/functionalTests/using/6optional-statements3/input.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* formatterSettingsOverride */
/* { "AblFormatter.usingFormatting": true,
"abl.completion.upperCase": false}*/

using Alpha.Beta.* from propath.
using Gamma.Delta.* from propath.
using Epsilon.Zeta.* from propath.
using Theta.Iota.* from assembly.
using Kappa.Lambda.* from propath.
using Mu.Nu.* from propath.
using Xi.Omicron.* from assembly.
16 changes: 16 additions & 0 deletions resources/functionalTests/using/6optional-statements3/target.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* formatterSettingsOverride */
/* { "AblFormatter.usingFormatting": true,
"abl.completion.upperCase": false}*/

using Alpha.*.
using Alpha.Beta.* from propath.
using Beta.Gamma.*.
using Chi.Psi.Omega.* from propath.
using Delta.Epsilon.Zeta.Eta.* from propath.
using Epsilon.Zeta.* from assembly.
using Eta.Theta.* from propath.
using Gamma.Delta.* from propath.
using Kappa.Lambda.Mu.Nu.* from propath.
using Sigma.Tau.Upsilon.Phi.* from propath.
using Theta.Iota.* from propath.
using Xi.Omicron.Pi.Rho.* from propath.
11 changes: 6 additions & 5 deletions src/v2/formatters/using/UsingFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { IConfigurationManager } from "../../../utils/IConfigurationManager";
import { FormatterHelper } from "../../formatterFramework/FormatterHelper";
import { UsingSettings } from "./UsingSettings";
import { SyntaxNodeType } from "../../../model/SyntaxNodeType";
import { Options } from "vscode-extension-tester";

@RegisterFormatter
export class UsingFormatter extends AFormatter implements IFormatter {
Expand Down Expand Up @@ -83,7 +82,11 @@ export class UsingFormatter extends AFormatter implements IFormatter {
let optionalDefinitions = "";
this.alignOptionalStatements = Math.max(
this.alignOptionalStatements,
keyword.length + identifier.length
/* The format is this:
USING IDENTIFIER OPTIONAL_DEFINITIONS.
therefore we add +1 for the spaces between different parts.
*/
keyword.length + 1 + identifier.length + 1
);
if (node.childCount > 2) {
for (let i = 2; i < node.childCount; ++i) {
Expand Down Expand Up @@ -116,9 +119,7 @@ export class UsingFormatter extends AFormatter implements IFormatter {
return (
statement.identifier +
" ".repeat(
this.alignOptionalStatements -
statement.identifier.length +
1
this.alignOptionalStatements - statement.identifier.length
) +
statement.optionalDefinitions +
"."
Expand Down

0 comments on commit 6f47c21

Please sign in to comment.