public void test_Screwed1a() throws ReSyntaxException, CompileDfaException, java.io.IOException { Nfa nfa = new Nfa("[XY](!A|M)", new Printf(true, "[%1]", 0)); DfaRun r = new DfaRun(nfa.compile(DfaRun.UNMATCHED_DROP)); // the buggy code will throw an Error here String s = r.filter("XA"); assertEquals("[A]", s); }
// exhibit problems with early implementations which picked up too // much to easily // public void test_Challenge1() // throws ReSyntaxException, CompileDfaException, java.io.IOException { // Nfa nfa = new Nfa(Nfa.NOTHING); // nfa.or("([a-z]+)@1@ *([0-9]*)@2@ *([a-z]+)@3@", // new Printf(true, "[%1] [%2] [%3]", 0)); // Dfa dfa = nfa.compile(); // String s; // s = dfa.createRun(DfaRun.UNMATCHED_DROP).filter("a 99 c"); // assertEquals("[a] [99] [c]", s); // } public void test_Challenge1a() throws ReSyntaxException, CompileDfaException, java.io.IOException { Nfa nfa = new Nfa(Nfa.NOTHING); nfa.or("(!([a-z]+)) *(!([0-9]*)) *(!([a-z]+))", new Printf(true, "[%1] [%2] [%3]", 0)); Dfa dfa = nfa.compile(DfaRun.UNMATCHED_DROP); String s; s = dfa.createRun().filter("a 99 c"); assertEquals("[a] [99] [c]", s); }
public void test_Challenge2a() throws ReSyntaxException, CompileDfaException, java.io.IOException { Nfa nfa = new Nfa(Nfa.NOTHING); nfa.or("((!([a-z]*))abc)!x", new Printf(true, "[%1]", 0)); Dfa dfa = nfa.compile(DfaRun.UNMATCHED_DROP); String s; s = dfa.createRun().filter("#zzzabcx--"); assertEquals("[zzzabc]", s); }
// Dfa dfa = nfa.compile(); // String s; // s = dfa.createRun(DfaRun.UNMATCHED_DROP).filter("..cat=1bcat=2bWRONG.."); // assertEquals("cat=1b", s); // } public void test_Or3a() throws ReSyntaxException, CompileDfaException, java.io.IOException { Nfa nfa = new Nfa(Nfa.NOTHING); nfa.or("(!(cat=1b)+)cat=2b(!WRONG)", new Printf(true, "%1", 0)); Dfa dfa = nfa.compile(DfaRun.UNMATCHED_DROP); String s; s = dfa.createRun().filter("..cat=1bcat=2bWRONG.."); assertEquals("cat=1b", s); }