1
- using System . ComponentModel . DataAnnotations ;
2
1
using System . Text . RegularExpressions ;
3
2
using AutoFixture . Xunit2 ;
4
3
using HydraScript . Domain . FrontEnd . Lexer ;
5
4
using HydraScript . Domain . FrontEnd . Lexer . Impl ;
6
5
using HydraScript . Domain . FrontEnd . Lexer . TokenTypes ;
7
6
using HydraScript . Infrastructure ;
7
+ using Xunit . Abstractions ;
8
8
9
9
namespace HydraScript . UnitTests . Domain . FrontEnd ;
10
10
11
- public class RegexLexerTests
11
+ public class RegexLexerTests ( ITestOutputHelper output )
12
12
{
13
13
private readonly RegexLexer _regexLexer = new (
14
14
new Structure < GeneratedRegexContainer > ( new TokenTypesProvider ( ) ) ,
@@ -55,10 +55,11 @@ public void GetTokens_KeywordInsideIdent_Ident(string input)
55
55
56
56
[ Theory , AutoHydraScriptData ]
57
57
public void GetTokens_MockedRegex_ValidOutput (
58
- [ MinLength ( 10 ) , MaxLength ( 25 ) ] TokenInput [ ] tokenInputs ,
58
+ LexerInput input ,
59
59
[ Frozen ] IStructure structure ,
60
60
RegexLexer lexer )
61
61
{
62
+ output . WriteLine ( input . ToString ( ) ) ;
62
63
var patterns = TokenInput . Pattern . Split ( '|' ) ;
63
64
64
65
structure . Regex . ReturnsForAnyArgs (
@@ -71,13 +72,11 @@ public void GetTokens_MockedRegex_ValidOutput(
71
72
structure . GetEnumerator ( )
72
73
. ReturnsForAnyArgs ( _ => tokenTypes . GetEnumerator ( ) ) ;
73
74
74
- var tokens = lexer . GetTokens (
75
- tokenInputs . Aggregate (
76
- TokenInput . AdditiveIdentity ,
77
- ( x , y ) => x + y ) . Value ) ;
78
- for ( var i = 0 ; i < tokenInputs . Length ; i ++ )
75
+ var tokens = lexer . GetTokens ( input . ToString ( ) ) ;
76
+ for ( var i = 0 ; i < input . Count ; i ++ )
79
77
{
80
- tokens [ i ] . Value . Should ( ) . BeEquivalentTo ( tokenInputs [ i ] . Value ) ;
78
+ output . WriteLine ( tokens [ i ] . ToString ( ) ) ;
79
+ tokens [ i ] . Value . Should ( ) . BeEquivalentTo ( input [ i ] ) ;
81
80
tokens [ i ] . Type . Should ( ) . BeOneOf ( tokenTypes ) ;
82
81
}
83
82
}
0 commit comments