Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AboutArrays Bug\Issue #358

Closed
ChaseFreeman17 opened this issue Feb 16, 2020 · 2 comments · Fixed by #360
Closed

AboutArrays Bug\Issue #358

ChaseFreeman17 opened this issue Feb 16, 2020 · 2 comments · Fixed by #360
Labels
Category-Koans Invoking the Great Doubt Issue-Bug 🐛 Something's wrong! Up For Grabs / Hacktoberfest 💻 If it's Up For Grabs, take it and run with it! If not, ask if it's in progress / you can take it.

Comments

@ChaseFreeman17
Copy link
Contributor

Describe "Koan Bug, Issue"

..\Foundations\AboutArrays.Koans.ps1

Context "The Problematic Assertions"

It 'allows you to check if something is contained within it'

Context "Your Attempts"

Here is my current block of code as it stand without modifications, but filled in.

   It 'allows you to check if something is contained within it' {
        <#
            The available methods can be seen with Get-Member:

                Get-Member -InputObject @()

            For example, each array has a Contains method.
        #>

        $true -eq $Numbers.Contains(3) | Should -BeTrue

        # The Contains method is case sensitive for arrays containing strings.

        $true -eq $Strings.Contains('first') | Should -BeTrue
        $false -eq $Strings.Contains('First') | Should -BeTrue

        # PowerShell's -contains operator is not case sensitive.

        $Strings -contains 'THIRD' | Should -BeTrue
        $Strings -contains 'SeConD' | Should -BeTrue
    }

I am not 100% sure this is a bug but this block is referring to two variables that are instantiated in the It block above 'is usually of type Object[]'. Therefore these variables are null in this block.

If you are to add the following code to the It 'allows you to check if something is contained within it' then the assertions will pass
`$Numbers = 1, 2, 3, 4

$Strings = 'first', 'second', 'third'`

Finally this passes:

    It 'allows you to check if something is contained within it' {
        <#
            The available methods can be seen with Get-Member:

                Get-Member -InputObject @()

            For example, each array has a Contains method.
        #>
        $Numbers = 1, 2, 3, 4
        $Strings = 'first', 'second', 'third'
        $true -eq $Numbers.Contains(3) | Should -BeTrue

        # The Contains method is case sensitive for arrays containing strings.

        $true -eq $Strings.Contains('first') | Should -BeTrue
        $false -eq $Strings.Contains('First') | Should -BeTrue

        # PowerShell's -contains operator is not case sensitive.

        $Strings -contains 'THIRD' | Should -BeTrue
        $Strings -contains 'SeConD' | Should -BeTrue
    }

Context "Additional Information"

Pester - 4.9.0
PSVersion - 5.1.18362.628

@ChaseFreeman17 ChaseFreeman17 added Category-Koans Invoking the Great Doubt Issue-Discussion Let's talk about it! labels Feb 16, 2020
@ChaseFreeman17
Copy link
Contributor Author

Willing to make a PR if you agree this is what needs to be done.

@vexx32 vexx32 added Issue-Bug 🐛 Something's wrong! Up For Grabs / Hacktoberfest 💻 If it's Up For Grabs, take it and run with it! If not, ask if it's in progress / you can take it. and removed Issue-Discussion Let's talk about it! labels Feb 16, 2020
@vexx32
Copy link
Owner

vexx32 commented Feb 16, 2020

Good catch! Yep, those should absolutely have been re-defined in that It block. Probably missed it during refactoring (that whole section used to be a single big It block).

That fix looks appropriate to me. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category-Koans Invoking the Great Doubt Issue-Bug 🐛 Something's wrong! Up For Grabs / Hacktoberfest 💻 If it's Up For Grabs, take it and run with it! If not, ask if it's in progress / you can take it.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants