Skip to content

Commit

Permalink
List Bug Fix mosa#1241 (mosa#1247)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiphil authored Oct 21, 2024
1 parent acb66fa commit 380b954
Show file tree
Hide file tree
Showing 4 changed files with 226 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected static void CopyCompound(Transform transform, Context context, Operand
var srcReg = transform.VirtualRegisters.AllocateNativeInteger();
var dstReg = transform.VirtualRegisters.AllocateNativeInteger();

context.AppendInstruction(transform.AddInstruction, srcReg, sourceBase, source);
context.SetInstruction(transform.AddInstruction, srcReg, sourceBase, source);
context.AppendInstruction(transform.AddInstruction, dstReg, destinationBase, destination);

var tmp = transform.VirtualRegisters.AllocateNativeInteger();
Expand Down
6 changes: 3 additions & 3 deletions Source/Mosa.Korlib/System.Collections.Generic/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,11 @@ public void Insert(int index, T item)
{
EnsureCapacity(_size + 1);

_size++;
for (int i = index; i < _size; i++)
for (int i = _size; i > index; i--)
{
_items[i] = _items[i + 1];
_items[i] = _items[i - 1];
}
_size++;

_items[index] = item;
}
Expand Down
218 changes: 216 additions & 2 deletions Source/Mosa.UnitTests/Korlib/ListTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static bool Add1()

list.Add(101);

return list.Count == 1;
return list[0] == 101 && list.Count == 1;
}

[MosaUnitTest]
Expand All @@ -40,7 +40,77 @@ public static bool Add2()
list.Add(101);
list.Add(202);

return list.Count == 2;
return list[0] == 101 && list[1] == 202 && list.Count == 2;
}

[MosaUnitTest]
public static bool Add4()
{
var list = new List<int>();

list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);

return list[0] == 0 && list[1] == 1 && list[2] == 2 && list[3] == 3 && list[4] == 4 && list[5] == 5;
}

[MosaUnitTest]
public static int Check0()
{
var list = new List<int>();

list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);

return list[0];
}

[MosaUnitTest]
public static int Check1()
{
var list = new List<int>();

list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);

return list[1];
}

[MosaUnitTest]
public static int Check2()
{
var list = new List<int>();

list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);

return list[2];
}

[MosaUnitTest]
public static int Check4()
{
var list = new List<int>();

list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);

return list[4];
}

[MosaUnitTest]
Expand Down Expand Up @@ -110,6 +180,150 @@ public static bool Remove2()
return list.IndexOf(101) == 0;
}

[MosaUnitTest]
public static bool RemoveAt0()
{
var list = new List<int>();

list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);

list.RemoveAt(0);

return list[0] == 1 && list[1] == 2 && list[2] == 3 && list[3] == 4;
}

[MosaUnitTest]
public static bool RemoveAt1()
{
var list = new List<int>();

list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);

list.RemoveAt(1);

return list[0] == 0 && list[1] == 2 && list[2] == 3 && list[3] == 3;
}

[MosaUnitTest]
public static bool RemoveAt3()
{
var list = new List<int>();

list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);

list.RemoveAt(4);

return list[0] == 0 && list[1] == 1 && list[2] == 2 && list[3] == 4;
}

[MosaUnitTest]
public static bool RemoveAt4()
{
var list = new List<int>();

list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);

list.RemoveAt(4);

return list[0] == 0 && list[1] == 1 && list[2] == 2 && list[3] == 3;
}

[MosaUnitTest]
public static bool Insert0()
{
var list = new List<int>();

list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);

list.Insert(0, 99);

return list[0] == 99 && list[1] == 0 && list[2] == 1 && list[3] == 2 && list[4] == 3 && list[5] == 4;
}

[MosaUnitTest]
public static bool Insert1()
{
var list = new List<int>();

list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);

list.Insert(1, 99);

return list[0] == 0 && list[1] == 99 && list[2] == 1 && list[3] == 2 && list[4] == 3 && list[5] == 4;
}

[MosaUnitTest]
public static bool Insert2()
{
var list = new List<int>();

list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);

list.Insert(2, 99);

return list[0] == 0 && list[1] == 1 && list[2] == 99 && list[3] == 2 && list[4] == 3 && list[5] == 4;
}

[MosaUnitTest]
public static bool Insert3()
{
var list = new List<int>();

list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);

list.Insert(3, 99);

return list[0] == 0 && list[1] == 1 && list[2] == 2 && list[3] == 99 && list[4] == 3 && list[5] == 4;
}

[MosaUnitTest]
public static bool Insert4()
{
var list = new List<int>();

list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);

list.Insert(4, 99);

return list[0] == 0 && list[1] == 1 && list[2] == 2 && list[3] == 3 && list[4] == 99 && list[5] == 4;
}

private static List<int> Populate(int count)
{
var list = new List<int>();
Expand Down
12 changes: 6 additions & 6 deletions Tools/reduce-qemu.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# curl https://qemu.weilnetz.de/w64/qemu-w64-setup-20230810.exe --output qemu-installer.exe
# del /S /Q qemu
# 7zip\7z.exe x -wqemu -oqemu -x!*.nsis -y qemu-installer.exe
# del /Q qemu-installer.exe
curl https://qemu.weilnetz.de/w64/2024/qemu-w64-setup-20240903.exe --output qemu-installer.exe
del /S /Q qemu
7zip\7z.exe x -wqemu -oqemu -x!*.nsis -y qemu-installer.exe
del /Q qemu-installer.exe

del /S /Q qemu\share\icons
del /S /Q qemu\share\doc
Expand Down Expand Up @@ -75,5 +75,5 @@ del /S /Q qemu\lib\gdk-pixbuf-2.0\2.10.0\qemu-uninstall.exe.nsis
del /S /Q qemu\share\petalogix-*.dtb
del /S /Q qemu\share\trace-events-all
del /S /Q qemu\share\s390-ccw.img


del /S /Q qemu\share\edk2-riscv*.fd
del /S /Q qemu\share\hppa-firmware64.img

0 comments on commit 380b954

Please sign in to comment.