Skip to content

Commit 9ab46b8

Browse files
committed
Added more AOT tests
1 parent c2e5627 commit 9ab46b8

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace DotNext.Collections.Generic;
2+
3+
[TestClass]
4+
public class ListTests
5+
{
6+
[TestMethod]
7+
public void Indexer()
8+
{
9+
IList<long> array = [5L, 6L, 30L];
10+
Assert.AreEqual(30L, List.Indexer<long>.Getter(array, 2));
11+
List.Indexer<long>.Setter(array, 1, 10L);
12+
Assert.AreEqual(10L, array.IndexerGetter().Invoke(1));
13+
array.IndexerSetter().Invoke(0, 6L);
14+
Assert.AreEqual(6L, array.IndexerGetter().Invoke(0));
15+
}
16+
17+
[TestMethod]
18+
public void ReadOnlyIndexer()
19+
{
20+
IReadOnlyList<long> array = [5L, 6L, 20L];
21+
Assert.AreEqual(20L, List.Indexer<long>.ReadOnly(array, 2));
22+
Assert.AreEqual(6L, array.IndexerGetter().Invoke(1));
23+
}
24+
}

src/DotNext.AotTests/DotNext.AotTests.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@
2828
<PackageReference Include="MSTest.TestFramework" />
2929
<PackageReference Include="MSTest.Analyzers" />
3030
</ItemGroup>
31+
32+
<ItemGroup>
33+
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
34+
</ItemGroup>
3135
</Project>

src/DotNext.AotTests/Reflection/TaskTypeTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
2-
31
namespace DotNext.Reflection;
42

53
[TestClass]

src/DotNext.Tests/Collections/Generic/ListTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static void OrderedInsertion()
3434
[Fact]
3535
public static void ReadOnlyView()
3636
{
37-
var view = new ReadOnlyListView<string, int>(new[] { "1", "2", "3" }, new Converter<string, int>(int.Parse));
37+
var view = new ReadOnlyListView<string, int>(["1", "2", "3"], new Converter<string, int>(int.Parse));
3838
Equal(3, view.Count);
3939
Equal(1, view[0]);
4040
Equal(2, view[1]);
@@ -46,15 +46,15 @@ public static void ReadOnlyView()
4646
[Fact]
4747
public static void ReadOnlyIndexer()
4848
{
49-
IReadOnlyList<long> array = new[] { 5L, 6L, 20L };
49+
IReadOnlyList<long> array = [5L, 6L, 20L];
5050
Equal(20L, List.Indexer<long>.ReadOnly(array, 2));
5151
Equal(6L, array.IndexerGetter().Invoke(1));
5252
}
5353

5454
[Fact]
5555
public static void Indexer()
5656
{
57-
IList<long> array = new[] { 5L, 6L, 30L };
57+
IList<long> array = [5L, 6L, 30L];
5858
Equal(30L, List.Indexer<long>.Getter(array, 2));
5959
List.Indexer<long>.Setter(array, 1, 10L);
6060
Equal(10L, array.IndexerGetter().Invoke(1));
@@ -99,8 +99,8 @@ private static void SliceTest(IList<long> list)
9999
public static void SliceList()
100100
{
101101
SliceTest(new List<long> { 10L, 20L, 30L, 40L });
102-
SliceTest(new[] { 10L, 20L, 30L, 40L });
103-
SliceTest(new ArraySegment<long>(new[] { 10L, 20L, 30L, 40L }, 0, 4));
102+
SliceTest([10L, 20L, 30L, 40L]);
103+
SliceTest(new ArraySegment<long>([10L, 20L, 30L, 40L], 0, 4));
104104
}
105105

106106
[Fact]
@@ -117,7 +117,7 @@ public static void InsertRemove()
117117
[Fact]
118118
public static void ArraySlice()
119119
{
120-
var segment = List.Slice(new int[] { 10, 20, 30 }, 0..2);
120+
var segment = List.Slice([10, 20, 30], 0..2);
121121
True(segment.TryGetSpan(out var span));
122122
Equal(2, span.Length);
123123
Equal(10, span[0]);

0 commit comments

Comments
 (0)