~ubuntu-branches/ubuntu/vivid/nqp/vivid-proposed

« back to all changes in this revision

Viewing changes to t/nqp/74-nfa.t

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2013-11-01 12:09:18 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20131101120918-kx51sl0sxl3exsxi
Tags: 2013.10-1
* New upstream release
* Bump versioned (Build-)Depends on parrot
* Update patches
* Install new README.pod
* Fix vcs-field-not-canonical
* Do not install rubyish examples
* Do not Depends on parrot-devel anymore
* Add 07_disable-serialization-tests.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
plan(7);
 
2
 
 
3
my knowhow NFAType is repr('NFA') { }
 
4
 
 
5
my $EDGE_FATE            := 0;
 
6
my $EDGE_EPSILON         := 1;
 
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;
 
17
 
 
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");
 
22
 
 
23
{
 
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); 
 
26
 
 
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");
 
30
 
 
31
  my $not_matching := nqp::nfarunproto($simple,"barfoo",0);
 
32
  ok(nqp::elems($not_matching) == 0,"we don't match what we shouldn't");
 
33
 
 
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");
 
37
}
 
38
 
 
39
 
 
40