コード例 #1
0
ファイル: TermApiTest.java プロジェクト: emend/logic2j
 @SuppressWarnings("deprecation")
 @Test
 public void test_avoidCycle() {
   Struct cyclic = new Struct("s", Struct.createEmptyPList());
   cyclic.setArg(0, cyclic);
   try {
     cyclic.avoidCycle(new ArrayList<Term>());
     fail("Should have thrown an IllegalStateException");
   } catch (IllegalStateException e) {
     // OK
   }
 }
コード例 #2
0
ファイル: TermApiTest.java プロジェクト: emend/logic2j
 @Test
 public void test_staticallyEquals() {
   // Vars are never statically equal ...
   assertFalse(new Var("X").staticallyEquals(new Var("Y")));
   Var x1 = new Var("X");
   Var x2 = new Var("X");
   // ... even when they have the same name
   assertFalse(x1.staticallyEquals(x2));
   Struct s = new Struct("s", x1, x2);
   assertFalse(s.getArg(0).staticallyEquals(s.getArg(1)));
   // After compacting, the 2 X will be same
   Struct s2 = (Struct) TERM_API.compact(s);
   assertNotSame(s, s2);
   assertFalse(s.staticallyEquals(s2));
   assertTrue(s2.getArg(0).staticallyEquals(s2.getArg(1)));
 }