Skip to content

Commit

Permalink
test for parrot opcodes
Browse files Browse the repository at this point in the history
Improve test for finding documented opcodes
  • Loading branch information
coke committed Oct 3, 2013
1 parent 2b8f9e3 commit c0c8267
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion t/docs/opcodes.t
Expand Up @@ -6,7 +6,7 @@ my %documented_ops := nqp::hash();

my @doc_lines := nqp::split("\n", nqp::readallfh(nqp::open("docs/ops.markdown","r")));
for @doc_lines -> $line {
next unless $line ~~ / ^ '* ' /;
next unless $line ~~ / ^ '* ' .* '(' /;
$line := nqp::substr2($line, 3);
$line := nqp::split("(", $line)[0];
%documented_ops{$line} := 1 ;
Expand All @@ -30,3 +30,22 @@ for %jvm_ops -> $jvm_op {
for %documented_ops -> $doc_op {
ok(%jvm_ops{$doc_op}, "documented op '$doc_op' exists in the JVM");
}

my %pvm_ops := nqp::hash();
my @pvm_lines := nqp::split("\n", nqp::readallfh(nqp::open("src/vm/parrot/QAST/Operations.nqp","r")));
for @pvm_lines -> $line {
next unless $line ~~ / 'add_core_op' | 'add_core_pirop_mapping' /;
$line := nqp::split("'", $line)[1];
next unless nqp::chars($line);
%pvm_ops{$line} := 1;
}

# All the pvm ops must be documented

for %pvm_ops -> $pvm_op {
ok(%documented_ops{$pvm_op}, "PVM op '$pvm_op' is documented");
}

for %documented_ops -> $doc_op {
ok(%pvm_ops{$doc_op}, "documented op '$doc_op' exists in the PVM");
}

0 comments on commit c0c8267

Please sign in to comment.