From 87db902e2a102c11a2395785776c257a2355a933 Mon Sep 17 00:00:00 2001 From: winscripter <142818255+winscripter@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:32:29 +0400 Subject: [PATCH] Fix tests --- ILSourceParser.Tests/InstructionTests.cs | 59 ++++++++++++------------ ILSourceParser.Tests/VerTest.cs | 36 +++++++-------- 2 files changed, 48 insertions(+), 47 deletions(-) diff --git a/ILSourceParser.Tests/InstructionTests.cs b/ILSourceParser.Tests/InstructionTests.cs index 2597712..9a444b1 100644 --- a/ILSourceParser.Tests/InstructionTests.cs +++ b/ILSourceParser.Tests/InstructionTests.cs @@ -1,29 +1,30 @@ -using ILSourceParser.Syntax; -using Sprache; - -namespace ILSourceParser.Tests; - -public class InstructionTests -{ - /// - /// A test to validate the IL ldsfld opcode. - /// - [Fact] - public void OpCodeLdsFldComplex() - { - var parser = new Parser(); - var ldsfld = parser.ParseLdsfldInstruction(); - var r = ldsfld.Parse(@"ldsfld class [System.Linq.Expressions]System.Runtime.CompilerServices.CallSite`1> C/'<>o__0'::'<>p__1'"); - - var result = (r.FieldType as GenericTypeReferenceSyntax)!; - Assert.Equal("System.Linq.Expressions", result.AssemblyReference!.AssemblyName); - Assert.Equal("System.Runtime.CompilerServices.CallSite`1", result.ClassName!); - Assert.Single(result.GenericArguments!.Parameters); - Assert.True(result.GenericArguments!.Parameters.All(arg => arg is GenericParameterTypeConstraintSyntax)); - - Assert.Equal("C/'<>o__0'", - (r.Target.DeclaringTypeReference as NonGenericTypeReferenceSyntax)!.GetNameOfType()); - - Assert.Equal("<>p__1", r.Target.FieldOrPropertyName); - } -} +using ILSourceParser.Syntax; +using ILSourceParser.Utilities; +using Sprache; + +namespace ILSourceParser.Tests; + +public class InstructionTests +{ + /// + /// A test to validate the IL ldsfld opcode. + /// + [Fact] + public void OpCodeLdsFldComplex() + { + var parser = new Parser(); + var ldsfld = parser.ParseLdsfldInstruction(); + var r = ldsfld.Parse(@"ldsfld class [System.Linq.Expressions]System.Runtime.CompilerServices.CallSite`1> C/'<>o__0'::'<>p__1'"); + + var result = (r.FieldType as GenericTypeReferenceSyntax)!; + Assert.Equal("System.Linq.Expressions", result.AssemblyReference!.AssemblyName); + Assert.Equal("System.Runtime.CompilerServices.CallSite`1", result.ClassName!); + Assert.Single(result.GenericArguments!.Parameters); + Assert.True(result.GenericArguments!.Parameters.All(arg => arg is GenericParameterTypeConstraintSyntax)); + + Assert.Equal("C/'<>o__0'", + (r.Target.DeclaringTypeReference as NonGenericTypeReferenceSyntax)!.GetNameOfType()); + + Assert.Equal("<>p__1", r.Target.FieldOrPropertyName); + } +} diff --git a/ILSourceParser.Tests/VerTest.cs b/ILSourceParser.Tests/VerTest.cs index c292da3..ac59f43 100644 --- a/ILSourceParser.Tests/VerTest.cs +++ b/ILSourceParser.Tests/VerTest.cs @@ -1,18 +1,18 @@ -using Sprache; - -namespace ILSourceParser.Tests; - -public class VerTest -{ - [Fact] - public void Test() - { - const string input = @".ver 1:2:3:4"; - var result = new Parser().ParseVerDirective().Parse(input); - - Assert.Equal('1', result.Major); - Assert.Equal('2', result.Minor); - Assert.Equal('3', result.Build); - Assert.Equal('4', result.Revision); - } -} +using Sprache; + +namespace ILSourceParser.Tests; + +public class VerTest +{ + [Fact] + public void Test() + { + const string input = @".ver 1:2:3:4"; + var result = Parser.ParseVerDirective().Parse(input); + + Assert.Equal('1', result.Major); + Assert.Equal('2', result.Minor); + Assert.Equal('3', result.Build); + Assert.Equal('4', result.Revision); + } +}