1
0
Fork 0

added more tests

This commit is contained in:
Jan Steemann 2015-03-19 18:21:00 +01:00
parent cf845bbe5e
commit 50c4682655
3 changed files with 634 additions and 23 deletions

View File

@ -125,6 +125,9 @@ namespace triagens {
if (! value.isEmpty()) {
auto it = _valueCount.find(value);
if (it == _valueCount.end()) {
TRI_IF_FAILURE("AqlItemBlock::setValue") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
_valueCount.emplace(std::make_pair(value, 1));
}
else {

View File

@ -32,9 +32,9 @@
#include "Basics/StringUtils.h"
#include "Basics/StringBuffer.h"
#include "Basics/json-utilities.h"
#include "V8/v8-globals.h"
#include "HashIndex/hash-index.h"
#include "Utils/Exception.h"
#include "V8/v8-globals.h"
#include "VocBase/edge-collection.h"
#include "VocBase/index.h"
#include "VocBase/vocbase.h"
@ -134,7 +134,10 @@ void AggregatorGroup::addValues (AqlItemBlock const* src,
else {
auto block = src->slice(firstRow, lastRow + 1);
try {
groupBlocks.push_back(block);
TRI_IF_FAILURE("AggregatorGroup::addValues") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
groupBlocks.emplace_back(block);
}
catch (...) {
delete block;
@ -378,6 +381,9 @@ void ExecutionBlock::inheritRegisters (AqlItemBlock const* src,
if (! src->getValue(row, i).isEmpty()) {
AqlValue a = src->getValue(row, i).clone();
try {
TRI_IF_FAILURE("ExecutionBlock::inheritRegisters") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
dst->setValue(0, i, a);
}
catch (...) {
@ -405,7 +411,10 @@ bool ExecutionBlock::getBlock (size_t atLeast, size_t atMost) {
return false;
}
try {
_buffer.push_back(docs);
TRI_IF_FAILURE("ExecutionBlock::getBlock") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
_buffer.emplace_back(docs);
}
catch (...) {
delete docs;
@ -536,7 +545,12 @@ int ExecutionBlock::getOrSkipSome (size_t atLeast,
// The current block is too large for atMost:
if (! skipping) {
unique_ptr<AqlItemBlock> more(cur->slice(_pos, _pos + (atMost - skipped)));
collector.push_back(more.get());
TRI_IF_FAILURE("ExecutionBlock::getOrSkipSome") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
collector.emplace_back(more.get());
more.release(); // do not delete it!
}
_pos += atMost - skipped;
@ -547,7 +561,12 @@ int ExecutionBlock::getOrSkipSome (size_t atLeast,
// half-eaten:
if (! skipping) {
unique_ptr<AqlItemBlock> more(cur->slice(_pos, cur->size()));
collector.push_back(more.get());
TRI_IF_FAILURE("ExecutionBlock::getOrSkipSome") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
collector.emplace_back(more.get());
more.release();
}
skipped += cur->size() - _pos;
@ -559,7 +578,10 @@ int ExecutionBlock::getOrSkipSome (size_t atLeast,
// The current block fits into our result and is fresh:
skipped += cur->size();
if (! skipping) {
collector.push_back(cur);
TRI_IF_FAILURE("ExecutionBlock::getOrSkipSome") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
collector.emplace_back(cur);
}
else {
delete cur;
@ -581,6 +603,9 @@ int ExecutionBlock::getOrSkipSome (size_t atLeast,
}
else if (! collector.empty()) {
try {
TRI_IF_FAILURE("ExecutionBlock::getOrSkipSomeConcatenate") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
result = AqlItemBlock::concatenate(collector);
}
catch (...) {
@ -646,10 +671,18 @@ int SingletonBlock::getOrSkipSome (size_t, // atLeast,
skipped++;
for (RegisterId reg = 0; reg < _inputRegisterValues->getNrRegs(); ++reg) {
TRI_IF_FAILURE("SingletonBlock::getOrSkipSome") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
AqlValue a = _inputRegisterValues->getValue(0, reg);
_inputRegisterValues->steal(a);
try {
TRI_IF_FAILURE("SingletonBlock::getOrSkipSomeSet") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
result->setValue(0, reg, a);
}
catch (...) {
@ -721,6 +754,10 @@ bool EnumerateCollectionBlock::moreDocuments (size_t hint) {
}
std::vector<TRI_doc_mptr_copy_t> newDocs;
TRI_IF_FAILURE("EnumerateCollectionBlock::moreDocuments") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
newDocs.reserve(hint);
@ -982,7 +1019,10 @@ int IndexRangeBlock::initialize () {
// all new AstNodes are registered with the Ast in the Query
auto e = new Expression(_engine->getQuery()->ast(), a);
try {
_allVariableBoundExpressions.push_back(e);
TRI_IF_FAILURE("IndexRangeBlock::initialize") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
_allVariableBoundExpressions.emplace_back(e);
}
catch (...) {
delete e;
@ -1020,6 +1060,9 @@ int IndexRangeBlock::initialize () {
instanciateExpression(h);
}
}
TRI_IF_FAILURE("IndexRangeBlock::initializeExpressions") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
}
catch (...) {
for (auto e : _allVariableBoundExpressions) {
@ -1306,6 +1349,10 @@ void IndexRangeBlock::sortConditions () {
for (size_t s = 0; s < n; s++) {
_sortCoords.push_back(s);
std::vector<size_t> next;
TRI_IF_FAILURE("IndexRangeBlock::sortConditions") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
next.reserve(en->_index->fields.size());
prefix.emplace_back(next);
// prefix[s][t] = position in _condition[s] corresponding to the <t>th index
@ -1314,6 +1361,10 @@ void IndexRangeBlock::sortConditions () {
for (size_t u = 0; u < _condition->at(s).size(); u++) {
auto ri = _condition->at(s)[u];
if (en->_index->fields[t].compare(ri._attr) == 0) {
TRI_IF_FAILURE("IndexRangeBlock::sortConditionsInner") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
prefix.at(s).insert(prefix.at(s).begin() + t, u);
break;
}
@ -1394,6 +1445,9 @@ std::vector<RangeInfo> IndexRangeBlock::andCombineRangeInfoVecs (
RangeInfo x = ri1.clone();
x.fuse(ri2);
if (x.isValid()){
TRI_IF_FAILURE("IndexRangeBlock::andCombineRangeInfoVecs") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
out.push_back(x);
}
}
@ -1407,13 +1461,12 @@ std::vector<RangeInfo> IndexRangeBlock::andCombineRangeInfoVecs (
/// "and" condition containing an "or" condition, which we must then distribute.
////////////////////////////////////////////////////////////////////////////////
IndexOrCondition* IndexRangeBlock::cartesian (
std::vector<std::vector<RangeInfo>> const& collector) {
IndexOrCondition* IndexRangeBlock::cartesian (std::vector<std::vector<RangeInfo>> const& collector) {
std::vector<size_t> indexes;
indexes.reserve(collector.size());
for (size_t i = 0; i < collector.size(); i++) {
indexes.push_back(0);
indexes.emplace_back(0);
}
auto out = new IndexOrCondition();
@ -1423,6 +1476,9 @@ IndexOrCondition* IndexRangeBlock::cartesian (
for (size_t i = 0; i < collector.size(); i++) {
next.push_back(collector[i][indexes[i]].clone());
}
TRI_IF_FAILURE("IndexRangeBlock::cartesian") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
out->push_back(next);
size_t j = collector.size() - 1;
while (true) {
@ -1465,6 +1521,9 @@ bool IndexRangeBlock::readIndex (size_t atMost) {
// entire index when we only want a small number of documents.
if (_documents.empty()) {
TRI_IF_FAILURE("IndexRangeBlock::readIndex") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
_documents.reserve(atMost);
}
else {
@ -1869,12 +1928,13 @@ bool IndexRangeBlock::setupHashIndexSearchValue (IndexAndCondition const& range)
}
auto shaped = TRI_ShapedJsonJson(shaper, x._lowConst.bound().json(), false);
// here x->_low->_bound = x->_high->_bound
// here x->_low->_bound == x->_high->_bound
if (shaped == nullptr) {
return false;
}
_hashIndexSearchValue._values[i] = *shaped;
// free only the pointer, but not the internals
TRI_Free(shaper->_memoryZone, shaped);
break;
}
@ -1916,6 +1976,10 @@ void IndexRangeBlock::readHashIndex (size_t atMost) {
while (nrSent < atMost) {
size_t const n = _documents.size();
TRI_IF_FAILURE("IndexRangeBlock::readHashIndex") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
TRI_LookupHashIndex(idx, &_hashIndexSearchValue, _documents, _hashNextElement, atMost);
size_t const numRead = _documents.size() - n;
@ -2074,6 +2138,9 @@ void IndexRangeBlock::readSkiplistIndex (size_t atMost) {
}
}
else {
TRI_IF_FAILURE("IndexRangeBlock::readSkiplistIndex") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
_documents.emplace_back(*(indexElement->_document));
++nrSent;
++_engine->_stats.scannedIndex;
@ -2233,6 +2300,9 @@ AqlItemBlock* EnumerateListBlock::getSome (size_t, size_t atMost) {
// requirements
// Note that _index has been increased by 1 by getAqlValue!
try {
TRI_IF_FAILURE("EnumerateListBlock::getsome") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
res->setValue(j, cur->getNrRegs(), a);
}
catch (...) {
@ -2342,6 +2412,10 @@ size_t EnumerateListBlock::skipSome (size_t atLeast, size_t atMost) {
////////////////////////////////////////////////////////////////////////////////
AqlValue EnumerateListBlock::getAqlValue (AqlValue const& inVarReg) {
TRI_IF_FAILURE("EnumerateListBlock::getAqlValue") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
switch (inVarReg._type) {
case AqlValue::JSON: {
// FIXME: is this correct? What if the copy works, but the
@ -2404,7 +2478,7 @@ CalculationBlock::CalculationBlock (ExecutionEngine* engine,
TRI_ASSERT(it2 != en->getRegisterPlan()->varInfo.end());
TRI_ASSERT(it2->second.registerId < ExecutionNode::MaxRegisterId);
_inRegs.push_back(it2->second.registerId);
_inRegs.emplace_back(it2->second.registerId);
}
// check if the expression is "only" a reference to another variable
@ -2449,6 +2523,9 @@ void CalculationBlock::fillBlockWithReference (AqlItemBlock* result) {
// care of correct freeing:
AqlValue a = result->getValueReference(i, _inRegs[0]);
try {
TRI_IF_FAILURE("CalculationBlock::fillBlockWithReference") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
result->setValue(i, _outReg, a);
}
catch (...) {
@ -2479,6 +2556,9 @@ void CalculationBlock::executeExpression (AqlItemBlock* result) {
AqlValue conditionResult = result->getValueReference(i, _conditionReg);
if (! conditionResult.isTrue()) {
TRI_IF_FAILURE("CalculationBlock::executeExpressionWithCondition") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
result->setValue(i, _outReg, AqlValue(new Json(TRI_UNKNOWN_MEM_ZONE, &Expression::NullJson, Json::NOFREE)));
continue;
}
@ -2488,6 +2568,9 @@ void CalculationBlock::executeExpression (AqlItemBlock* result) {
TRI_document_collection_t const* myCollection = nullptr;
AqlValue a = _expression->execute(_trx, docColls, data, nrRegs * i, _inVars, _inRegs, &myCollection);
try {
TRI_IF_FAILURE("CalculationBlock::executeExpression") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
result->setValue(i, _outReg, a);
}
catch (...) {
@ -2635,6 +2718,9 @@ AqlItemBlock* SubqueryBlock::getSome (size_t atLeast,
subqueryResults = executeSubquery();
TRI_ASSERT(subqueryResults != nullptr);
try {
TRI_IF_FAILURE("SubqueryBlock::getSome") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
res->setValue(i, _outReg, AqlValue(subqueryResults));
}
catch (...) {
@ -2674,7 +2760,12 @@ std::vector<AqlItemBlock*>* SubqueryBlock::executeSubquery () {
if (tmp.get() == nullptr) {
break;
}
results->push_back(tmp.get());
TRI_IF_FAILURE("SubqueryBlock::executeSubquery") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
results->emplace_back(tmp.get());
tmp.release();
}
while (true);
@ -2740,7 +2831,11 @@ bool FilterBlock::getBlock (size_t atLeast, size_t atMost) {
_chosen.reserve(cur->size());
for (size_t i = 0; i < cur->size(); ++i) {
if (takeItem(cur, i)) {
_chosen.push_back(i);
TRI_IF_FAILURE("FilterBlock::getBlock") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
_chosen.emplace_back(i);
}
}
@ -2789,7 +2884,12 @@ int FilterBlock::getOrSkipSome (size_t atLeast,
if (! skipping) {
unique_ptr<AqlItemBlock> more(cur->slice(_chosen,
_pos, _pos + (atMost - skipped)));
collector.push_back(more.get());
TRI_IF_FAILURE("FilterBlock::getOrSkipSome1") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
collector.emplace_back(more.get());
more.release();
}
_pos += atMost - skipped;
@ -2800,7 +2900,12 @@ int FilterBlock::getOrSkipSome (size_t atLeast,
// half-eaten or needs to be copied anyway:
if (! skipping) {
unique_ptr<AqlItemBlock> more(cur->steal(_chosen, _pos, _chosen.size()));
collector.push_back(more.get());
TRI_IF_FAILURE("FilterBlock::getOrSkipSome2") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
collector.emplace_back(more.get());
more.release();
}
skipped += _chosen.size() - _pos;
@ -2814,7 +2919,10 @@ int FilterBlock::getOrSkipSome (size_t atLeast,
// takes them all, so we can just hand it on:
skipped += cur->size();
if (! skipping) {
collector.push_back(cur);
TRI_IF_FAILURE("FilterBlock::getOrSkipSome3") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
collector.emplace_back(cur);
}
else {
delete cur;
@ -2838,6 +2946,9 @@ int FilterBlock::getOrSkipSome (size_t atLeast,
}
else if (collector.size() > 1) {
try {
TRI_IF_FAILURE("FilterBlock::getOrSkipSomeConcatenate") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
result = AqlItemBlock::concatenate(collector);
}
catch (...) {
@ -3096,6 +3207,10 @@ int AggregateBlock::getOrSkipSome (size_t atLeast,
try {
// emit last buffered group
if (! skipping) {
TRI_IF_FAILURE("AggregateBlock::getOrSkipSome") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
emitGroup(cur, res.get(), skipped);
++skipped;
TRI_ASSERT(skipped > 0);
@ -3254,6 +3369,9 @@ void SortBlock::doSorting () {
sum += block->size();
}
TRI_IF_FAILURE("SortBlock::doSorting") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
coords.reserve(sum);
// install the coords
@ -3261,14 +3379,14 @@ void SortBlock::doSorting () {
for (auto block : _buffer) {
for (size_t i = 0; i < block->size(); i++) {
coords.push_back(std::make_pair(count, i));
coords.emplace_back(std::make_pair(count, i));
}
count++;
}
std::vector<TRI_document_collection_t const*> colls;
for (RegisterId i = 0; i < _sortRegisters.size(); i++) {
colls.push_back(_buffer.front()->getDocumentCollection(_sortRegisters[i].first));
colls.emplace_back(_buffer.front()->getDocumentCollection(_sortRegisters[i].first));
}
// comparison function
@ -3297,7 +3415,10 @@ void SortBlock::doSorting () {
size_t sizeNext = (std::min)(sum - count, DefaultBatchSize);
AqlItemBlock* next = new AqlItemBlock(sizeNext, nrregs);
try {
newbuffer.push_back(next);
TRI_IF_FAILURE("SortBlock::doSortingInner") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
newbuffer.emplace_back(next);
}
catch (...) {
delete next;
@ -3329,6 +3450,9 @@ void SortBlock::doSorting () {
// Was already stolen for another block
AqlValue b = a.clone();
try {
TRI_IF_FAILURE("SortBlock::doSortingCache") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
cache.emplace(make_pair(a, b));
}
catch (...) {
@ -3336,6 +3460,9 @@ void SortBlock::doSorting () {
throw;
}
try {
TRI_IF_FAILURE("SortBlock::doSortingNext1") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
next->setValue(i, j, b);
}
catch (...) {
@ -3355,6 +3482,9 @@ void SortBlock::doSorting () {
// If this has worked, responsibility is now with the
// new block or indeed with us!
try {
TRI_IF_FAILURE("SortBlock::doSortingNext2") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
next->setValue(i, j, a);
}
catch (...) {
@ -3552,6 +3682,10 @@ AqlItemBlock* ReturnBlock::getSome (size_t atLeast,
if (! a.isEmpty()) {
res->steal(a);
try {
TRI_IF_FAILURE("ReturnBlock::getSome") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
stripped->setValue(i, 0, a);
}
catch (...) {
@ -3633,8 +3767,12 @@ AqlItemBlock* ModificationBlock::getSome (size_t atLeast,
if (res == nullptr) {
break;
}
TRI_IF_FAILURE("ModificationBlock::getSome") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
blocks.push_back(res);
blocks.emplace_back(res);
}
// now apply the modifications for the complete input
@ -3650,8 +3788,12 @@ AqlItemBlock* ModificationBlock::getSome (size_t atLeast,
if (res == nullptr) {
break;
}
TRI_IF_FAILURE("ModificationBlock::getSome") {
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG);
}
blocks.push_back(res);
blocks.emplace_back(res);
replyBlocks = work(blocks);
if (replyBlocks != nullptr) {
@ -3690,7 +3832,7 @@ int ModificationBlock::extractKey (AqlValue const& value,
TRI_json_t const* json = member.json();
if (TRI_IsStringJson(json)) {
key = std::string(json->_value._string.data, json->_value._string.length - 1);
key.assign(json->_value._string.data, json->_value._string.length - 1);
return TRI_ERROR_NO_ERROR;
}
}

View File

@ -0,0 +1,466 @@
/*jshint strict: true, maxlen: 200 */
/*global require, fail, assertEqual, AQL_EXECUTE */
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure scenarios
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Jan Steemann
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
var jsunity = require("jsunity");
var arangodb = require("org/arangodb");
var db = arangodb.db;
var internal = require("internal");
// -----------------------------------------------------------------------------
// --SECTION-- aql failures
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief test suite
////////////////////////////////////////////////////////////////////////////////
function ahuacatlFailureSuite () {
"use strict";
var cn = "UnitTestsAhuacatlFailures";
var c;
var count = 2000;
var assertFailingQuery = function (query) {
try {
AQL_EXECUTE(query);
fail();
}
catch (err) {
if (err.errorNum === undefined) {
require("internal").print("\nERROR: ", query, err, "\n");
}
assertEqual(internal.errors.ERROR_DEBUG.code, err.errorNum);
}
};
return {
setUp: function () {
internal.debugClearFailAt();
db._drop(cn);
c = db._create(cn);
for (var i = 0; i < count; ++i) {
c.save({ value: i, value2: i % 10 });
}
},
tearDown: function () {
internal.debugClearFailAt();
db._drop(cn);
c = null;
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testAggregateBlock1 : function () {
internal.debugSetFailAt("AggregatorGroup::addValues");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i.value INTO g RETURN [ key, g ]");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i.value2 INTO g RETURN [ key, g ]");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testAggregateBlock2 : function () {
internal.debugSetFailAt("AggregateBlock::getOrSkipSome");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i.value INTO g RETURN [ key, g ]");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i.value2 INTO g RETURN [ key, g ]");
assertFailingQuery("FOR i IN 1..10000 COLLECT key = i INTO g RETURN [ key, g ]");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testSingletonBlock1 : function () {
internal.debugSetFailAt("SingletonBlock::getOrSkipSome");
assertFailingQuery("LET a = 1 FOR i IN 1..10 RETURN a");
assertFailingQuery("FOR i IN " + c.name() + " RETURN 1");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testSingletonBlock2 : function () {
internal.debugSetFailAt("SingletonBlock::getOrSkipSomeSet");
assertFailingQuery("FOR i IN 1..10 RETURN 1");
assertFailingQuery("FOR i IN " + c.name() + " RETURN 1");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testReturnBlock : function () {
internal.debugSetFailAt("ReturnBlock::getOrSkipSome");
assertFailingQuery("RETURN 1");
assertFailingQuery("FOR i IN 1..10 RETURN 1");
assertFailingQuery("FOR i IN " + c.name() + " RETURN 1");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testSortBlock1 : function () {
internal.debugSetFailAt("SortBlock::doSorting");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i._key SORT key RETURN key");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i.value SORT key RETURN key");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i.value2 SORT key RETURN key");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testSortBlock2 : function () {
internal.debugSetFailAt("SortBlock::doSortingInner");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i._key SORT key RETURN key");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i.value SORT key RETURN key");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i.value2 SORT key RETURN key");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testSortBlock3 : function () {
internal.debugSetFailAt("SortBlock::doSortingCache");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i._key SORT key RETURN key");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i.value SORT key RETURN key");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i.value2 SORT key RETURN key");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testSortBlock4 : function () {
internal.debugSetFailAt("SortBlock::doSortingNext1");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i._key SORT key RETURN key");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i.value SORT key RETURN key");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i.value2 SORT key RETURN key");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testSortBlock5 : function () {
internal.debugSetFailAt("SortBlock::doSortingNext2");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i._key SORT key RETURN key");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i.value SORT key RETURN key");
assertFailingQuery("FOR i IN " + c.name() + " COLLECT key = i.value2 SORT key RETURN key");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testFilterBlock1 : function () {
internal.debugSetFailAt("FilterBlock::getOrSkipSome1");
assertFailingQuery("FOR i IN " + c.name() + " FILTER i.value2 == 7 RETURN i");
assertFailingQuery("FOR i IN 1..10000 FILTER i.value % 4 == 0 RETURN i");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testFilterBlock2 : function () {
internal.debugSetFailAt("FilterBlock::getOrSkipSome2");
assertFailingQuery("FOR i IN " + c.name() + " FILTER i.value2 == 7 RETURN i");
assertFailingQuery("FOR i IN 1..10000 FILTER i.value % 4 == 0 RETURN i");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testFilterBlock3 : function () {
internal.debugSetFailAt("FilterBlock::getOrSkipSome3");
assertFailingQuery("FOR i IN " + c.name() + " FILTER i.value2 == 7 RETURN i");
assertFailingQuery("FOR i IN 1..10000 FILTER i.value % 4 == 0 RETURN i");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testFilterBlock4 : function () {
internal.debugSetFailAt("FilterBlock::getOrSkipSomeConcatenate");
assertFailingQuery("FOR i IN " + c.name() + " FILTER i.value2 == 7 RETURN i");
assertFailingQuery("FOR i IN 1..10000 FILTER i.value % 4 == 0 RETURN i");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testModificationBlock : function () {
internal.debugSetFailAt("ModificationBlock::getSome");
assertFailingQuery("FOR i IN " + c.name() + " REMOVE i IN " + c.name());
assertFailingQuery("FOR i IN 1..10000 REMOVE CONCAT('test' + i) IN " + c.name() + " OPTIONS { ignoreErrors: true }");
assertFailingQuery("FOR i IN " + c.name() + " REMOVE i IN " + c.name());
assertFailingQuery("FOR i IN 1..10000 INSERT { value3: i } IN " + c.name());
assertEqual(count, c.count());
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testCalculationBlock1 : function () {
internal.debugSetFailAt("CalculationBlock::fillBlockWithReference");
assertFailingQuery("FOR i IN " + c.name() + " LET v = i RETURN v");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testCalculationBlock2 : function () {
internal.debugSetFailAt("CalculationBlock::executeExpression");
assertFailingQuery("FOR i IN " + c.name() + " LET v = i RETURN v");
assertFailingQuery("FOR i IN " + c.name() + " LET v = CONCAT(i._key, 'foo') RETURN v");
assertFailingQuery("FOR i IN " + c.name() + " LET v = i._key RETURN v");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testEnumerateListBlock1 : function () {
internal.debugSetFailAt("EnumerateListBlock::getSome");
assertFailingQuery("LET values = (FOR i IN " + c.name() + " RETURN i) FOR x IN values RETURN x");
assertFailingQuery("FOR i IN 1..10000 RETURN i");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testEnumerateListBlock2 : function () {
internal.debugSetFailAt("EnumerateListBlock::getAqlValue");
assertFailingQuery("LET values = (FOR i IN " + c.name() + " RETURN i) FOR x IN values RETURN x");
assertFailingQuery("FOR i IN 1..10000 RETURN i");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testSubqueryBlock1 : function () {
internal.debugSetFailAt("SubqueryBlock::getSome");
assertFailingQuery("LET values = (FOR i IN " + c.name() + " RETURN i) FOR x IN values RETURN x");
assertFailingQuery("LET values = (FOR i IN 1..10000 RETURN i) FOR x IN values RETURN x");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testSubqueryBlock2 : function () {
internal.debugSetFailAt("SubqueryBlock::executeSubquery");
assertFailingQuery("LET values = (FOR i IN " + c.name() + " RETURN i) FOR x IN values RETURN x");
assertFailingQuery("LET values = (FOR i IN 1..10000 RETURN i) FOR x IN values RETURN x");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testExecutionBlock1 : function () {
internal.debugSetFailAt("ExecutionBlock::inheritRegisters");
assertFailingQuery("FOR i IN " + c.name() + " FILTER i.value > 10 LIMIT 99 RETURN CONCAT(i, 'foo')");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testExecutionBlock2 : function () {
internal.debugSetFailAt("ExecutionBlock::getBlock");
assertFailingQuery("FOR i IN 1..10000 FILTER i.value % 4 == 0 LIMIT 9999 RETURN CONCAT(i, 'foo')");
assertFailingQuery("LET values = (FOR i IN " + c.name() + " RETURN i) FOR x IN values LIMIT 9999 RETURN x");
assertFailingQuery("FOR i IN " + c.name() + " FILTER i.value2 == 9 COLLECT key = i._key LIMIT 9999 RETURN key");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testExecutionBlock3 : function () {
internal.debugSetFailAt("ExecutionBlock::getOrSkipSome");
assertFailingQuery("FOR i IN 1..10000 FILTER i.value % 4 == 0 LIMIT 9999 RETURN CONCAT(i, 'foo')");
assertFailingQuery("LET values = (FOR i IN " + c.name() + " RETURN i) FOR x IN values LIMIT 9999 RETURN x");
assertFailingQuery("FOR i IN " + c.name() + " FILTER i.value2 == 9 COLLECT key = i._key LIMIT 9999 RETURN key");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testExecutionBlock4 : function () {
internal.debugSetFailAt("ExecutionBlock::getOrSkipSomeConcatenate");
assertFailingQuery("FOR i IN 1..10000 FILTER i.value % 4 == 0 LIMIT 9999 RETURN CONCAT(i, 'foo')");
assertFailingQuery("LET values = (FOR i IN " + c.name() + " RETURN i) FOR x IN values LIMIT 9999 RETURN x");
assertFailingQuery("FOR i IN " + c.name() + " LIMIT 99999 COLLECT key = i._key LIMIT 9999 RETURN key");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testEnumerateCollectionBlock : function () {
internal.debugSetFailAt("EnumerateCollectionBlock::moreDocuments");
assertFailingQuery("FOR i IN " + c.name() + " FILTER i.value2 == 9 COLLECT key = i._key RETURN key");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testIndexRangeBlock1 : function () {
c.ensureHashIndex("value");
internal.debugSetFailAt("IndexRangeBlock::initialize");
assertFailingQuery("LET f = PASSTHRU(1) FOR j IN 1..10 FOR i IN " + c.name() + " FILTER i.value == j FILTER i.value == f RETURN i");
assertFailingQuery("FOR j IN 1..10 FOR i IN " + c.name() + " FILTER i.value == j RETURN i");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testIndexRangeBlock2 : function () {
c.ensureHashIndex("value");
internal.debugSetFailAt("IndexRangeBlock::initializeExpressions");
assertFailingQuery("LET f = PASSTHRU(1) FOR j IN 1..10 FOR i IN " + c.name() + " FILTER i.value == j FILTER i.value == f RETURN i");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testIndexRangeBlock3 : function () {
c.ensureHashIndex("value", "value2");
internal.debugSetFailAt("IndexRangeBlock::sortConditions");
assertFailingQuery("FOR j IN 1..10 FOR k IN 1..2 FOR i IN " + c.name() + " FILTER i.value == j FILTER i.value2 == k RETURN i");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testIndexRangeBlock4 : function () {
c.ensureHashIndex("value", "value2");
internal.debugSetFailAt("IndexRangeBlock::sortConditionsInner");
assertFailingQuery("FOR j IN 1..10 FOR k IN 1..2 FOR i IN " + c.name() + " FILTER i.value == j FILTER i.value2 == k RETURN i");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testIndexRangeBlock5 : function () {
c.ensureHashIndex("value", "value2");
internal.debugSetFailAt("IndexRangeBlock::cartesian");
assertFailingQuery("FOR j IN 1..10 FOR k IN 1..2 FOR i IN " + c.name() + " FILTER i.value == j FILTER i.value2 == k RETURN i");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
/* TODO: make this test throw errors!
testIndexRangeBlock6 : function () {
c.ensureHashIndex("value", "value2");
internal.debugSetFailAt("IndexRangeBlock::andCombineRangeInfoVecs");
assertFailingQuery("FOR j IN 1..10 FOR k IN 1..2 FOR i IN " + c.name() + " FILTER i.value == j FILTER i.value2 == k RETURN i");
},
*/
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testIndexRangeBlock7 : function () {
c.ensureSkiplist("value", "value2");
internal.debugSetFailAt("IndexRangeBlock::readIndex");
assertFailingQuery("FOR i IN " + c.name() + " FILTER i.value == 25 RETURN i");
assertFailingQuery("FOR j IN 1..10 FOR i IN " + c.name() + " FILTER i.value == j RETURN i");
assertFailingQuery("FOR j IN 1..10 FOR k IN 1..2 FOR i IN " + c.name() + " FILTER i.value == j FILTER i.value2 == k RETURN i");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testIndexRangeBlock8 : function () {
c.ensureHashIndex("value", "value2");
internal.debugSetFailAt("IndexRangeBlock::readHashIndex");
assertFailingQuery("FOR i IN " + c.name() + " FILTER i.value == 25 && i.value2 == 5 RETURN i");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test failure
////////////////////////////////////////////////////////////////////////////////
testIndexRangeBlock9 : function () {
c.ensureSkiplist("value", "value2");
internal.debugSetFailAt("IndexRangeBlock::readSkiplistIndex");
assertFailingQuery("FOR i IN " + c.name() + " FILTER i.value == 25 && i.value2 == 5 RETURN i");
}
};
}
// -----------------------------------------------------------------------------
// --SECTION-- main
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suites
////////////////////////////////////////////////////////////////////////////////
if (internal.debugCanUseFailAt()) {
jsunity.run(ahuacatlFailureSuite);
}
return jsunity.done();
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
// End: