|
| 1 | +# SYNTAX TEST "Packages/PowerShell/PowerShell.sublime-syntax" |
| 2 | + |
| 3 | +"<- Exit the imports context block" |
| 4 | + |
| 5 | + workflow w1 {} |
| 6 | +#^^^^^^^^^^^^^^^^^ meta.function.powershell |
| 7 | +# ^^^^^^^^ keyword.declaration.function.powershell |
| 8 | +# ^^ entity.name.function.powershell |
| 9 | +# @@ definition |
| 10 | +# ^ punctuation.section.block.begin.powershell |
| 11 | +# ^ punctuation.section.block.end.powershell |
| 12 | + Workflow work { sequence {} } |
| 13 | +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell |
| 14 | +# ^^^^^^^^ keyword.declaration.function.powershell |
| 15 | +# ^^^^ entity.name.function.powershell |
| 16 | +# @@@@ definition |
| 17 | +# ^ punctuation.section.block.begin.powershell |
| 18 | +# ^^^^^^^^^^^ meta.block.powershell |
| 19 | +# ^^^^^^^^ keyword.control.flow.powershell |
| 20 | +# ^ punctuation.section.block.begin.powershell |
| 21 | +# ^ punctuation.section.block.end.powershell |
| 22 | +# ^ punctuation.section.block.end.powershell |
| 23 | + |
| 24 | + workflow Test-Workflow { |
| 25 | +#^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell |
| 26 | +# ^^^^^^^^ keyword.declaration.function.powershell |
| 27 | +# ^^^^^^^^^^^^^ entity.name.function.powershell |
| 28 | +# @@@@@@@@@@@@@ definition |
| 29 | +# ^ punctuation.section.block.begin.powershell |
| 30 | + parallel { |
| 31 | +#^^^^^^^^^^^^^^^^^ meta.function.powershell |
| 32 | +# ^^^^^^^^ keyword.control.flow.powershell |
| 33 | +# ^ punctuation.section.block.begin.powershell |
| 34 | + Get-Process |
| 35 | +# @@@@@@@@@@@ reference |
| 36 | + Get-Service |
| 37 | +#^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell |
| 38 | +# ^^^^^^^^^^^ meta.function-call.powershell support.function.powershell |
| 39 | +# @@@@@@@@@@@ reference |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + |
| 44 | + workflow Test-Workflow { |
| 45 | +# @@@@@@@@@@@@@ definition |
| 46 | + $a = 3 |
| 47 | +#^^^^^^^^^^^^^ meta.function.powershell |
| 48 | +# ^^ variable.other.readwrite.powershell |
| 49 | +# ^ punctuation.definition.variable.powershell |
| 50 | +# ^ keyword.operator.assignment.powershell |
| 51 | +# ^ meta.number.integer.decimal.powershell constant.numeric.value.powershell |
| 52 | + |
| 53 | + ## Without $Using, the $a workflow variable isn't visible |
| 54 | + ## in inline script. |
| 55 | + inlinescript {"Inline A0 = $a"} |
| 56 | +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell |
| 57 | +# ^^^^^^^^^^^^ keyword.control.context.powershell |
| 58 | +# ^ punctuation.section.block.begin.powershell |
| 59 | +# ^^^^^^^^^^^^^^^^ meta.string.interpolated.powershell |
| 60 | +# ^^^^^^^^^^^^^ string.quoted.double.powershell |
| 61 | +# ^ punctuation.definition.string.begin.powershell |
| 62 | +# ^^ meta.interpolation.powershell variable.other.readwrite.powershell |
| 63 | +# ^ punctuation.definition.variable.powershell |
| 64 | +# ^ string.quoted.double.powershell punctuation.definition.string.end.powershell |
| 65 | +# ^ punctuation.section.block.end.powershell |
| 66 | + |
| 67 | + ## $Using imports the variable and its current value. |
| 68 | + inlinescript {"Inline A1 = $Using:a"} |
| 69 | + } |
| 70 | + Test-Workflow |
| 71 | +# @@@@@@@@@@@@@ reference |
| 72 | + |
| 73 | + |
| 74 | + workflow Test-Workflow { |
| 75 | +# @@@@@@@@@@@@@ definition |
| 76 | + $a = 3 |
| 77 | + |
| 78 | + ## Changes to the inlinescript variable value don't |
| 79 | + ## change the workflow variable. |
| 80 | + inlinescript { |
| 81 | + $a = $Using:a+1; |
| 82 | + "Inline A = $a" |
| 83 | + } |
| 84 | + "Workflow A = $a" |
| 85 | + |
| 86 | + ## To change the variable in workflow scope, return the |
| 87 | + ## new value. |
| 88 | + $a = inlinescript {$b = $Using:a+1; $b} |
| 89 | + "Workflow New A = $a" |
| 90 | + } |
| 91 | + Test-Workflow |
| 92 | +# @@@@@@@@@@@@@ reference |
| 93 | + |
| 94 | + |
| 95 | + workflow Test-Workflow { |
| 96 | +# @@@@@@@@@@@@@ definition |
| 97 | + $ie = inlinescript { |
| 98 | + $ie = New-Object -ComObject InternetExplorer.Application -Property @{navigate2="www.microsoft.com"} |
| 99 | +# @@@@@@@@@@ reference |
| 100 | + |
| 101 | + $ie.Visible = $true |
| 102 | +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell |
| 103 | +# ^^^ variable.other.readwrite.powershell |
| 104 | +# ^ punctuation.definition.variable.powershell |
| 105 | +# ^ punctuation.accessor.dot.powershell |
| 106 | +# ^^^^^^^ variable.other.member.powershell |
| 107 | +# ^ keyword.operator.assignment.powershell |
| 108 | +# ^^^^^ constant.language.boolean.true.powershell |
| 109 | +# ^ punctuation.definition.variable.powershell |
| 110 | + } |
| 111 | + |
| 112 | + $ie |
| 113 | + } |
| 114 | + Test-Workflow |
| 115 | +# @@@@@@@@@@@@@ reference |
| 116 | + |
| 117 | + |
| 118 | + workflow Test-Workflow { |
| 119 | +# @@@@@@@@@@@@@ definition |
| 120 | + parallel { |
| 121 | + Get-Process |
| 122 | +# @@@@@@@@@@@ reference |
| 123 | + Get-Service |
| 124 | +#^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell |
| 125 | +# ^^^^^^^^^^^ meta.function-call.powershell support.function.powershell |
| 126 | +# @@@@@@@@@@@ reference |
| 127 | + |
| 128 | + sequence { |
| 129 | +# ^ meta.function.powershell meta.block.powershell meta.block.powershell punctuation.section.block.begin.powershell |
| 130 | + $Hotfix = Get-Content 'D:\HotFixes\Required.txt' |
| 131 | +# @@@@@@@@@@@ reference |
| 132 | + foreach ($h in $Hotfix) {'D:\Scripts\Verify-Hotfix' -Hotfix $h} |
| 133 | +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.powershell meta.block.powershell |
| 134 | +# ^^^^^^^ keyword.control.loop.for.powershell |
| 135 | +# ^^^^^^^^^^^^^^^ meta.group.powershell |
| 136 | +# ^ punctuation.section.group.begin.powershell |
| 137 | +# ^^ variable.other.readwrite.powershell |
| 138 | +# ^ punctuation.definition.variable.powershell |
| 139 | +# ^^ keyword.control.loop.in.powershell |
| 140 | +# ^^^^^^^ variable.other.readwrite.powershell |
| 141 | +# ^ punctuation.definition.variable.powershell |
| 142 | +# ^ punctuation.section.group.end.powershell |
| 143 | +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.powershell |
| 144 | +# ^ punctuation.section.braces.begin.powershell |
| 145 | +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.powershell string.quoted.single.powershell |
| 146 | +# ^ punctuation.definition.string.begin.powershell |
| 147 | +# ^ punctuation.definition.string.end.powershell |
| 148 | +# ^^^^^^^ variable.parameter.option.powershell |
| 149 | +# ^ punctuation.definition.parameter.powershell |
| 150 | +# ^^ variable.other.readwrite.powershell |
| 151 | +# ^ punctuation.definition.variable.powershell |
| 152 | +# ^ punctuation.section.braces.end.powershell |
| 153 | + } |
| 154 | + } |
| 155 | + } |
0 commit comments