Debian Codegraph @

t/deprecated1.t

raw
1 #!perl
2 # Copyright 2022 Jeffrey Kegler
3 # This file is part of Marpa::R2. Marpa::R2 is free software: you can
4 # redistribute it and/or modify it under the terms of the GNU Lesser
5 # General Public License as published by the Free Software Foundation,
6 # either version 3 of the License, or (at your option) any later version.
7 #
8 # Marpa::R2 is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser
14 # General Public License along with Marpa::R2. If not, see
15 # http://www.gnu.org/licenses/.
16
17 # !!! WARNING !!!
18 # The code in this test uses deprecated methods, techniques, etc.
19 # Please DO NOT USE IT AS AN EXAMPLE
20 # Thanks
21
22 use 5.010001;
23 use strict;
24 use warnings;
25
26 use Test::More tests => 2;
27
28 use lib 'inc';
29 use Marpa::R2::Test;
30 use English qw( -no_match_vars );
31 use Fatal qw( close open );
32 use Marpa::R2;
33
34 # Test the deprecated, zero-argument form
35 # of the thin grammar constructor.
36 my $grammar = Marpa::R2::Thin::G->new();
37
38 # Carry on with it a little ways,
39 # just to show that the recognizer starts out
40 # sane
41
42 my $symbol_S = $grammar->symbol_new();
43 my $symbol_a = $grammar->symbol_new();
44 $grammar->start_symbol_set($symbol_S);
45
46 $grammar->rule_new( $symbol_S, [ $symbol_a, $symbol_a ] );
47
48 $grammar->precompute();
49
50 my $recce = Marpa::R2::Thin::R->new($grammar);
51 $recce->start_input();
52 $recce->alternative( $symbol_a, 1, 1 );
53 $recce->earleme_complete();
54 my @terminals = $recce->terminals_expected();
55
56 Test::More::is( ( scalar @terminals ), 1, 'count of terminals expected' );
57 Test::More::is( $terminals[0], $symbol_a, 'expected terminal' );
58
59 # Local Variables:
60 # mode: cperl
61 # cperl-indent-level: 4
62 # fill-column: 100
63 # End:
64 # vim: expandtab shiftwidth=4: