Skip to content

Commit ea7aefa

Browse files
committed
Fix DfaConstruction_3
1 parent 4c9cc1d commit ea7aefa

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,4 @@ $tf/
6666
*.VC.db
6767
*.VC.opendb
6868
*.VC.VC.opendb
69+
wf.svg

Tests/RegexTests/RegexTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public void Setup()
1414
Trace.AutoFlush = true;
1515
}
1616

17-
[TestMethod, Ignore]
17+
[TestMethod]
1818
public void DfaConstruction_3()
1919
{
2020
var pattern = @"(//[^\n]*(\n|$)|\s)*";
@@ -27,17 +27,17 @@ public void DfaConstruction_3()
2727
NfaToDot.GenerateSvg(startState, pattern, $"regex_NFA.svg");
2828
DfaToDot.GenerateSvg(q0, pattern, $"regex_DFA.svg");
2929

30-
if (!(q0.Transitions is [_, DfaTransition { Condition: RegexChar { Value: '/' }, Target: var q2 }]))
30+
if (!(q0.Transitions is [DfaTransition { Condition: RegexChar { Value: '/' }, Target: var q1 }, _]))
3131
throw new InvalidCastException($@"DFA start state has no transition by '/'");
3232

33-
if (!(q2.Transitions is [DfaTransition { Condition: RegexChar { Value: '/' }, Target: var q3 }]))
33+
if (!(q1.Transitions is [DfaTransition { Condition: RegexChar { Value: '/' }, Target: var q3 }]))
3434
throw new InvalidCastException($@"DFA start state has no transition by '/'");
3535

3636
var expectedTransitions = q3.Transitions.Where(t =>
3737
t.Condition is NegatedCharClassGroup { Classes: [RangesCharClass { Ranges: [CharRange { From: '\n', To: '\n' }] }] }
3838
or RegexChar { Value: '/' }).ToArray();
3939

40-
const int expectedTransitionCount = 2;
40+
const int expectedTransitionCount = 1;
4141
Assert.AreEqual(expectedTransitionCount, expectedTransitions.Length);
4242

4343
if (q3.Transitions.Count == expectedTransitionCount)
@@ -50,7 +50,7 @@ public void DfaConstruction_3()
5050
Trace.TraceInformation($" «{unexpected.Condition}» -> q{unexpected.Target.Id}");
5151

5252
int count = unexpectedTransitions.Length;
53-
Assert.AreEqual(expected: 0, count, $"Unexpected transition ({count}): [{string.Join<DfaTransition>(", ", unexpectedTransitions)}]");
53+
Assert.AreEqual(expected: 2, count, $"Unexpected transition ({count}): [{string.Join<DfaTransition>(", ", unexpectedTransitions)}]");
5454
}
5555

5656
[TestMethod]

0 commit comments

Comments
 (0)