[t][TT #1122] Convert t/op/numbert.t to PIR, mgrimes++
[parrot.git] / t / pmc / lexinfo.t
blobb24f6152b07ff06e9f605c8304fa75870bf7c0d5
1 #! parrot
2 # Copyright (C) 2006-2007, Parrot Foundation.
3 # $Id$
5 =head1 NAME
7 t/pmc/lexinfo.t - test LexInfo PMC
10 =head1 SYNOPSIS
12     % prove t/pmc/lexinfo.t
14 =head1 DESCRIPTION
16 Tests the LexInfo PMC.
18 =cut
20 .sub main :main
21     .include 'test_more.pir'
22     plan(4)
24     new_test()
25     inspect_test()
26 .end
28 .sub new_test
29     push_eh eh
30     $P0 = new ['LexInfo']
31     pop_eh
32     ok(0, "shouldn't be able to create a LexInfo without an initializer")
33     goto end
34 eh:
35     ok(1, "can't create a LexInfo without an initializer")
36 end:
37 .end
39 .sub inspect_test
40     .lex "$a", $P0
41     .lex "$b", $P1
42     
43     $P2 = new 'ParrotInterpreter'
44     $P2 = $P2['sub']
45     $P2 = $P2.'get_lexinfo'()
46     $P2 = inspect $P2, 'symbols'
47     $I0 = elements $P2
48     is($I0, 2, "correct number of symbol in introspection hash")
50     .local int have_a, have_b
51     have_a = 0
52     have_b = 0
53     $S0 = $P2[0]
54     if $S0 != "$a" goto not_a_1
55     inc have_a
56   not_a_1:
57     if $S0 != "$b" goto not_b_1
58     inc have_b
59   not_b_1:
61     $S0 = $P2[1]
62     if $S0 != "$a" goto not_a_2
63     inc have_a
64   not_a_2:
65     if $S0 != "$b" goto not_b_2
66     inc have_b
67   not_b_2:
69     is(have_a, 1, "$a symbol was in list")
70     is(have_b, 1, "$b symbol was in list")
71 .end
73 # Local Variables:
74 #   mode: pir
75 #   cperl-indent-level: 4
76 #   fill-column: 100
77 # End:
78 # vim: expandtab shiftwidth=4 ft=pir: