summaryrefslogtreecommitdiff
path: root/test/rat_tests-tokens.adb
blob: 95fe5ffe9ceea9b89f4de70e54c0e75f1ef691a4 (plain)
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


with Packrat.Tokens;


package body Rat_Tests.Tokens is



    type My_Labels is (One, Two, Three);
    package My_Tokens is new Packrat.Tokens (My_Labels, Character, String);





    function Adjust_Check
        return Test_Result
    is
        A : My_Tokens.Token_Type;
    begin
        declare
            B : My_Tokens.Token_Type := My_Tokens.Create (One, 1, "abc");
        begin
            A := B;
        end;
        if My_Tokens.Value (A) /= "abc" then
            return Fail;
        end if;
        return Pass;
    end Adjust_Check;





    function Equals_Check
        return Test_Result
    is
        use type My_Tokens.Token_Type;
        A : My_Tokens.Token_Type := My_Tokens.Create (One, 1, "abc");
        B : My_Tokens.Token_Type := My_Tokens.Create (One, 1, "abc");
    begin
        if A /= B then
            return Fail;
        end if;
        return Pass;
    end Equals_Check;





    function Store_Check
        return Test_Result
    is
        T : My_Tokens.Token_Type := My_Tokens.Create (One, 1, "abc");
    begin
        if My_Tokens.Label (T) /= One or else
           My_Tokens.Start (T) /= 1 or else
           My_Tokens.Value (T) /= "abc"
        then
            return Fail;
        end if;
        return Pass;
    end Store_Check;


end Rat_Tests.Tokens;