Search in sources :

Example 11 with ITerm

use of mb.nabl2.terms.ITerm in project nabl by metaborg.

the class HashcodeAndEqualsTest method testGenericAndSpecializedEqual.

@Test
public void testGenericAndSpecializedEqual() {
    ITerm t1 = B.newAppl(SpecializedAppl.OP, B.newString("Hello, world!"), B.newInt(42));
    ITerm t2 = ImmutableSpecializedAppl.of("Hello, world!", 42);
    assertEquals(t1.hashCode(), t2.hashCode());
    assertTrue(t1.equals(t2));
}
Also used : ITerm(mb.nabl2.terms.ITerm) Test(org.junit.Test)

Example 12 with ITerm

use of mb.nabl2.terms.ITerm in project nabl by metaborg.

the class HashcodeAndEqualsTest method testSameInts.

@Test
public void testSameInts() {
    ITerm t1 = B.newInt(1);
    ITerm t2 = B.newInt(1);
    assertEquals(t1.hashCode(), t2.hashCode());
    assertTrue(t1.equals(t2));
}
Also used : ITerm(mb.nabl2.terms.ITerm) Test(org.junit.Test)

Example 13 with ITerm

use of mb.nabl2.terms.ITerm in project nabl by metaborg.

the class HashcodeAndEqualsTest method testGenericApplEqualAfterSerialization.

@Test
public void testGenericApplEqualAfterSerialization() throws Exception {
    ITerm t1 = B.newAppl(SpecializedAppl.OP, B.newString("Hello, world!"), B.newInt(42));
    ITerm t2 = deserialize(serialize(t1));
    assertEquals(t1.hashCode(), t2.hashCode());
    assertTrue(t1.equals(t2));
}
Also used : ITerm(mb.nabl2.terms.ITerm) Test(org.junit.Test)

Example 14 with ITerm

use of mb.nabl2.terms.ITerm in project nabl by metaborg.

the class HashcodeAndEqualsTest method testSpecializedApplEqualAfterSerialization.

@Test
public void testSpecializedApplEqualAfterSerialization() throws Exception {
    ITerm t1 = ImmutableSpecializedAppl.of("Hello, world!", 42);
    ITerm t2 = deserialize(serialize(t1));
    assertEquals(t1.hashCode(), t2.hashCode());
    assertTrue(t1.equals(t2));
}
Also used : ITerm(mb.nabl2.terms.ITerm) Test(org.junit.Test)

Example 15 with ITerm

use of mb.nabl2.terms.ITerm in project nabl by metaborg.

the class HashcodeAndEqualsTest method testDifferentInts.

@Test
public void testDifferentInts() {
    ITerm t1 = B.newInt(1);
    ITerm t2 = B.newInt(2);
    assertFalse(t1.equals(t2));
}
Also used : ITerm(mb.nabl2.terms.ITerm) Test(org.junit.Test)

Aggregations

ITerm (mb.nabl2.terms.ITerm)79 Test (org.junit.Test)24 Occurrence (mb.nabl2.scopegraph.terms.Occurrence)19 Scope (mb.nabl2.scopegraph.terms.Scope)18 SolveResult (mb.nabl2.solver.ISolver.SolveResult)16 Optional (java.util.Optional)15 IMessageInfo (mb.nabl2.constraints.messages.IMessageInfo)15 ITermVar (mb.nabl2.terms.ITermVar)15 Label (mb.nabl2.scopegraph.terms.Label)14 Map (java.util.Map)12 Set (java.util.Set)10 MessageContent (mb.nabl2.constraints.messages.MessageContent)10 SolverCore (mb.nabl2.solver.SolverCore)9 IUnifier (mb.nabl2.terms.unification.IUnifier)9 Function1 (org.metaborg.util.functions.Function1)9 Lists (com.google.common.collect.Lists)8 ISolution (mb.nabl2.solver.ISolution)8 HashMultimap (com.google.common.collect.HashMultimap)7 Multimap (com.google.common.collect.Multimap)7 IConstraint (mb.nabl2.constraints.IConstraint)7