Example #1
0
 /**
  * Performs the test-uris function.
  *
  * @param ctx query context
  * @return resulting value
  * @throws QueryException query exception
  */
 private Item testUris(final QueryContext ctx) throws QueryException {
   checkCreate(ctx);
   final ArrayList<IO> inputs = new ArrayList<>();
   final Iter ir = ctx.iter(expr[0]);
   for (Item it; (it = ir.next()) != null; ) inputs.add(checkPath(it, ctx));
   return new Suite(ctx, info).test(inputs);
 }
Example #2
0
 /**
  * Performs the test-libraries function (still experimental).
  *
  * @param ctx query context
  * @return resulting value
  * @throws QueryException query exception
  */
 private Item testLibraries(final QueryContext ctx) throws QueryException {
   checkCreate(ctx);
   final TokenList tl = new TokenList();
   final Iter ir = ctx.iter(expr[0]);
   for (Item it; (it = ir.next()) != null; ) tl.add(checkStr(it));
   return new Suite(ctx, info).test(tl);
 }
Example #3
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);
 }
Example #4
0
  /**
   * Performs the test function.
   *
   * @param ctx query context
   * @return resulting value
   * @throws QueryException query exception
   */
  private Item test(final QueryContext ctx) throws QueryException {
    final Unit unit = new Unit(ctx, info);
    if (expr.length == 0) return unit.test(sc);

    final ArrayList<StaticFunc> funcs = new ArrayList<>();
    final Iter ir = ctx.iter(expr[0]);
    for (Item it; (it = ir.next()) != null; ) {
      final FItem fi = checkFunc(it, ctx);
      if (fi.funcName() != null) {
        final StaticFunc sf = ctx.funcs.get(fi.funcName(), fi.arity(), null, true);
        if (sf != null) funcs.add(sf);
      }
    }
    return unit.test(sc, funcs);
  }