You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bat/tests/syntax-tests/source/PowerShell/test.ps1

26 lines
1.4 KiB
PowerShell

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

# PowerShell script for testing syntax highlighting
function Get-FutureTime {
param (
[Int32] $Minutes
)
$time = Get-Date | % { $_.AddMinutes($Minutes) }
"{0:d2}:{1:d2}:{2:d2}" -f @($time.hour, $time.minute, $time.second)
}
if ($env:PATH -match '.*rust.*') {
'Path contains Rust'
try {
& "cargo" "--version"
} catch {
Write-Error "Failed to run cargo"
}
} else {
'Path does not contain Rust'
}
(5..30) | ? { $_ % (2 * 2 + 1) -eq 0 } | % {"In {0} minutes, the time will be {1}." -f $_, $( Get-FutureTime $_ )}
$later = Get-FutureTime -Minutes $( Get-Random -Minimum 60 -Maximum 120 )
"The time will be " + $later + " later."