Skip to content

Commit

Permalink
Add PowerShell syntax test
Browse files Browse the repository at this point in the history
Part of the work for issue sharkdp#1213.

A short PowerShell script and the corresponding syntax-highlighted output
has been added. The script exhibits many of the peculiarities of the
PowerShell syntax.
  • Loading branch information
dp304 committed Oct 25, 2020
1 parent 7a7bb80 commit 90696fa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/syntax-tests/highlighted/PowerShell/test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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."
Binary file added tests/syntax-tests/source/PowerShell/test.ps1
Binary file not shown.

0 comments on commit 90696fa

Please sign in to comment.