Improve ctags callback API
[geany-mirror.git] / tests / ctags / simple.ps1
blob2e7fff3f70fc7a7a8b829b8b200900a006e6b86e
1 # pseudo #!/PowerShell :)
3 # test file for the CTags/Geany PowerShell tag parser
4 # based on real world code but simplified for automated tests
6 <#
7 multiline comment including a function and variable, both should be ignored:
9 $IgnoreThisVaribale = "Stop"
11 function IgnoreThisFunction($arg1) {
12 Write-Host "dummy"
16 # immediately stop the script if an errors occurs
17 $ErrorActionPreference = "Stop"
19 # a global scoped variable
20 $Global:Settings = $null
22 # a local scoped variable
23 $Local:ALocalVar = $null
25 # a usual variable
26 $BasePath = split-path -parent $Global:MyInvocation.InvocationName
29 FUNCTION Read-Configuration-File() {
30 $Hostname = [System.Environment]::MachineName
31 $ConfigurationFileName = $BasePath + "\script-${Hostname}.conf"
32 LogMessage "Read configuration '${ConfigurationFileName}'"
34 $ConfigFileContent = Get-Content -raw $ConfigurationFileName
35 $Global:Settings = Convertfrom-Stringdata $ConfigFileContent
38 Function LogMessageOK()
40 $x = [Console]::WindowWidth - 6
41 $y = [Console]::CursorTop
42 Try {
43 [Console]::setcursorposition($x, $y)
44 } Catch [system.exception] {
45 # intentionally left empty for redirect of outputs to file
48 Write-Host -foregroundcolor "green" "[ok]"
51 function LogMessage() {
52 param(
53 [Parameter(Mandatory=$false)][switch] $NoNewLine,
54 [Parameter(Mandatory=$true)][string] $Message
56 $Date = Get-Date -UFormat "%Y-%m-%d %T: "
57 Write-Host -foregroundcolor "yellow" -NoNewLine $Date
59 if ($NoNewLine) {
60 Write-Host -foregroundcolor "green" -NoNewLine $Message
61 } else {
62 Write-Host -foregroundcolor "green" $Message
66 function global:A-Global-Scope-Function() {
67 Write-Host "dummy"
70 filter Script:MyFilter {
71 filter-something
74 Filter Private:MyPrivateFilter {
75 filter-something
78 function LoadTemplate($template) {
79 # woah, this is real magic,
80 # see http://stackoverflow.com/questions/10754582/string-interpolation-of-hashtable-values-in-powershell
82 # Set all unbound variables (@args) in the local context
83 while ($args)
85 ($key, $val, $args) = $args
86 Set-Variable -Name $key.SubString(1, $key.Length-2) -Value $val
88 $ExecutionContext.InvokeCommand.ExpandString($template)
91 function TopLevelFunction() {
92 function SecondLevelNestedFunction() {
93 function ThirdLevelNestedFunction() {
94 doSomething()
97 ThirdLevelNestedFunction
100 SecondLevelNestedFunction
103 function Main() {
104 Read-Configuration-File
105 LogMessage $("Working on Environment '{0}'" -f $Settings["EnvironmentName"])
107 LogMessage "do something ..."
108 Stripped-Down-Code
109 LogMessageOK
112 Main