@@ -3,13 +3,54 @@ This directory and it's subdirectories contain additional language keywords with
33Most keywords will be implemented as a Transpiler that tranforms a CommandAST.
44
55
6- | DisplayName | Synopsis |
7- | ------------------| ----------------------------|
8- | [ New] ( New.psx.ps1 ) | [ 'new' keyword] ( New.psx.ps1 ) |
6+ | DisplayName | Synopsis |
7+ | ------------------------| --------------------------------|
8+ | [ Assert] ( Assert.psx.ps1 ) | [ Assert keyword] ( Assert.psx.ps1 ) |
9+ | [ New] ( New.psx.ps1 ) | [ 'new' keyword] ( New.psx.ps1 ) |
910
1011
1112
1213
14+ ## Assert Example 1
15+
16+
17+ ~~~ PowerShell
18+ # With no second argument, assert will throw an error with the condition of the assertion.
19+ Invoke-PipeScript {
20+ assert (1 -eq 1)
21+ } -Debug
22+ ~~~
23+
24+ ## Assert Example 2
25+
26+
27+ ~~~ PowerShell
28+ # With a second argument of a string, assert will throw an error
29+ Invoke-PipeScript {
30+ assert ($true) "It's true"
31+ } -Debug
32+ ~~~
33+
34+ ## Assert Example 3
35+
36+
37+ ~~~ PowerShell
38+ # Conditions can also be written as a ScriptBlock
39+ Invoke-PipeScript {
40+ assert {$true} "Process id '$pid' Asserted"
41+ } -Verbose
42+ ~~~
43+
44+ ## Assert Example 4
45+
46+
47+ ~~~ PowerShell
48+ # If the assertion action was a ScriptBlock, no exception is automatically thrown
49+ Invoke-PipeScript {
50+ assert ($true) { Write-Information "Assertion was true"}
51+ } -Verbose
52+ ~~~
53+
1354## New Example 1
1455
1556
@@ -35,19 +76,26 @@ Most keywords will be implemented as a Transpiler that tranforms a CommandAST.
3576
3677
3778~~~ PowerShell
38- .> { new datetime 12/31/1999 }
79+ .> { new Timespan }
3980~~~
4081
4182## New Example 5
4283
4384
4485~~~ PowerShell
45- .> { new @{RandomNumber = Get-Random; A ='b'} }
86+ .> { new datetime 12/31/1999 }
4687~~~
4788
4889## New Example 6
4990
5091
92+ ~~~ PowerShell
93+ .> { new @{RandomNumber = Get-Random; A ='b'}}
94+ ~~~
95+
96+ ## New Example 7
97+
98+
5199~~~ PowerShell
52100 .> { new Diagnostics.ProcessStartInfo @{FileName='f'} }
53101~~~
0 commit comments