on master help sign in
Add PowerShell syntax test

Part of the work for issue #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.

commitec8072d51fa943569ebdace5c79d9f8452cf2d8f authorDobe Peter <dobepeter@gmail.com> dateSun 25 Oct 2020, 02:19 (6 years ago) parent7a7bb80
2 files changed+25
tests/syntax-tests/highlighted/PowerShell/test.ps1+25 tests/syntax-tests/source/PowerShell/test.ps1
tests/syntax-tests/highlighted/PowerShell/test.ps1new file+25
@@ -0,0 +1,25 @@
1+# PowerShell script for testing syntax highlighting
2+
3+function Get-FutureTime {
4+ param (
5+ [Int32] $Minutes
6+ )
7+ 
8+ $time = Get-Date | % { $_.AddMinutes($Minutes) }
9+ "{0:d2}:{1:d2}:{2:d2}" -f @($time.hour, $time.minute, $time.second)
10+}
11+
12+if ($env:PATH -match '.*rust.*') {
13+ 'Path contains Rust'
14+ try {
15+ & "cargo" "--version"
16+ } catch {
17+ Write-Error "Failed to run cargo"
18+ }
19+} else {
20+ 'Path does not contain Rust'
21+}
22+
23+(5..30) | ? { $_ % (2 * 2 + 1) -eq 0 } | % {"In {0} minutes, the time will be {1}." -f $_, $( Get-FutureTime $_ )}
24+$later = Get-FutureTime -Minutes $( Get-Random -Minimum 60 -Maximum 120 )
25+"The time will be " + $later + " later."
tests/syntax-tests/source/PowerShell/test.ps1new file

Binary file not shown.