Skip to content

Instantly share code, notes, and snippets.

@basso414f
Last active October 10, 2016 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basso414f/ec4779fbfee10b8e1243de2d34ca8b10 to your computer and use it in GitHub Desktop.
Save basso414f/ec4779fbfee10b8e1243de2d34ca8b10 to your computer and use it in GitHub Desktop.
2次元配列のテスト
Describe "a1b1c1: NOT use 'NoEnumerate'/NOT use function/NOT use variable" {
It "t1: index access test" {
@(, @(1,2,3))[0][1] | Should Be 2
}
It "t2: pipe access test" {
@(, @(1,2,3)) | ForEach { $_[1] } | Should Be 2
}
}
Describe "a1b1c2: NOT use 'NoEnumerate'/NOT use function/use variable" {
BeforeEach {
$result = @(, @(1,2,3))
}
It "t1: index access test" {
$result[0][1] | Should Be 2
}
It "t2: pipe access test" {
$result | ForEach { $_[1] } | Should Be 2
}
}
Describe "a1b2c1: NOT use 'NoEnumerate'/use function/NOT use variable" {
BeforeEach {
function func_b { @(, @(1,2,3)) }
}
It "t1: index access test" {
(func_b)[0][1] | Should Be 2 #=> Failure
}
It "t2: pipe access test" {
func_b | ForEach { $_[1] } | Should Be 2 #=>Success
}
It "t2-add01: pipe access test" {
(func_b) | ForEach { $_[1] } | Should Be 2 #=>Failure
}
}
Describe "a1b2c2: NOT use 'NoEnumerate'/use function/use variable" {
BeforeEach {
function func_b { @(, @(1,2,3)) }
$result = func_b
}
It "t1: index access test" {
$result[0][1] | Should Be 2
}
It "t2: pipe access test" {
$result | ForEach { $_[1] } | Should Be 2
}
}
Describe "a1b3c1: NOT use 'NoEnumerate'/use scriptblock/NOT use variable" {
BeforeEach {
$block_c = { @(, @(1,2,3)) }
}
It "t1: index access test" {
(& $block_c)[0][1] | Should Be 2
}
It "t2: pipe access test" {
(& $block_c) | ForEach { $_[1] } | Should Be 2
}
}
Describe "a1b3c2: NOT use 'NoEnumerate'/use scriptblock/use variable" {
BeforeEach {
$block_c = { @(, @(1,2,3)) }
$result = (& $block_c)
}
It "t1: index access test" {
$result[0][1] | Should Be 2
}
It "t2: pipe access test" {
$result | ForEach { $_[1] } | Should Be 2
}
}
Describe "a2b1c1: use 'NoEnumerate'/NOT use function/NOT use variable" {
It "t1: index access test" {
(Write-Output @(, @(1,2,3)) -NoEnumerate)[0][1] | Should Be 2
}
It "t2: pipe access test" {
(Write-Output @(, @(1,2,3)) -NoEnumerate) | ForEach { $_[1] } | Should Be 2
}
}
Describe "a2b1c2: use 'NoEnumerate'/NOT use function/use variable" {
BeforeEach {
$result = Write-Output @(, @(1,2,3)) -NoEnumerate
}
It "t1: index access test" {
$result[0][1] | Should Be 2
}
It "t2: pipe access test" {
$result | ForEach { $_[1] } | Should Be 2
}
}
Describe "a2b2c1: use 'NoEnumerate'/use function/NOT use variable" {
BeforeEach {
function func_b { Write-Output @(, @(1,2,3)) -NoEnumerate }
}
It "t1: index access test" {
(func_b)[0][1] | Should Be 2 #=>Success
}
It "t2: pipe access test" {
func_b | ForEach { $_[1] } | Should Be 2 #=>Failure
}
It "t2-add01: pipe access test" {
(func_b) | ForEach { $_[1] } | Should Be 2 #=>Success
}
It "t2-add02: pipe access test" {
func_b | ForEach { $_[0][1] } | Should Be 2 #=>Success
}
}
Describe "a2b2c2: use 'NoEnumerate'/use function/use variable" {
BeforeEach {
function func_b { Write-Output @(, @(1,2,3)) -NoEnumerate }
$result = func_b
}
It "t1: index access test" {
$result[0][1] | Should Be 2
}
It "t2: pipe access test" {
$result | ForEach { $_[1] } | Should Be 2
}
}
Describe "a2b3c1: use 'NoEnumerate'/use scriptblock/NOT use variable" {
BeforeEach {
$block_c = { Write-Output @(, @(1,2,3)) -NoEnumerate }
}
It "t1: index access test" {
(& $block_c)[0][1] | Should Be 2
}
It "t2: pipe access test" {
(& $block_c) | ForEach { $_[1] } | Should Be 2
}
}
Describe "a2b3c2: use 'NoEnumerate'/use scriptblock/use variable" {
BeforeEach {
$block_c = { Write-Output @(, @(1,2,3)) -NoEnumerate }
$result = (& $block_c)
}
It "t1: index access test" {
$result[0][1] | Should Be 2
}
It "t2: pipe access test" {
$result | ForEach { $_[1] } | Should Be 2
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment