use of nars.subterm.UnitSubterm in project narchy by automenta.
the class AnonTest method testMixedAnonVector.
@Test
public void testMixedAnonVector() {
Term[] x = { $.varDep(1), $.varIndep(2), $.varQuery(3), Anom.the(4) };
Random rng = new XoRoShiRo128PlusRandom(1);
for (int i = 0; i < 4; i++) {
ArrayUtils.shuffle(x, rng);
assertEqual(new UnitSubterm(x[0]), new AnonVector(x[0]));
assertEqual(new TermVector2(x[0], x[1]), new AnonVector(x[0], x[1]));
assertEqual(new ArrayTermVector(x), new AnonVector(x));
}
}
use of nars.subterm.UnitSubterm in project narchy by automenta.
the class TermTest method testHashConsistent.
@Test
public void testHashConsistent() {
Term x = $.the("z");
Subterms a = new UnitSubterm(x);
Subterms b = new ArrayTermVector(x);
assertEquals(a, b);
assertEquals(a.hashCode(), b.hashCode());
assertEquals(a.hashCodeSubterms(), b.hashCodeSubterms());
assertEquals(a.toString(), b.toString());
}
use of nars.subterm.UnitSubterm in project narchy by automenta.
the class TermTest method testHashDistribution.
@Test
public void testHashDistribution() {
// one letter apart
int ah = new UnitSubterm($.the("x")).hashCode();
int bh = new UnitSubterm($.the("y")).hashCode();
assertTrue(Math.abs(ah - bh) > 1, ah + " vs " + bh);
}
use of nars.subterm.UnitSubterm in project narchy by automenta.
the class UnitCompoundTest method assertEqual.
static void assertEqual(Op o, Atomic x, Compound u) {
Compound g = CachedCompound.the(o, new UnitSubterm(x));
assertEquals(g.hashCode(), u.hashCode());
assertEquals(g.hashCodeSubterms(), u.hashCodeSubterms());
assertEquals(u, g);
assertEquals(g, u);
assertEquals(0, u.compareTo(g));
assertEquals(0, g.compareTo(u));
assertEquals(g.toString(), u.toString());
assertTrue(Arrays.equals(TermKey.termByVolume(g).array(), TermKey.termByVolume(u).array()));
assertTrue(Arrays.equals(IO.termToBytes(g), IO.termToBytes(u)));
}
use of nars.subterm.UnitSubterm in project narchy by automenta.
the class AnonTest method testAnomVector.
@Test
public void testAnomVector() {
Term[] x = { Anom.the(3), Anom.the(1), Anom.the(2) };
assertEqual(new UnitSubterm(x[0]), new AnonVector(x[0]));
assertEqual(new TermVector2(x[0], x[1]), new AnonVector(x[0], x[1]));
assertEqual(new ArrayTermVector(x), new AnonVector(x));
}
Aggregations