Skip to content

Actual parameter position is inconsistent across the new assertions #2933

Description

@nohwnd

The Actual parameter sits at a different position depending on the assertion.

Two argument assertions use [Parameter(Position = 1, ValueFromPipeline = $true)] $Actual with Expected at Position = 0. But the single subject assertions are not consistent:

  • the Boolean ones (Should-BeTrue, Should-BeFalse, Should-BeTruthy, Should-BeFalsy) have no Position at all, so Should-BeTrue $x does not bind,
  • Should-BeEmptyString uses Position = 0,
  • Should-BeNull uses Position = 1 even though there is no Position = 0 parameter,
  • Should-BeAfter and Should-BeBefore put Actual at Position = 2.

Pick one rule for single subject assertions (Actual at Position = 0 with ValueFromPipeline) and apply it, so passing Actual positionally works and the position does not jump around.

Part of the new Should-* assertion consistency audit, see #2874.

🤖

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions