konstantinvlasenko / PowerSlim

Fitnesse Slim implementation in PowerShell. PowerSlim makes it possible to use PowerShell in the acceptance testing
powerslim.org
GNU General Public License v3.0
48 stars 21 forks source link

If there are 2 nested loops, the inner loop is executed only once #91

Closed ZakharShkonda closed 6 years ago

ZakharShkonda commented 6 years ago

For example, this test will fail:

|scenario|show bug|
|eval|{{{
$i=0
$arr = new-object int[] 4
For ($a=0; $a -lt 2; $a++)
{
    For($b=0; $b -lt 2; $b++)
    {
        $arr[$i]=$i
        $i++
    }
}
}}}|
|check|eval|$arr[0]|0|
|check|eval|$arr[1]|1|
|check|eval|$arr[2]|2|
|check|eval|$arr[3]|3|

$arr[2] and $arr[3] will be 0

konstantinvlasenko commented 6 years ago

Confirmed https://github.com/konstantinvlasenko/PowerSlim/blob/master/FitNesseRoot/PowerSlim/OriginalMode/SuiteCommon/TestNestedLoop.wiki

konstantinvlasenko commented 6 years ago

ok. I understand the issue now. Problem is that PowerSLim converts nested loop into FOR ($script:b=0; $b -lt 2; $b++). And $script:b and $b are actually 2 different variables in this context. So second time we don't set $b to 0 actually. It remains being equal to 2.