diff --git a/IDEHelper/Tests/src/Generics.bf b/IDEHelper/Tests/src/Generics.bf index 4e087acd..5b4d0167 100644 --- a/IDEHelper/Tests/src/Generics.bf +++ b/IDEHelper/Tests/src/Generics.bf @@ -1,4 +1,5 @@ using System; +using System.Collections; namespace Tests { @@ -120,5 +121,30 @@ namespace Tests float totals = GetSum(fVals); Test.Assert(totals == 10+20+30+40+50); } + + public static mixin TransformArray(Input[InputSize] array, delegate void(Input, ref Output) predicate) where InputSize : const int where Output : new + { + Output[2] output = default; + for (int i = 0; i < array.Count; i++) + { + output[i] = scope:mixin Output(); + predicate(array[i], ref output[i]); + } + output + } + + [Test] + public static void TestSizedArrays() + { + int[2] arr = .(2, 4); + + delegate void(int, ref String) toString = scope (i, str) => { i.ToString(str); }; + + List l2 = scope .(); + l2.Add(TransformArray!(arr, toString)); + + Test.Assert(l2.Front[0] == "2"); + Test.Assert(l2.Front[1] == "4"); + } } }