Search in sources :

Example 1 with CompoundLight

use of nars.term.compound.CompoundLight in project narchy by automenta.

the class TermListTest method assertReallyEquals.

static void assertReallyEquals(String s) {
    Subterms immutable = $.$$(s).subterms();
    TermList mutable = new TermList(immutable);
    assertNotSame(immutable, mutable);
    assertNotEquals(immutable.getClass(), mutable.getClass());
    assertEquals(immutable, mutable);
    assertEquals(mutable, immutable);
    assertEquals(mutable, mutable);
    assertEquals(immutable, immutable);
    if (immutable.subs() > 1) {
        assertNotEquals(mutable.reversed(), mutable);
        assertNotEquals(immutable.reversed(), mutable);
    }
    assertEquals(mutable.reversed(), immutable.reversed());
    assertEquals(immutable.toString(), mutable.toString());
    assertEquals(0, Subterms.compare(mutable, immutable));
    assertEquals(0, Subterms.compare(mutable, mutable));
    assertEquals(0, Subterms.compare(immutable, mutable));
    assertEquals(immutable.hashCode(), mutable.hashCode());
    assertEquals(immutable.hashCodeSubterms(), mutable.hashCodeSubterms());
    assertEquals(immutable.subs(), mutable.subs());
    assertEquals(immutable.volume(), mutable.volume());
    assertEquals(immutable.complexity(), mutable.complexity());
    assertEquals(immutable.structure(), mutable.structure());
    assertEquals(immutable, mutable.the());
    Subterms[] ab = { mutable, immutable };
    for (Subterms a : ab) {
        for (Subterms b : ab) {
            TermTest.assertReallyEquals(CachedCompound.the(PROD, a), new CompoundLight(PROD, b));
            TermTest.assertReallyEquals(CachedCompound.the(SETe, a), new CompoundLight(SETe, b));
            assertNotEquals(CachedCompound.the(PROD, a), new CompoundLight(SETi, b));
        }
    }
}
Also used : CompoundLight(nars.term.compound.CompoundLight) TermList(nars.subterm.util.TermList)

Aggregations

TermList (nars.subterm.util.TermList)1 CompoundLight (nars.term.compound.CompoundLight)1