Skip to content

Commit

Permalink
icsharpcode#1869: Add correctness test case
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer authored and ElektroKill committed Aug 3, 2021
1 parent 0098640 commit 2d1ed2a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ICSharpCode.Decompiler.Tests/TestCases/Correctness/Loops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ static void Main()
Console.WriteLine(NoForeachCallWithSideEffect(new CustomClassEnumeratorWithIDisposable<int>()));
LoopWithGotoRepeat();
Console.WriteLine("LoopFollowedByIf: {0}", LoopFollowedByIf());
NoForeachDueToVariableAssignment();
}

public static void ForWithMultipleVariables()
Expand Down Expand Up @@ -277,5 +278,18 @@ static void Issue1392ForWithNestedSwitchPlusGoto()
}
}
}

private static void NoForeachDueToVariableAssignment()
{
try {
int[] array = new int[] { 1, 2, 3 };
for (int i = 0; i < array.Length; i++) {
Console.WriteLine(array[i]);
array = null;
}
} catch (Exception ex) {
Console.WriteLine(ex.GetType() + ": " + ex.Message);
}
}
}
}

0 comments on commit 2d1ed2a

Please sign in to comment.