1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 20:42:21 +02:00

Enhanced ranges

This commit is contained in:
Brian Fiete 2021-10-24 08:12:18 -07:00
parent eec2cb5e6c
commit 27fd5552cc
12 changed files with 365 additions and 22 deletions

View file

@ -133,6 +133,35 @@ namespace Tests
Test.Assert((1..<3).Contains(1..<3));
Test.Assert(!(1..<3).Contains(1..<4));
List<int> iList = scope .() { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
total = 0;
for (int i in iList[...])
total += i;
Test.Assert(total == 10+20+30+40+50+60+70+80+90+100);
total = 0;
for (int i in iList[1...])
total += i;
Test.Assert(total == 20+30+40+50+60+70+80+90+100);
total = 0;
for (int i in iList[...^1])
total += i;
Test.Assert(total == 10+20+30+40+50+60+70+80+90);
total = 0;
for (int i in iList[..<^1])
total += i;
Test.Assert(total == 10+20+30+40+50+60+70+80);
total = 0;
for (int i in iList[...^1][1...^1])
total += i;
Test.Assert(total == 20+30+40+50+60+70+80);
var str = scope String();
(2...^3).ToString(str);
Test.Assert(str == "2...^3");
}
public static void TestEnumerator1(EnumeratorTest e)