Esempio n. 1
0
 /**
  * Performs the assert-equals function.
  *
  * @param ctx query context
  * @return resulting value
  * @throws QueryException query exception
  */
 private Item assertEquals(final QueryContext ctx) throws QueryException {
   final byte[] str = expr.length < 3 ? null : checkStr(expr[2], ctx);
   final Iter iter1 = ctx.iter(expr[0]), iter2 = ctx.iter(expr[1]);
   final Compare comp = new Compare(info);
   Item it1, it2;
   int c = 1;
   while (true) {
     it1 = iter1.next();
     it2 = iter2.next();
     final boolean empty1 = it1 == null, empty2 = it2 == null;
     if (empty1 && empty2) return null;
     if (empty1 || empty2 || !comp.deep(it1.iter(), it2.iter())) break;
     c++;
   }
   if (str != null) throw UNIT_MESSAGE.get(info, str);
   throw new UnitException(info, UNIT_ASSERT_EQUALS, it1, it2, c);
 }
Esempio n. 2
0
 /**
  * Performs the assert function.
  *
  * @param ctx query context
  * @return resulting value
  * @throws QueryException query exception
  */
 private Item assrt(final QueryContext ctx) throws QueryException {
   final byte[] str = expr.length < 2 ? null : checkStr(expr[1], ctx);
   if (expr[0].ebv(ctx, info).bool(info)) return null;
   throw str == null ? UNIT_ASSERT.get(info) : UNIT_MESSAGE.get(info, str);
 }
Esempio n. 3
0
 /**
  * Performs the fail function.
  *
  * @param ctx query context
  * @return resulting value
  * @throws QueryException query exception
  */
 private Item fail(final QueryContext ctx) throws QueryException {
   throw UNIT_MESSAGE.get(info, checkStr(expr[0], ctx));
 }