summaryrefslogtreecommitdiff
path: root/test/membero.adb
blob: 827e6ab0ddc83e29205b4b7fd15fcd6a161f5115 (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


--  Programmed by Jedidiah Barber
--  Licensed under the Sunset License v1.0

--  See license.txt for further details


with

    Ada.Strings.Unbounded,
    Ada.Text_IO,
    Kompsos.Pretty_Print;


procedure Membero is

    package SU  renames Ada.Strings.Unbounded;
    package TIO renames Ada.Text_IO;

    function "+"
           (Item : in String)
        return SU.Unbounded_String
    renames SU.To_Unbounded_String;


    package SKomp is new Kompsos (SU.Unbounded_String);
    use SKomp;

    package Printer is new SKomp.Pretty_Print (SU.To_String);

    Verse : World := Empty_World;

    Test_Item : constant Term := T (T (+"one") & T (+"two") & T (+"three") & T (+"four"));

begin

    TIO.Put_Line ("Test program to check if membero, and hence recursion, is working.");
    TIO.Put_Line ("Not currently designed to check for infinite recursion.");
    TIO.New_Line;
    TIO.Put_Line ("Should find all possible members of (one two three four)");

    TIO.New_Line;

    Verse.Member (Verse.Fresh ("result") & Test_Item);

    TIO.Put_Line ("Raw results:");
    TIO.Put_Line (Printer.Image (Verse));

    TIO.New_Line;

    TIO.Put_Line ("Reified results:");
    for Subst of Verse.Take_All loop
        TIO.Put_Line (Printer.Image (Resolve_First (Subst, "result")));
    end loop;

end Membero;