This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| findNb :: Integer -> Integer | |
| findNb m = | |
| if (volume == m) then | |
| fromIntegral $ length cubes | |
| else | |
| -1 | |
| where | |
| cubes = listCubesTillVolume m | |
| volume = last cubes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Requires -RunAsAdministrator | |
| function Uninstall-Pester ([switch]$All) { | |
| if ([IntPtr]::Size * 8 -ne 64) { throw "Run this script from 64bit PowerShell." } | |
| #Requires -RunAsAdministrator | |
| $pesterPaths = foreach ($programFiles in ($env:ProgramFiles, ${env:ProgramFiles(x86)})) { | |
| $path = "$programFiles\WindowsPowerShell\Modules\Pester" | |
| if ($null -ne $programFiles -and (Test-Path $path)) { | |
| if ($All) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| InModuleScope Pester { | |
| [System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '', Scope = '*', Target = 'SuppressImportModule')] | |
| $SuppressImportModule = $true | |
| . $PSScriptRoot\Shared.ps1 | |
| Describe 'Function-Name' { | |
| Context "asdf" { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function 🐙 { | |
| $name,$params = $args.Where({$_ -eq '💩'},'Until') | |
| $null,$groups = $args.Where({$_ -eq '💩'},'SkipUntil') | |
| $params = @($params |? {$_}) | |
| $bodyText = $groups | %{ | |
| $enumerator = [System.Globalization.StringInfo]::GetTextElementEnumerator($_) | |
| $letters = while ($enumerator.MoveNext()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $script:scope = "" | |
| $script:results = @{} | |
| function Get-Scope () { $script:scope } | |
| function Set-Scope ($Name) { | |
| $script:scope = $Name | |
| } | |
| function Add-Result ($Result, $Scope = (Get-Scope)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Set-ScriptBlockScope | |
| { | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter(Mandatory = $true)] | |
| [scriptblock] | |
| $ScriptBlock, | |
| [Parameter(Mandatory = $true, ParameterSetName = 'FromSessionState')] | |
| [System.Management.Automation.SessionState] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $path = "C:\Projects\pester_nohwnd" | |
| $volumePath = "//" + ($path -replace "\\","/" -replace "\:") | |
| docker run --rm -v ${volumePath}:/home/pester microsoft/powershell --% cd /home/pester/; import-module ./pester.psd1; $result = Invoke-Pester -PassThru ; Export-Clixml -InputObject $result ./result.clixml | |
| $result = $path + "/result.clixml" | Import-Clixml | |
| $result.TestResult | Where Result -NE Passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # author Dave Wyatt, I just copied the code from here https://blogs.technet.microsoft.com/heyscriptingguy/2015/12/14/what-is-pester-and-why-should-i-care/ | |
| function TimesTwo ($value) { | |
| return $value * 2 | |
| } | |
| Describe 'TimesTwo' { | |
| Context 'Numbers' { | |
| It 'Multiplies numbers properly' { | |
| TimesTwo 2 | Should Be 4 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ex1 | |
| # say not to this one | |
| $configuration:Servers | foreach { | |
| It "A test" { | |
| # code | |
| } | |
| } | |
| # use this instead | |
| It "A test" -TestCases @( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Should-Be { | |
| param($Expected,[Parameter(ValueFromPipeline)]$Actual) | |
| "We are comparing if two values are equal so" | |
| "when `$Expected is $($Expected.GetType()) with value '$Expected'" | |
| if ($null -eq $Actual) | |
| { | |
| "and `$Actual is `$null then the result is:" | |
| } | |
| else |