MCPcopy Create free account
hub / github.com/BaseXdb/basex / check

Method check

basex-core/src/main/java/org/basex/core/Sandbox.java:272–292  ·  view source on GitHub ↗

Checks the query plan and the result. @param query query @param expected result or null for no comparison @param tests queries on the query plan

(final String query, final Object expected, final String... tests)

Source from the content-addressed store, hash-verified

270 * @param tests queries on the query plan
271 */
272 protected static void check(final String query, final Object expected, final String... tests) {
273 try(QueryProcessor qp = new QueryProcessor(query, context)) {
274 qp.optimize();
275 final FNode plan = qp.toXml();
276 // compare result
277 if(expected != null) {
278 compare(query, qp.value().serialize().toString(), expected, plan);
279 }
280 // check syntax tree
281 for(final String test : tests) {
282 final FNode doc = FDoc.build().node(plan).finish();
283 try(QueryProcessor qp2 = new QueryProcessor(test, context).context(doc)) {
284 if(qp2.value() != Bln.TRUE) fail(Prop.NL + "QUERY: " + query + Prop.NL +
285 "OPTIMIZED: " + qp.qc.main + Prop.NL + "TEST: " + test + Prop.NL + serialize(plan));
286 }
287 }
288 } catch(final QueryException | QueryIOException ex) {
289 Util.stack(ex);
290 fail(ex);
291 }
292 }
293
294 /**
295 * Checks types at runtime.

Callers

nothing calls this directly

Calls 11

compareMethod · 0.95
serializeMethod · 0.95
buildMethod · 0.95
stackMethod · 0.95
toStringMethod · 0.65
optimizeMethod · 0.45
toXmlMethod · 0.45
valueMethod · 0.45
finishMethod · 0.45
nodeMethod · 0.45
contextMethod · 0.45

Tested by

no test coverage detected