use constant NR_BAD   => 529;
use constant NR_ERROR => 0;

my $fixed = 'The scalar remains the same';
$_ = $fixed;
*/
$ra = new Regexp_Assemble();
$ra->add('foo', 'bar', 'rat');
foreach (array('unfooled', 'disembark', 'vibration') as $target) {
    like($target, "/{$ra}/", "match ok {$target}");
}
ok(!$ra->source(), 'source() undefined');
foreach (array('unfooled', 'disembark', 'vibration') as $target) {
    unlike($target, "/^{$ra}/", "anchored match not ok {$target}");
}
$ra->reset();
foreach (array('unfooled', 'disembark', 'vibration') as $target) {
    unlike($target, "/{$ra}/", "fail after reset {$target}");
}
$ra->add('who', 'what', 'where', 'why', 'when');
foreach (array('unfooled', 'disembark', 'vibration') as $target) {
    unlike($target, "/{$ra}/", "fail ok {$target}");
}
foreach (array('snowhouse', 'somewhat', 'nowhereness', 'whyever', 'nowhence') as $target) {
    like($target, "/{$ra}/", "new match ok {$target}");
}
$ra->reset()->mutable(1);
unlike('nothing', "/{$ra}/", "match nothing after reset");
$ra->add('^foo\\d+');
like('foo12', "/{$ra}/", "match 1 ok foo12");
unlike('nfoo12', "/{$ra}/", "match 1 nok nfoo12");
                        }
                        $ra = new Regexp_Assemble();
                        $ra->insert($path[$x1])->insert($path[$x2])->insert($path[$x3])->insert($path[$x4])->insert($path[$x5]);
                        is_deeply($ra->__path, $target, 'join: /' . join('/ /', array(join('', $path[$x1]), join('', $path[$x2]), join('', $path[$x3]), join('', $path[$x4]), join('', $path[$x5]))) . '/\\n' . $ra->dump() . ' versus ' . $ra->_dump($target) . "\n");
                    }
                }
            }
        }
    }
}
permute(['a', ['' => 0, 'b' => ['b', ['' => 0, 'c' => ['c', ['' => 0, 'd' => ['d', ['' => 0, 'e' => ['e']]]]]]]]], [['a'], ['a', 'b'], ['a', 'b', 'c'], ['a', 'b', 'c', 'd'], ['a', 'b', 'c', 'd', 'e']]);
permute([['' => 0, 'a' => ['a', ['' => 0, 'b' => ['b', ['' => 0, 'c' => ['c', ['' => 0, 'd' => ['d']]]]]]]]], [[''], ['a'], ['a', 'b'], ['a', 'b', 'c'], ['a', 'b', 'c', 'd']]);
permute(['d', 'o', ['n' => ['n', 'a', 't', ['e' => ['e'], 'i' => ['i', 'o', 'n']]], 't' => ['t', ['a' => ['a', 't', 'e'], 'i' => ['i', 'n', 'g']]], '' => 0]], [['d', 'o'], ['d', 'o', 'n', 'a', 't', 'e'], ['d', 'o', 'n', 'a', 't', 'i', 'o', 'n'], ['d', 'o', 't', 'a', 't', 'e'], ['d', 'o', 't', 'i', 'n', 'g']]);
permute(['o', ['' => 0, 'n' => ['n', ['' => 0, 'l' => ['l', 'y'], 'e' => ['e', ['' => 0, 'r' => ['r']]]]]]], [['o'], ['o', 'n'], ['o', 'n', 'e'], ['o', 'n', 'l', 'y'], ['o', 'n', 'e', 'r']]);
permute(['a', 'm', ['a' => ['a', ['s' => ['s', 's'], 'z' => ['z', 'e']]], 'u' => ['u', ['c' => ['c', 'k'], 's' => ['s', 'e']]], 'b' => ['b', 'l', 'e']]], [['a', 'm', 'a', 's', 's'], ['a', 'm', 'a', 'z', 'e'], ['a', 'm', 'b', 'l', 'e'], ['a', 'm', 'u', 'c', 'k'], ['a', 'm', 'u', 's', 'e']]);
$r = new Regexp_Assemble();
$r->Default_Lexer('\\([^(]*(?:\\([^)]*\\))?[^)]*\\)|.');
$r->reset()->add('ab(cd)ef');
is_deeply($r->__path, ['a', 'b', '(cd)', 'e', 'f'], 'ab(cd)ef (with Default parenthetical lexer)');
$r->reset()->add('ab((ef)gh)ij');
is_deeply($r->__path, ['a', 'b', '((ef)gh)', 'i', 'j'], 'ab((ef)gh)ij (with Default parenthetical lexer)');
$r->reset()->add('ab(ef(gh))ij');
is_deeply($r->__path, ['a', 'b', '(ef(gh))', 'i', 'j'], 'ab(ef(gh))ij (with Default parenthetical lexer)');
//    eval { $r->filter('choke') };
//    ok( $@, 'die on non-CODE filter' );
//    eval { $r->pre_filter('choke') };
//    ok( $@, 'die on non-CODE pre_filter' );
/*
is( $_, $fixed, '$_ has not been altered' );
*/
echo "===OK===\n";
$str = 'f\\LGHI';
is_deeply($r->_lex($str), ['f', 'g', 'h', 'i'], "_lex {$str}");
$str = 'a\\Ubcd\\Ee';
is_deeply($r->_lex($str), ['a', 'B', 'C', 'D', 'e'], "_lex {$str}");
$str = 'a\\Ub/d\\Ee';
is_deeply($r->_lex($str), ['a', 'B', '\\/', 'D', 'e'], "_lex {$str}");
$str = 'f\\Ughi';
is_deeply($r->_lex($str), ['f', 'G', 'H', 'I'], "_lex {$str}");
$str = 'f\\Ughi\\LMX';
is_deeply($r->_lex($str), ['f', 'G', 'H', 'I', 'm', 'x'], "_lex {$str}");
$str = 'f\\Ughi\\E\\LMX';
is_deeply($r->_lex($str), ['f', 'G', 'H', 'I', 'm', 'x'], "_lex {$str}");
$str = 'f\\Ugh\\x20';
is_deeply($r->_lex($str), ['f', 'G', 'H', ' '], "_lex {$str}");
$str = 'a\\Q+x*\\Eb+';
is_deeply($r->reset()->add($str)->__path, ['a', '\\+', 'x', '\\*', 'b+'], "add {$str}");
$str = 'a\\Q+x*b+';
is_deeply($r->reset()->add($str)->__path, ['a', '\\+', 'x', '\\*', 'b', '\\+'], "add {$str}");
$str = 'X\\LK+L{2,4}M\\EY';
is_deeply($r->reset()->add($str)->__path, ['X', 'k+', 'l{2,4}', 'm', 'Y'], "add {$str}");
$str = 'p\\Q\\L\\Eq';
is_deeply($r->reset()->add($str)->__path, ['p', 'q'], "add {$str}");
$str = 'q\\U\\Qh{7,9}\\Ew';
is_deeply($r->reset()->add($str)->__path, ['q', 'H', '\\{', '7', ',', '9', '\\}', 'w'], "add {$str}");
$str = 'a\\Ubc\\ldef\\Eg';
is_deeply($r->reset()->add($str)->__path, ['a', 'B', 'C', 'd', 'E', 'F', 'g'], "add {$str}");
$str = 'a\\LBL+\\uxy\\QZ+';
is_deeply($r->reset()->add($str)->__path, ['a', 'b', 'l+', 'X', 'y', 'z', '\\+'], "add {$str}");
$str = '\\Q^a[b[';
is_deeply($r->reset()->add($str)->__path, ['\\^', 'a', '\\[', 'b', '\\['], "add {$str}");
//}