3
my knowhow NFAType is repr('NFA') { }
7
my $EDGE_CODEPOINT := 2;
8
my $EDGE_CODEPOINT_NEG := 3;
9
my $EDGE_CHARCLASS := 4;
10
my $EDGE_CHARCLASS_NEG := 5;
11
my $EDGE_CHARLIST := 6;
12
my $EDGE_CHARLIST_NEG := 7;
13
my $EDGE_SUBRULE := 8;
14
my $EDGE_CODEPOINT_I := 9;
15
my $EDGE_CODEPOINT_I_NEG := 10;
16
my $EDGE_GENERIC_VAR := 11;
18
my $empty := nqp::nfafromstatelist([[],[]],NFAType);
19
ok(nqp::istype($empty,NFAType),"nfafromstatelist creates an object of the right type");
20
my $empty_fates := nqp::nfarunproto($empty,"foo",0);
21
ok(nqp::elems($empty_fates) == 0,"an empty nfa matches no fates");
24
# the target state of a FATE transition is ignore so we can pass anything
25
my $simple := nqp::nfafromstatelist([[11],[$EDGE_CODEPOINT,102,2],[$EDGE_CODEPOINT,111,3],[$EDGE_CODEPOINT,111,4],[$EDGE_FATE,11,666]],NFAType);
27
my $matching := nqp::nfarunproto($simple,"foo",0);
28
ok(nqp::elems($matching) == 1,"we can match a simple string");
29
ok(nqp::atpos_i($matching, 0) == 11,"...and we get the right fate");
31
my $not_matching := nqp::nfarunproto($simple,"barfoo",0);
32
ok(nqp::elems($not_matching) == 0,"we don't match what we shouldn't");
34
my $matching_at_specified_pos := nqp::nfarunproto($simple,"barfoo",3);
35
ok(nqp::elems($matching_at_specified_pos) == 1,"we match at the right position");
36
ok(nqp::atpos_i($matching_at_specified_pos, 0) == 11,"...and we get the right fate");