-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18d38bc
commit 87db902
Showing
2 changed files
with
48 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
using ILSourceParser.Syntax; | ||
using Sprache; | ||
|
||
namespace ILSourceParser.Tests; | ||
|
||
public class InstructionTests | ||
{ | ||
/// <summary> | ||
/// A test to validate the IL ldsfld opcode. | ||
/// </summary> | ||
[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<class [System.Runtime]System.Func`3<class [System.Linq.Expressions]System.Runtime.CompilerServices.CallSite, object, int32>> 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 | ||
{ | ||
/// <summary> | ||
/// A test to validate the IL ldsfld opcode. | ||
/// </summary> | ||
[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<class [System.Runtime]System.Func`3<class [System.Linq.Expressions]System.Runtime.CompilerServices.CallSite, object, int32>> 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()); | ||
Check failure on line 26 in ILSourceParser.Tests/InstructionTests.cs GitHub Actions / build
Check failure on line 26 in ILSourceParser.Tests/InstructionTests.cs GitHub Actions / build
|
||
|
||
Assert.Equal("<>p__1", r.Target.FieldOrPropertyName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |