Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Formalize the regex unit test
- Loading branch information
Showing
3 changed files
with
45 additions
and
36 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
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
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 |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| using Niecza; | ||
| using System; | ||
|
|
||
| public class RxUnitTest { | ||
| private static SubInfo TestSI = new SubInfo(TestC); | ||
| private static Frame TestC(Frame th) { | ||
| if (Kernel.TraceCont) Console.WriteLine("At {0}", th.ip); | ||
| switch (th.ip) { | ||
| case 0: | ||
| th.rx = new RxFrame(Kernel.MockBox(new Cursor("aaaaab"))); | ||
| th.rx.OpenQuant(); | ||
| goto case 1; | ||
| case 1: | ||
| th.rx.PushBacktrack("*", 3); | ||
| th.ip = 2; | ||
| return th.rx.ExactOne(th, 'a'); | ||
| case 2: | ||
| th.rx.IncQuant(); | ||
| goto case 1; | ||
| case 3: | ||
| th.rx.CloseQuant(); | ||
| th.ip = 4; | ||
| return th.rx.Exact(th, "ab"); | ||
| case 4: | ||
| System.Console.WriteLine("Match!"); | ||
| return null; | ||
| default: | ||
| System.Console.WriteLine("Bad IP"); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| public static void Main() { | ||
| Frame fr = new Frame(null, null, TestSI); | ||
|
|
||
| while (fr != null) | ||
| fr = fr.Continue(); | ||
| } | ||
| } |