From 0ff5b2f4a63ff8a66103d0748bafb26fd58e0626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Fri, 31 Jul 2026 17:20:14 +0200 Subject: [PATCH 1/2] Fix #2931: make Expected mandatory in Should-NotBeString, Should-BeFasterThan and Should-BeSlowerThan --- src/functions/assert/String/Should-NotBeString.ps1 | 2 +- src/functions/assert/Time/Should-BeFasterThan.ps1 | 2 +- src/functions/assert/Time/Should-BeSlowerThan.ps1 | 2 +- tst/functions/assert/String/Should-NotBeString.Tests.ps1 | 5 +++++ tst/functions/assert/Time/Should-BeFasterThan.Tests.ps1 | 5 +++++ tst/functions/assert/Time/Should-BeSlowerThan.Tests.ps1 | 5 +++++ 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/functions/assert/String/Should-NotBeString.ps1 b/src/functions/assert/String/Should-NotBeString.ps1 index 1797b9ad8..a9f5b3f3c 100644 --- a/src/functions/assert/String/Should-NotBeString.ps1 +++ b/src/functions/assert/String/Should-NotBeString.ps1 @@ -57,7 +57,7 @@ function Should-NotBeString { param ( [Parameter(Position = 1, ValueFromPipeline = $true)] $Actual, - [Parameter(Position = 0)] + [Parameter(Position = 0, Mandatory)] [String]$Expected, [String]$Because, [switch]$CaseSensitive, diff --git a/src/functions/assert/Time/Should-BeFasterThan.ps1 b/src/functions/assert/Time/Should-BeFasterThan.ps1 index 450df6629..826f2b9dd 100644 --- a/src/functions/assert/Time/Should-BeFasterThan.ps1 +++ b/src/functions/assert/Time/Should-BeFasterThan.ps1 @@ -47,7 +47,7 @@ param ( [Parameter(Position = 1, ValueFromPipeline = $true)] $Actual, - [Parameter(Position = 0)] + [Parameter(Position = 0, Mandatory)] $Expected, [string] $Because ) diff --git a/src/functions/assert/Time/Should-BeSlowerThan.ps1 b/src/functions/assert/Time/Should-BeSlowerThan.ps1 index ef40c0892..2558597f2 100644 --- a/src/functions/assert/Time/Should-BeSlowerThan.ps1 +++ b/src/functions/assert/Time/Should-BeSlowerThan.ps1 @@ -54,7 +54,7 @@ param ( [Parameter(Position = 1, ValueFromPipeline = $true)] $Actual, - [Parameter(Position = 0)] + [Parameter(Position = 0, Mandatory)] $Expected, [string] $Because ) diff --git a/tst/functions/assert/String/Should-NotBeString.Tests.ps1 b/tst/functions/assert/String/Should-NotBeString.Tests.ps1 index 1e0d041a6..3211310be 100644 --- a/tst/functions/assert/String/Should-NotBeString.Tests.ps1 +++ b/tst/functions/assert/String/Should-NotBeString.Tests.ps1 @@ -60,5 +60,10 @@ Describe "Should-NotBeString" { $err = { Should-NotBeString -Expected "abc" -Actual 1 } | Verify-Throw $err.Exception | Verify-Type ([ArgumentException]) } + + It "Requires Expected" { + $err = { "abc" | Should-NotBeString } | Verify-Throw + $err.Exception | Verify-Type ([System.Management.Automation.ParameterBindingException]) + } } diff --git a/tst/functions/assert/Time/Should-BeFasterThan.Tests.ps1 b/tst/functions/assert/Time/Should-BeFasterThan.Tests.ps1 index d13b0d5b1..0e8099363 100644 --- a/tst/functions/assert/Time/Should-BeFasterThan.Tests.ps1 +++ b/tst/functions/assert/Time/Should-BeFasterThan.Tests.ps1 @@ -54,4 +54,9 @@ Describe "Should-BeFasterThan" { $err = { $Actual | Should-BeFasterThan -Expected $Expected -Because $Because } | Verify-AssertionFailed $err.Exception.Message | Verify-Like '*because I said so*' } + + It "Requires Expected" { + $err = { [timespan]::FromMilliseconds(1) | Should-BeFasterThan } | Verify-Throw + $err.Exception | Verify-Type ([System.Management.Automation.ParameterBindingException]) + } } diff --git a/tst/functions/assert/Time/Should-BeSlowerThan.Tests.ps1 b/tst/functions/assert/Time/Should-BeSlowerThan.Tests.ps1 index 080265d7e..c5458f243 100644 --- a/tst/functions/assert/Time/Should-BeSlowerThan.Tests.ps1 +++ b/tst/functions/assert/Time/Should-BeSlowerThan.Tests.ps1 @@ -31,4 +31,9 @@ Describe "Should-BeSlowerThan" { $err = { $Actual | Should-BeSlowerThan -Expected $Expected -Because $Because } | Verify-AssertionFailed $err.Exception.Message | Verify-Like '*because I said so*' } + + It "Requires Expected" { + $err = { [timespan]::FromMilliseconds(1) | Should-BeSlowerThan } | Verify-Throw + $err.Exception | Verify-Type ([System.Management.Automation.ParameterBindingException]) + } } From 0775fc40831356aa45c9c949d0f1d82d6ff016a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Fri, 31 Jul 2026 18:28:44 +0200 Subject: [PATCH 2/2] Retrigger CI (macOS_14 leg cancelled, infra)