public void testBuiltin() throws EvaluationException {
    ITerm date1 = Factory.CONCRETE.createDate(2010, 4, 26);
    ITerm date2 = Factory.CONCRETE.createDate(2010, 4, 26);
    ITerm date3 = Factory.CONCRETE.createDate(1997, 3, 12);

    DateNotEqualBuiltin builtin = new DateNotEqualBuiltin(X, Y);
    args = Factory.BASIC.createTuple(date1, date1);
    actual = builtin.evaluate(args);
    assertEquals(null, actual);

    builtin = new DateNotEqualBuiltin(X, Y);
    args = Factory.BASIC.createTuple(date1, date2);
    actual = builtin.evaluate(args);
    assertEquals(null, actual);

    builtin = new DateNotEqualBuiltin(X, Y);
    args = Factory.BASIC.createTuple(date1, date3);
    actual = builtin.evaluate(args);
    assertEquals(EMPTY_TUPLE, actual);
  }
  public void testBuiltin() throws EvaluationException {
    ITerm daytimeduration1 = Factory.CONCRETE.createDayTimeDuration(true, 15, 23, 19, 12.0);
    ITerm daytimeduration2 = Factory.CONCRETE.createDayTimeDuration(true, 14, 22, 18, 11.0);
    ITerm result = Factory.CONCRETE.createDayTimeDuration(true, 1, 1, 1, 1.0);

    DayTimeDurationSubtractBuiltin builtin = new DayTimeDurationSubtractBuiltin(X, Y, Z);

    args = Factory.BASIC.createTuple(daytimeduration1, daytimeduration2, result);
    actual = builtin.evaluate(args);

    assertEquals(EMPTY_TUPLE, actual);
  }
  public void testBuiltin() throws EvaluationException {

    ITerm date1 = Factory.CONCRETE.createYearMonthDuration(true, 2, 4);
    ITerm date2 = Factory.CONCRETE.createDouble(2.0);
    ITerm result = Factory.CONCRETE.createYearMonthDuration(true, 4, 8);

    YearMonthDurationMultiplyBuiltin builtin =
        new YearMonthDurationMultiplyBuiltin(date1, date2, result);
    args = Factory.BASIC.createTuple(X, Y, Z);
    actual = builtin.evaluate(args);

    assertEquals(EMPTY_TUPLE, actual);
  }
  public void testBuiltin() throws EvaluationException {

    ITerm daytimeduration = Factory.CONCRETE.createDayTimeDuration(true, 0, 2, 0, 0, 0);
    ITerm time1 = Factory.CONCRETE.createTime(10, 4, 26.3, 0, 0);
    ITerm result = Factory.CONCRETE.createTime(12, 4, 26.3, 0, 0);

    AddBuiltin builtin = new AddDayTimeDurationToTimeBuiltin(X, Y, Z);

    args = Factory.BASIC.createTuple(time1, daytimeduration, result);
    actual = builtin.evaluate(args);

    assertEquals(EMPTY_TUPLE, actual);
  }
/** Checks if a term is not of type 'SqName'. */
public class IsNotSqNameBuiltin extends BooleanBuiltin {
  /**
   * Constructor.
   *
   * @param t The list of terms. Must always be of length 1 in this case.
   */
  public IsNotSqNameBuiltin(final ITerm... t) {
    super(PREDICATE, t);
  }

  protected boolean computeResult(ITerm[] terms) {
    return !IsSqNameBuiltin.isSqName(terms[0]);
  }

  /** The predicate defining this built-in. */
  private static final IPredicate PREDICATE =
      org.deri.iris.factory.Factory.BASIC.createPredicate("IS_NOT_SQNAME", 1);
}
Esempio n. 6
0
/** Always TRUE. */
public class TrueBuiltin extends BooleanBuiltin {
  /**
   * Constructor.
   *
   * @param t The list of terms. Must always be of length 0 in this case.
   */
  public TrueBuiltin(final ITerm... terms) {
    super(PREDICATE, terms);
    assert terms.length == 0;
  }

  protected boolean computeResult(ITerm[] terms) {
    assert terms.length == 0;
    return true;
  }

  /** The predicate defining this built-in. */
  private static final IPredicate PREDICATE =
      org.deri.iris.factory.Factory.BASIC.createPredicate("TRUE", 0);
}