1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package io.github.prolobjectlink.prolog.jtrolog;
23
24 import java.util.HashMap;
25 import java.util.Map;
26
27 import javax.script.ScriptEngineManager;
28
29 import io.github.prolobjectlink.prolog.Prolog;
30 import io.github.prolobjectlink.prolog.PrologAtom;
31 import io.github.prolobjectlink.prolog.PrologDouble;
32 import io.github.prolobjectlink.prolog.PrologFloat;
33 import io.github.prolobjectlink.prolog.PrologInteger;
34 import io.github.prolobjectlink.prolog.PrologProvider;
35 import io.github.prolobjectlink.prolog.PrologTerm;
36 import io.github.prolobjectlink.prolog.PrologVariable;
37
38
39 public abstract class PrologBaseTest {
40
41 protected String male = "male";
42 protected String parent = "parent";
43 protected String female = "female";
44 protected String mother = "mother";
45 protected String sister = "sister";
46 protected String different = "different";
47 protected String offspring = "offspring";
48 protected String grandparent = "grandparent";
49 protected String predecessor = "predecessor";
50
51 protected String salary = "salary";
52 protected String employee = "employee";
53 protected String department = "department";
54
55 protected static final PrologProvider provider = Prolog.getProvider();
56 protected static final ScriptEngineManager manager = new ScriptEngineManager();
57
58 protected PrologTerm nil = provider.prologNil();
59 protected PrologTerm empty = provider.prologEmpty();
60
61 protected PrologVariable x = provider.newVariable("X", 0);
62 protected PrologVariable y = provider.newVariable("Y", 1);
63 protected PrologVariable z = provider.newVariable("Z", 2);
64
65 protected PrologVariable name = provider.newVariable("Name", 0);
66 protected PrologVariable dpto = provider.newVariable("Dpto", 1);
67 protected PrologVariable scale = provider.newVariable("Scale", 2);
68 protected PrologVariable dptoName = provider.newVariable("DepartmentName", 3);
69 protected PrologVariable money = provider.newVariable("Money", 4);
70
71 protected PrologAtom pam = provider.newAtom("pam");
72 protected PrologAtom bob = provider.newAtom("bob");
73 protected PrologAtom tom = provider.newAtom("tom");
74 protected PrologAtom liz = provider.newAtom("liz");
75 protected PrologAtom ann = provider.newAtom("ann");
76 protected PrologAtom pat = provider.newAtom("pat");
77 protected PrologAtom jim = provider.newAtom("jim");
78
79 protected PrologInteger zero = provider.newInteger();
80 protected PrologInteger one = provider.newInteger(1);
81 protected PrologInteger two = provider.newInteger(2);
82 protected PrologInteger three = provider.newInteger(3);
83 protected PrologInteger four = provider.newInteger(4);
84 protected PrologInteger five = provider.newInteger(5);
85 protected PrologInteger six = provider.newInteger(6);
86 protected PrologInteger seven = provider.newInteger(7);
87 protected PrologInteger eight = provider.newInteger(8);
88 protected PrologInteger nine = provider.newInteger(9);
89 protected PrologInteger ten = provider.newInteger(10);
90
91 protected PrologDouble gauss = provider.newDouble(.8346268);
92 protected PrologDouble aureo = provider.newDouble(1.6180339887);
93 protected PrologDouble pi = provider.newDouble(Math.PI);
94 protected PrologFloat euler = provider.newFloat(Math.E);
95
96 protected PrologAtom cat = provider.newAtom("cat");
97 protected PrologAtom bear = provider.newAtom("bear");
98 protected PrologAtom elephant = provider.newAtom("elephant");
99
100 protected PrologAtom mcardon = provider.newAtom("mcardon");
101 protected PrologAtom treeman = provider.newAtom("treeman");
102 protected PrologAtom chapman = provider.newAtom("chapman");
103 protected PrologAtom claessen = provider.newAtom("claessen");
104 protected PrologAtom petersen = provider.newAtom("petersen");
105 protected PrologAtom cohn = provider.newAtom("cohn");
106 protected PrologAtom duffy = provider.newAtom("duffy");
107
108 protected PrologAtom board = provider.newAtom("board");
109 protected PrologAtom human_resources = provider.newAtom("human_resources");
110 protected PrologAtom production = provider.newAtom("production");
111 protected PrologAtom technical_services = provider.newAtom("technical_services");
112 protected PrologAtom administration = provider.newAtom("administration");
113
114 protected PrologInteger thousand = provider.newInteger(1000);
115 protected PrologInteger thousandFiveHundred = provider.newInteger(1500);
116 protected PrologInteger twoThousand = provider.newInteger(2000);
117 protected PrologInteger twoThousandFiveHundred = provider.newInteger(2500);
118 protected PrologInteger threeThousand = provider.newInteger(3000);
119 protected PrologInteger threeThousandFiveHundred = provider.newInteger(3500);
120 protected PrologTerm fourThousand = provider.newInteger(4000);
121 protected PrologTerm fourThousandFiveHundred = provider.newInteger(4500);
122 protected PrologTerm fiveThousand = provider.newInteger(5000);
123
124 protected PrologTerm[] expecteds0 = new PrologTerm[] { mcardon, one, five, board, threeThousand };
125 protected PrologTerm[] expecteds1 = new PrologTerm[] { treeman, two, three, human_resources, twoThousand };
126 protected PrologTerm[] expecteds2 = new PrologTerm[] { chapman, one, two, board, thousandFiveHundred };
127 protected PrologTerm[] expecteds3 = new PrologTerm[] { claessen, four, one, technical_services, thousand };
128 protected PrologTerm[] expecteds4 = new PrologTerm[] { petersen, five, eight, administration,
129 fourThousandFiveHundred };
130 protected PrologTerm[] expecteds5 = new PrologTerm[] { cohn, one, seven, board, fourThousand };
131 protected PrologTerm[] expecteds6 = new PrologTerm[] { duffy, one, nine, board, fiveThousand };
132
133 protected PrologTerm[][] solution = new PrologTerm[7][5];
134
135 protected Map<String, PrologTerm> solutionMap;
136 protected Map<String, PrologTerm>[] allSolutionMap;
137
138 protected Map<String, PrologTerm>[] famillyAllSolutionMap;
139 protected Map<String, PrologTerm> famillySolutionMap = new HashMap<String, PrologTerm>();
140
141 }