1- using System ;
1+ using System ;
2+ using System . Collections . Generic ;
23using NFluent ;
34using ReClassNET . AddressParser ;
45using Xunit ;
6+ using static ReClassNET . AddressParser . DynamicCompiler ;
57
68namespace ReClass . NET_Tests . AddressParser
79{
10+ class TestClassList : IProjectContext
11+ {
12+ public IReadOnlyList < ReClassNET . Nodes . ClassNode > Classes { get ; } = new List < ReClassNET . Nodes . ClassNode > { } ;
13+ }
14+
815 public class ParserTest
916 {
1017 [ Theory ]
@@ -17,6 +24,8 @@ public class ParserTest
1724 [ InlineData ( ")" ) ]
1825 [ InlineData ( "[" ) ]
1926 [ InlineData ( "]" ) ]
27+ [ InlineData ( "{" ) ]
28+ [ InlineData ( "}" ) ]
2029 [ InlineData ( "1-" ) ]
2130 [ InlineData ( "1(" ) ]
2231 [ InlineData ( "1)" ) ]
@@ -26,6 +35,8 @@ public class ParserTest
2635 [ InlineData ( ")1" ) ]
2736 [ InlineData ( "[1" ) ]
2837 [ InlineData ( "]1" ) ]
38+ [ InlineData ( "{1" ) ]
39+ [ InlineData ( "}1" ) ]
2940 [ InlineData ( "1+(" ) ]
3041 [ InlineData ( "1+)" ) ]
3142 [ InlineData ( "1 + ()" ) ]
@@ -44,22 +55,24 @@ public void InvalidExpressionTests(string expression)
4455 }
4556
4657 [ Theory ]
47- [ InlineData ( "1" , typeof ( ConstantExpression ) ) ]
48- [ InlineData ( "1 + 2" , typeof ( AddExpression ) ) ]
58+ [ InlineData ( "1" , typeof ( ConstantExpression ) ) ] // Address
59+ [ InlineData ( "1 + 2" , typeof ( AddExpression ) ) ] // Calculation for address
4960 [ InlineData ( "1 - 2" , typeof ( SubtractExpression ) ) ]
5061 [ InlineData ( "1 * 2" , typeof ( MultiplyExpression ) ) ]
5162 [ InlineData ( "1 / 2" , typeof ( DivideExpression ) ) ]
5263 [ InlineData ( "1 + 2 * 3" , typeof ( AddExpression ) ) ]
53- [ InlineData ( "(1 + 2) * 3" , typeof ( MultiplyExpression ) ) ]
64+ [ InlineData ( "(1 + 2) * 3" , typeof ( MultiplyExpression ) ) ] // Calculation for address with parenthesis
5465 [ InlineData ( "1 + (2 * 3)" , typeof ( AddExpression ) ) ]
55- [ InlineData ( "(1 + (2 * 3))" , typeof ( AddExpression ) ) ]
56- [ InlineData ( "[1]" , typeof ( ReadMemoryExpression ) ) ]
66+ [ InlineData ( "(1 + (2 * 3))" , typeof ( AddExpression ) ) ]
67+ [ InlineData ( "[1]" , typeof ( ReadMemoryExpression ) ) ] // Read memory at address
5768 [ InlineData ( "[1,4]" , typeof ( ReadMemoryExpression ) ) ]
58- [ InlineData ( "[1,8]" , typeof ( ReadMemoryExpression ) ) ]
59- [ InlineData ( "<test>" , typeof ( ModuleExpression ) ) ]
60- [ InlineData ( "[<test>]" , typeof ( ReadMemoryExpression ) ) ]
69+ [ InlineData ( "[1,8]" , typeof ( ReadMemoryExpression ) ) ]
70+ [ InlineData ( "<test.exe>" , typeof ( ModuleExpression ) ) ] // Module
71+ [ InlineData ( "[<test.exe>]" , typeof ( ReadMemoryExpression ) ) ] // Read memory at address of module
72+ [ InlineData ( "{ClassName}" , typeof ( TypeExpression ) ) ] // Address of another class
6173 public void ValidExpressionTests ( string expression , Type type )
6274 {
75+ DynamicCompiler . projectContext = new TestClassList ( ) ;
6376 Check . That ( Parser . Parse ( expression ) ) . IsInstanceOfType ( type ) ;
6477 }
6578
0 commit comments