Exemple #1
0
  @Test
  public void backwardsEnqueue_success() {
    DiffList<Cons<Var, Cons<Var, Var>>, Var> startList =
        DiffList.of(Cons.of(new Var(), Cons.of(new Var(), new Var())), new Var());

    new LogicAsserter()
        .stream(
            conj(
                Queue.O.last(10, A, Queue.of(Count.of(Count.of(null)), startList)),
                Queue.O.last(20, EMPTY, A),
                same(startList.head().cdr().cdr(), null),
                same(C, startList.head())))
        .workUnits(2)
        .addRequestedVar(C)
        .startSubst()
        .put(C, Cons.list(Arrays.asList(20, 10)))
        .test();
  }
Exemple #2
0
 @Test
 public void enqueue() {
   new LogicAsserter()
       .stream(
           conj(
               Queue.O.last(42, EMPTY, A),
               Queue.O.last("1011", A, B),
               Queue.O.last(false, B, C),
               Queue.O.last('a', C, FINISH_QUEUE),
               same(null, FINISH_QUEUE.contents().hole()),
               same(D, FINISH_QUEUE.contents().head()),
               same(E, FINISH_QUEUE.size())))
       .addRequestedVar(D, E)
       .workUnits(2)
       .startSubst()
       .put(D, Cons.list(Arrays.asList(42, "1011", false, 'a')))
       .put(E, Count.of(Count.of(Count.of(Count.of(null)))))
       .test();
 }