forked from parrot/parrot
/
06-opsfile.t
44 lines (34 loc) · 1.08 KB
/
06-opsfile.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!./parrot-nqp
# Copyright (C) 2010, Parrot Foundation.
pir::load_bytecode("opsc.pbc");
pir::load_bytecode("nqp-setting.pbc");
plan(7);
my $oplib := Ops::OpLib.new;
my @files := <
src/ops/core.ops
src/ops/math.ops
>;
my $f := Ops::File.new(:oplib($oplib), |@files, :core(1));
my @ops := $f.ops;
# 82 core
# 116 math
# We can generate more than 1 Ops::Op per op due args expansion.
say( "# Parsed " ~ +@ops);
# There is more than 200 ops in this 2 files.
# Feel free to update number if you change them.
ok(+@ops > 0, "Ops parsed correctly");
say('# ' ~ +@ops);
my $op := @ops[0];
#_dumper($op);
# First op should be C<end> and has code 0.
ok($op.name eq 'end', "First op is end");
ok($op<code> == 0, "... with code 0");
$op := @ops[(+@ops)-1];
ok($op.name eq 'sqrt', "Last op is tanh");
say('# ' ~ $op.name);
ok($op<code> > 84 + 116, "... with non zero code");
my $version := join(' ', |$f.version);
ok( $version ~~ /^\d+ \s \d+ \s \d+$/, "Version parsed");
say("# $version");
ok( $f.preamble ~~ /pmc_parrotlibrary.h/, "Preamble preserved");
# vim: expandtab shiftwidth=4 ft=perl6: