()
| 159 | } |
| 160 | |
| 161 | static void test_7() { |
| 162 | System.out.print("test 7..."); |
| 163 | |
| 164 | String t7 = "r(f(X,X), Y)"; |
| 165 | |
| 166 | Variable vX = new Variable("X"); |
| 167 | Variable vY = new Variable("Y"); |
| 168 | Query q7 = new Query("r", new Term[] { new Compound("f", new Term[] { vX, vX }), vY }); |
| 169 | Map<String, Term>[] solutions = q7.allSolutions(); |
| 170 | |
| 171 | // Hashtable<String, Term>[] solutions = Query.allSolutions(t7); |
| 172 | |
| 173 | if (solutions.length != 2) { |
| 174 | System.out.println(t7 + " failed:"); |
| 175 | System.out.println("\tExpected: 2 solutions"); |
| 176 | System.out.println("\tGot: " + solutions.length); |
| 177 | // System.exit(1); |
| 178 | } |
| 179 | Term X = solutions[0].get("X"); |
| 180 | Term Y = solutions[0].get("Y"); |
| 181 | if (X != Y) { |
| 182 | System.out.println(t7 + " failed:"); |
| 183 | System.out.println(Util.subsToString(solutions[0])); |
| 184 | System.out.println("\tThe variables to which X and Y are bound in the first solution should be identical."); |
| 185 | // System.exit(1); |
| 186 | } |
| 187 | X = solutions[1].get("X"); |
| 188 | Y = solutions[1].get("Y"); |
| 189 | if (X == Y) { |
| 190 | System.out.println(t7 + " failed:"); |
| 191 | System.out.println(Util.subsToString(solutions[1])); |
| 192 | System.out.println("\tThe variables to which X and Y are bound in the second solution should be distinct."); |
| 193 | // System.exit(1); |
| 194 | } |
| 195 | if (X.equals(Y)) { |
| 196 | System.out.println(t7 + " failed:"); |
| 197 | System.out.println(Util.subsToString(solutions[1])); |
| 198 | System.out.println("\tThe variables to which X and Y are bound in the second solution should not be \"equal\"."); |
| 199 | // System.exit(1); |
| 200 | } |
| 201 | System.out.println("passed"); |
| 202 | } |
| 203 | |
| 204 | static void test_8() { |
| 205 | System.out.print("test 8..."); |
no test coverage detected