1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-01 13:56:00 +02:00

Fixed lambda capture of shadows variables

This commit is contained in:
Brian Fiete 2020-09-01 15:57:08 -07:00
parent 0700697fe9
commit 177b5b7254
6 changed files with 88 additions and 133 deletions

View file

@ -1,9 +1,16 @@
using System;
using System.Collections;
namespace Tests
{
class Lambdas
{
static void TestIt(List<float>.Enumerator e, int idx, float val)
{
Test.Assert(e.Index == idx);
Test.Assert(e.Current == val);
}
[Test]
static void TestBasics()
{
@ -20,6 +27,18 @@ namespace Tests
act();
Test.Assert(a == 101);
List<float> iList = scope List<float>() { 10, 20, 30 };
int idx = 0;
for (var val in iList)
{
delegate void() dlg = scope () =>
{
TestIt(@val, idx, val);
};
dlg();
++idx;
}
}
static int Add3<T>(T func) where T : delegate int()