-
Notifications
You must be signed in to change notification settings - Fork 135
/
04-compile.t
87 lines (62 loc) · 1.94 KB
/
04-compile.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!parrot
# $Id$
# Copyright (C) 2007-2009, Parrot Foundation.
=head1 NAME
t/compilers/pge/04-compile.t - Test our ability to compile regexes into various names
=head1 SYNOPSIS
% prove t/compilers/pge/04-compile.t
=head1 DESCRIPTION
Tests various arguments to the compiler.
=cut
.namespace []
.sub main :main
.include 'test_more.pir'
plan(4)
test_basic_compile_no_name_grammar()
test_compile_into_current_namespace()
test_compile_into_a_new_grammar()
test_compile_into_a_new_grammar_2x()
.end
.sub test_basic_compile_no_name_grammar
load_bytecode 'PGE.pbc'
.local pmc p6compiler
p6compiler = compreg 'PGE::Perl6Regex'
$P1 = p6compiler('.+')
$P2 = $P1('ok 1')
is($P2, 'ok 1', 'basic compile, no name/grammar')
.end
.sub test_compile_into_current_namespace
load_bytecode 'PGE.pbc'
.local pmc p6compiler
p6compiler = compreg 'PGE::Perl6Regex'
$P1 = p6compiler('.+', 'name'=>'xyz', 'grammar'=>'')
$P2 = 'xyz'('ok 1')
is($P2, 'ok 1', 'compile into current namespace')
.end
.sub test_compile_into_a_new_grammar
load_bytecode 'PGE.pbc'
.local pmc p6compiler
p6compiler = compreg 'PGE::Perl6Regex'
$P1 = p6compiler('.+', 'name'=>'xyz1', 'grammar'=>'PGE::Test')
$P0 = get_hll_global ['PGE'], 'Test'
$P2 = find_method $P0, 'xyz1'
$P3 = $P2('ok 1')
is($P3, 'ok 1', 'compile into a new grammar')
.end
.sub test_compile_into_a_new_grammar_2x
load_bytecode 'PGE.pbc'
.local pmc p6compiler
p6compiler = compreg 'PGE::Perl6Regex'
$P1 = p6compiler('.+', 'name'=>'abc', 'grammar'=>'PGE::Test')
$P1 = p6compiler('.+', 'name'=>'xyz2', 'grammar'=>'PGE::Test')
$P0 = get_hll_global ['PGE'], 'Test'
$P2 = find_method $P0, 'abc'
$P3 = $P2('ok 1')
is($P3, 'ok 1', 'compile into a new grammar, 2x')
.end
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 filetype=pir: