From ec8072d51fa943569ebdace5c79d9f8452cf2d8f Mon Sep 17 00:00:00 2001 From: Dobe Peter Date: Sun, 25 Oct 2020 02:19:07 +0100 Subject: [PATCH] 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. --- .../highlighted/PowerShell/test.ps1 | 25 ++++++++++++++++++ tests/syntax-tests/source/PowerShell/test.ps1 | Bin 0 -> 1430 bytes 2 files changed, 25 insertions(+) create mode 100644 tests/syntax-tests/highlighted/PowerShell/test.ps1 create mode 100755 tests/syntax-tests/source/PowerShell/test.ps1 diff --git a/tests/syntax-tests/highlighted/PowerShell/test.ps1 b/tests/syntax-tests/highlighted/PowerShell/test.ps1 new file mode 100644 index 00000000..915b6072 --- /dev/null +++ b/tests/syntax-tests/highlighted/PowerShell/test.ps1 @@ -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." diff --git a/tests/syntax-tests/source/PowerShell/test.ps1 b/tests/syntax-tests/source/PowerShell/test.ps1 new file mode 100755 index 0000000000000000000000000000000000000000..434414df4059c3b1eac568be7515ce1c43aea629 GIT binary patch literal 1430 zcmai!U279T6o${W;C~p_XtwGuNs3++LlZl;M%kBi71#^qM;Xko68@tve ztJc2SPj;uAkNHnmbJDwOcTD5NmS_*%e$Fb`Tl}?F*&8G+W5NCi>lt&fE4K=)^qmuB z!I-fwGfC3;Wc!}Yt_|!nS{-}unaa2FRt`ybC);gGI-Xz5;2HWU$5+IbpJ2Zj_Ze4= zj(xG(UfPH+k5>K@e+T{REN+31p6y{fK(fcKpX~;JcLlZ;2nKt>?bkWh;5~Qb9(y*z zT)Ef$Ri$|MZCQiH5W6!XMCC5en);l%%cxS^CLSM@8p)-`3}SFce;~a|(Ln THXOuJVV>VXCz7o11yX+im