Skip to content

Commit

Permalink
Fixed some asserts, disabled some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luizzeroxis committed Aug 30, 2024
1 parent 4ab51a3 commit e7da31e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
30 changes: 15 additions & 15 deletions UndertaleModLib.Tests/GameLoadingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void SaveDataAndCompare()

ms.Position = 0;
string writtenMD5 = GenerateMD5(ms);
Assert.True(expectedMD5 == writtenMD5, "Written file doesn't match read file");
Assert.True(expectedMD5.Equals(writtenMD5), "Written file doesn't match read file");
}
}

Expand Down Expand Up @@ -81,29 +81,29 @@ public void DisassembleAndReassembleAllScripts()

IList<UndertaleInstruction> reasm = Assembler.Assemble(disasm, data.Functions, data.Variables, data.Strings);

Assert.True(code.Instructions.Count == reasm.Count, "Reassembled instruction count didn't match the disassembly for script " + code.Name.Content);
Assert.True(code.Instructions.Count.Equals(reasm.Count), "Reassembled instruction count didn't match the disassembly for script " + code.Name.Content);

for (int i = 0; i < code.Instructions.Count; i++)
{
string errMsg = "Instruction at " + code.Instructions[i].Address.ToString("D5") + " didn't match for script: " + code.Name.Content;

Assert.True(code.Instructions[i].Kind == reasm[i].Kind, errMsg);
Assert.True(code.Instructions[i].ComparisonKind == reasm[i].ComparisonKind, errMsg);
Assert.True(code.Instructions[i].Type1 == reasm[i].Type1, errMsg);
Assert.True(code.Instructions[i].Type2 == reasm[i].Type2, errMsg);
Assert.True(code.Instructions[i].TypeInst == reasm[i].TypeInst, errMsg);
Assert.True(code.Instructions[i].Extra == reasm[i].Extra, errMsg);
Assert.True(code.Instructions[i].SwapExtra == reasm[i].SwapExtra, errMsg);
Assert.True(code.Instructions[i].ArgumentsCount == reasm[i].ArgumentsCount, errMsg);
Assert.True(code.Instructions[i].JumpOffsetPopenvExitMagic == reasm[i].JumpOffsetPopenvExitMagic, errMsg);
Assert.True(code.Instructions[i].Kind.Equals(reasm[i].Kind), errMsg);
Assert.True(code.Instructions[i].ComparisonKind.Equals(reasm[i].ComparisonKind), errMsg);
Assert.True(code.Instructions[i].Type1.Equals(reasm[i].Type1), errMsg);
Assert.True(code.Instructions[i].Type2.Equals(reasm[i].Type2), errMsg);
Assert.True(code.Instructions[i].TypeInst.Equals(reasm[i].TypeInst), errMsg);
Assert.True(code.Instructions[i].Extra.Equals(reasm[i].Extra), errMsg);
Assert.True(code.Instructions[i].SwapExtra.Equals(reasm[i].SwapExtra), errMsg);
Assert.True(code.Instructions[i].ArgumentsCount.Equals(reasm[i].ArgumentsCount), errMsg);
Assert.True(code.Instructions[i].JumpOffsetPopenvExitMagic.Equals(reasm[i].JumpOffsetPopenvExitMagic), errMsg);

if (!code.Instructions[i].JumpOffsetPopenvExitMagic)
Assert.True(code.Instructions[i].JumpOffset == reasm[i].JumpOffset, errMsg); // note: also handles IntArgument implicitly
Assert.True(code.Instructions[i].JumpOffset.Equals(reasm[i].JumpOffset), errMsg); // note: also handles IntArgument implicitly

Assert.True(Object.ReferenceEquals(code.Instructions[i].Destination?.Target, reasm[i].Destination?.Target), errMsg);
Assert.True(code.Instructions[i].Destination?.Type == reasm[i].Destination?.Type, errMsg);
Assert.True(Object.Equals(code.Instructions[i].Destination?.Type, reasm[i].Destination?.Type), errMsg);
Assert.True(Object.ReferenceEquals(code.Instructions[i].Function?.Target, reasm[i].Function?.Target), errMsg);
Assert.True(code.Instructions[i].Function?.Type == reasm[i].Function?.Type, errMsg);
Assert.True(Object.Equals(code.Instructions[i].Function?.Type, reasm[i].Function?.Type), errMsg);

Assert.True(Object.ReferenceEquals(code.Instructions[i].Value?.GetType(), reasm[i].Value?.GetType()), errMsg);

Expand All @@ -118,7 +118,7 @@ public void DisassembleAndReassembleAllScripts()
else if (code.Instructions[i].Value?.GetType() == typeof(UndertaleResourceById<UndertaleString, UndertaleChunkSTRG>))
Assert.True(Object.ReferenceEquals(((UndertaleResourceById<UndertaleString, UndertaleChunkSTRG>)code.Instructions[i].Value).Resource, ((UndertaleResourceById<UndertaleString, UndertaleChunkSTRG>)reasm[i].Value).Resource), errMsg);
else
Assert.True(code.Instructions[i].Value == reasm[i].Value, errMsg);
Assert.True(Object.Equals(code.Instructions[i].Value, reasm[i].Value), errMsg);
}
});
}
Expand Down
3 changes: 1 addition & 2 deletions UndertaleModLib.Tests/GamePaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ namespace UndertaleModLib.Tests
static class GamePaths
{
// TODO: Maybe these should be configuration variables?
//public static string UNDERTALE_PATH = @"C:\Program Files (x86)\Steam\steamapps\common\Undertale\data.win";
public static string UNDERTALE_PATH = @"D:\SteamLibrary\steamapps\common\Undertale\data.win";
public static string UNDERTALE_PATH = @"C:\Program Files (x86)\Steam\steamapps\common\Undertale\data.win";
public static string UNDERTALE_MD5 = "5903fc5cb042a728d4ad8ee9e949c6eb";
public static string UNDERTALE_SWITCH_PATH = @"..\..\..\Test\bin\Debug\switch\game.win";
public static string UNDERTALE_SWITCH_MD5 = "427520a97db28c87da4220abb3a334c1";
Expand Down
4 changes: 2 additions & 2 deletions UndertaleModLib.Tests/GameScriptTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,10 @@ public UndertaleScriptTest() : base(GamePaths.UNDERTALE_PATH, GamePaths.UNDERTAL
[InlineData("GoToRoom.csx")]
[InlineData("ShowRoomName.csx")]
[InlineData("BorderEnabler.csx")]
[InlineData("testing.csx")]
[InlineData("testing.csx", Skip = "Script does not exist")]
[InlineData("RoomOfDetermination.csx")]
[InlineData("TTFFonts.csx")]
[InlineData("MixMod.csx")]
[InlineData("MixMod.csx", Skip = "Script not working")]
public async Task RunScriptTest(string scriptName)
{
await RunScript(scriptName);
Expand Down

0 comments on commit e7da31e

Please sign in to comment.