diff --git a/js/client/tests/shell/shell-client.js b/js/client/tests/shell/shell-client.js index ee818753fc..397eb56d61 100644 --- a/js/client/tests/shell/shell-client.js +++ b/js/client/tests/shell/shell-client.js @@ -1,214 +1,215 @@ -/*jshint globalstrict:false, strict:false */ -/*global assertEqual, assertNotEqual, - print, print_plain, COMPARE_STRING, NORMALIZE_STRING, - help, start_pager, stop_pager, start_pretty_print, stop_pretty_print, start_color_print, stop_color_print */ +/* jshint globalstrict:false, strict:false */ +/* global assertEqual, assertNotEqual, + print, print_plain, COMPARE_STRING, NORMALIZE_STRING, + help, start_pager, stop_pager, start_pretty_print, stop_pretty_print, start_color_print, stop_color_print */ -//////////////////////////////////////////////////////////////////////////////// -/// @brief tests for client-specific functionality -/// -/// @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 -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tests for client-specific functionality +// / +// / @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 db = require("@arangodb").db; +var jsunity = require('jsunity'); +var db = require('@arangodb').db; -//////////////////////////////////////////////////////////////////////////////// -/// @brief test suite -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test suite +// ////////////////////////////////////////////////////////////////////////////// function clientTestSuite () { 'use strict'; return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief set up -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief set up +// ////////////////////////////////////////////////////////////////////////////// - setUp : function () { + setUp: function () { }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief tear down -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tear down +// ////////////////////////////////////////////////////////////////////////////// - tearDown : function () { + tearDown: function () { }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test global help function -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test global help function +// ////////////////////////////////////////////////////////////////////////////// - testHelp : function () { + testHelp: function () { help(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test start_pager function -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test start_pager function +// ////////////////////////////////////////////////////////////////////////////// - testPagerStart : function () { + testPagerStart: function () { start_pager(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test stop_pager function -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test stop_pager function +// ////////////////////////////////////////////////////////////////////////////// - testPagerStop : function () { + testPagerStop: function () { stop_pager(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test start_pager function -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test start_pager function +// ////////////////////////////////////////////////////////////////////////////// - testPagerStartStart : function () { + testPagerStartStart: function () { start_pager(); start_pager(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test stop_pager function -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test stop_pager function +// ////////////////////////////////////////////////////////////////////////////// - testPagerStopStop : function () { + testPagerStopStop: function () { stop_pager(); stop_pager(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test start_pretty_print function -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test start_pretty_print function +// ////////////////////////////////////////////////////////////////////////////// - testPrettyStart : function () { + testPrettyStart: function () { start_pretty_print(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test stop_pretty_print function -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test stop_pretty_print function +// ////////////////////////////////////////////////////////////////////////////// - testPrettyStop : function () { + testPrettyStop: function () { stop_pretty_print(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test start_color_print function -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test start_color_print function +// ////////////////////////////////////////////////////////////////////////////// - testColorStart : function () { + testColorStart: function () { start_color_print(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test start_color_print function -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test start_color_print function +// ////////////////////////////////////////////////////////////////////////////// - testColorStartArg : function () { + testColorStartArg: function () { start_color_print(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test stop_color_print function -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test stop_color_print function +// ////////////////////////////////////////////////////////////////////////////// - testColorStop : function () { + testColorStop: function () { stop_color_print(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test print function -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test print function +// ////////////////////////////////////////////////////////////////////////////// - testPrint : function () { + testPrint: function () { print(true); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test print_plain function -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test print_plain function +// ////////////////////////////////////////////////////////////////////////////// - testPrintPlain : function () { + testPrintPlain: function () { print_plain(true); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test COMPARE_STRING function -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test COMPARE_STRING function +// ////////////////////////////////////////////////////////////////////////////// - testICU_Compare : function () { - var nfc = "Gr\u00FC\u00DF Gott."; - var nfd = "Gru\u0308\u00DF Gott."; + testICU_Compare: function () { + var nfc = 'Gr\u00FC\u00DF Gott.'; + var nfd = 'Gru\u0308\u00DF Gott.'; assertNotEqual(nfc, nfd); assertNotEqual(COMPARE_STRING(nfc, nfd), true); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test NORMALIZE_STRING function -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test NORMALIZE_STRING function +// ////////////////////////////////////////////////////////////////////////////// - testICU_Normalize : function () { - var nfc = "Gr\u00FC\u00DF Gott."; - var nfd = "Gru\u0308\u00DF Gott."; + testICU_Normalize: function () { + var nfc = 'Gr\u00FC\u00DF Gott.'; + var nfd = 'Gru\u0308\u00DF Gott.'; assertNotEqual(nfc, nfd); assertEqual(NORMALIZE_STRING(nfd), nfc); - assertEqual(NORMALIZE_STRING(nfd), "Grüß Gott."); + assertEqual(NORMALIZE_STRING(nfd), 'Grüß Gott.'); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test skiplist sorting -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test skiplist sorting +// ////////////////////////////////////////////////////////////////////////////// - testICU_Compare_Skiplist_Sorting : function () { - db._drop("ICU_SORTED"); - db._create("ICU_SORTED"); - db.ICU_SORTED.ensureSkiplist("test"); - db.ICU_SORTED.save({ test : "äää" }); - db.ICU_SORTED.save({ test : "aaa" }); - db.ICU_SORTED.save({ test : "aab" }); - db.ICU_SORTED.save({ test : "äaa" }); - db.ICU_SORTED.save({ test : "äää" }); - db.ICU_SORTED.save({ test : "Aaa" }); + testICU_Compare_Skiplist_Sorting: function () { + db._drop('ICU_SORTED'); + db._create('ICU_SORTED'); + db.ICU_SORTED.ensureSkiplist('test'); + db.ICU_SORTED.save({ test: 'äää' }); + db.ICU_SORTED.save({ test: 'aaa' }); + db.ICU_SORTED.save({ test: 'aab' }); + db.ICU_SORTED.save({ test: 'äaa' }); + db.ICU_SORTED.save({ test: 'äää' }); + db.ICU_SORTED.save({ test: 'Aaa' }); - var y = db.ICU_SORTED.range("test", "A", "z") ; + var y = db.ICU_SORTED.range('test', 'A', 'z'); - assertEqual(y.next().test, "Aaa"); - assertEqual(y.next().test, "aaa"); - assertEqual(y.next().test, "äaa"); - assertEqual(y.next().test, "äää"); - assertEqual(y.next().test, "äää"); - assertEqual(y.next().test, "aab"); + assertEqual(y.next().test, 'Aaa'); + assertEqual(y.next().test, 'aaa'); + assertEqual(y.next().test, 'äaa'); + assertEqual(y.next().test, 'äää'); + assertEqual(y.next().test, 'äää'); + assertEqual(y.next().test, 'aab'); + db._drop('ICU_SORTED'); } }; } -//////////////////////////////////////////////////////////////////////////////// -/// @brief executes the test suite -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief executes the test suite +// ////////////////////////////////////////////////////////////////////////////// jsunity.run(clientTestSuite); diff --git a/js/client/tests/shell/shell-foxx-manager-spec.js b/js/client/tests/shell/shell-foxx-manager-spec.js index c87ab24f09..51bb8d726f 100644 --- a/js/client/tests/shell/shell-foxx-manager-spec.js +++ b/js/client/tests/shell/shell-foxx-manager-spec.js @@ -1,4 +1,4 @@ -/* global describe, it, beforeEach, afterEach, before, after*/ +/* global describe, it, beforeEach, afterEach */ 'use strict'; const FoxxManager = require('@arangodb/foxx/manager'); @@ -42,6 +42,12 @@ describe('Foxx Manager', function () { db._drop(setupTeardownCol); } catch (e) { } + + try { + // some tests create these: + db._drop('testmount_setup'); + } catch (e) { + } }); it('should contains in _apps', function () { @@ -95,6 +101,16 @@ describe('Foxx Manager', function () { db._drop(setupTeardownCol); } catch (e) { } + try { + // some tests create these: + db._drop('testmount_setup'); + } catch (e) { + } + try { + // some tests create these: + db._drop('testmount_setup'); + } catch (e) { + } }); it('should not contains in _apps', function () { @@ -146,6 +162,11 @@ describe('Foxx Manager', function () { db._drop(setupTeardownCol); } catch (e) { } + try { + // some tests create these: + db._drop('testmount_setup'); + } catch (e) { + } }); it('should update it checksum in _apps', function () { @@ -189,6 +210,11 @@ describe('Foxx Manager', function () { FoxxManager.uninstall(mount, {force: false}); } catch (e) { } + try { + // some tests create these: + db._drop('testmount_setup'); + } catch (e) { + } }); it('should not contains in _apps', function () { @@ -271,6 +297,11 @@ describe('Foxx Manager', function () { FoxxManager.uninstall(mount, {force: false}); } catch (e) { } + try { + // some tests create these: + db._drop('testmount_setup'); + } catch (e) { + } }); it('should contains in _apps', function () { diff --git a/js/common/tests/shell/shell-edge-index-noncluster.js b/js/common/tests/shell/shell-edge-index-noncluster.js index 4bbbaa8cf9..a039179932 100644 --- a/js/common/tests/shell/shell-edge-index-noncluster.js +++ b/js/common/tests/shell/shell-edge-index-noncluster.js @@ -1,82 +1,81 @@ -/*jshint globalstrict:false, strict:false */ -/*global assertEqual, assertTrue, assertFalse, assertNotNull */ +/* jshint globalstrict:false, strict:false */ +/* global assertEqual, assertTrue, assertFalse, assertNotNull */ -//////////////////////////////////////////////////////////////////////////////// -/// @brief test the document interface -/// -/// @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 Dr. Frank Celler -/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test the document interface +// / +// / @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 Dr. Frank Celler +// / @author Copyright 2012, triAGENS GmbH, Cologne, Germany +// ////////////////////////////////////////////////////////////////////////////// -var jsunity = require("jsunity"); -var arangodb = require("@arangodb"); +var jsunity = require('jsunity'); +var arangodb = require('@arangodb'); var db = arangodb.db; -var internal = require("internal"); +var internal = require('internal'); var wait = internal.wait; -var print = internal.print; var ArangoCollection = arangodb.ArangoCollection; var mmfilesEngine = false; -if (db._engine().name === "mmfiles") { +if (db._engine().name === 'mmfiles') { mmfilesEngine = true; } -//////////////////////////////////////////////////////////////////////////////// -/// @brief test suite: buckets -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test suite: buckets +// ////////////////////////////////////////////////////////////////////////////// function EdgeIndexBucketsSuite () { - var vn = "UnitTestsCollectionVertex"; + var vn = 'UnitTestsCollectionVertex'; var vertex = null; - var en1 = "UnitTestsCollectionEdge1"; + var en1 = 'UnitTestsCollectionEdge1'; var edge1 = null; - var en2 = "UnitTestsCollectionEdge2"; + var en2 = 'UnitTestsCollectionEdge2'; var edge2 = null; - var en3 = "UnitTestsCollectionEdge3"; + var en3 = 'UnitTestsCollectionEdge3'; var edge3 = null; return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief set up -//////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////////// + // / @brief set up + // ////////////////////////////////////////////////////////////////////////////// - setUp : function () { + setUp: function () { db._drop(en1); db._drop(en2); db._drop(en3); var options = {}; - if (mmfilesEngine){ + if (mmfilesEngine) { options = { indexBuckets: 1 }; } edge1 = db._createEdgeCollection(en1, options); - if (mmfilesEngine){ + if (mmfilesEngine) { options = { indexBuckets: 16 }; } edge2 = db._createEdgeCollection(en2, options); - if (mmfilesEngine){ + if (mmfilesEngine) { options = { indexBuckets: 128 }; } edge3 = db._createEdgeCollection(en3, options); @@ -85,31 +84,34 @@ function EdgeIndexBucketsSuite () { vertex = db._create(vn); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief tear down -//////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////////// + // / @brief tear down + // ////////////////////////////////////////////////////////////////////////////// - tearDown : function () { + tearDown: function () { edge1.drop(); edge2.drop(); edge3.drop(); edge1 = null; edge2 = null; edge3 = null; + vertex.drop(); wait(0.0); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief compare results with different buckets -//////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////////// + // / @brief compare results with different buckets + // ////////////////////////////////////////////////////////////////////////////// - testSaveEdgeBuckets : function () { - var i, j, n = 50; + testSaveEdgeBuckets: function () { + var i; + var j; + var n = 50; for (i = 0; i < n; ++i) { for (j = 0; j < n; ++j) { - edge1.save(vn + "/v" + i, vn + "/v" + j, { }); - edge2.save(vn + "/v" + i, vn + "/v" + j, { }); - edge3.save(vn + "/v" + i, vn + "/v" + j, { }); + edge1.save(vn + '/v' + i, vn + '/v' + j, { }); + edge2.save(vn + '/v' + i, vn + '/v' + j, { }); + edge3.save(vn + '/v' + i, vn + '/v' + j, { }); } } @@ -133,32 +135,34 @@ function EdgeIndexBucketsSuite () { edge3 = db._collection(en3); for (i = 0; i < n; ++i) { - assertEqual(n, edge1.outEdges(vn + "/v" + i).length); - assertEqual(n, edge2.outEdges(vn + "/v" + i).length); - assertEqual(n, edge3.outEdges(vn + "/v" + i).length); + assertEqual(n, edge1.outEdges(vn + '/v' + i).length); + assertEqual(n, edge2.outEdges(vn + '/v' + i).length); + assertEqual(n, edge3.outEdges(vn + '/v' + i).length); - assertEqual(n, edge1.inEdges(vn + "/v" + i).length); - assertEqual(n, edge2.inEdges(vn + "/v" + i).length); - assertEqual(n, edge3.inEdges(vn + "/v" + i).length); + assertEqual(n, edge1.inEdges(vn + '/v' + i).length); + assertEqual(n, edge2.inEdges(vn + '/v' + i).length); + assertEqual(n, edge3.inEdges(vn + '/v' + i).length); - assertEqual((n * 2) - 1, edge1.edges(vn + "/v" + i).length); - assertEqual((n * 2) - 1, edge2.edges(vn + "/v" + i).length); - assertEqual((n * 2) - 1, edge3.edges(vn + "/v" + i).length); - } + assertEqual((n * 2) - 1, edge1.edges(vn + '/v' + i).length); + assertEqual((n * 2) - 1, edge2.edges(vn + '/v' + i).length); + assertEqual((n * 2) - 1, edge3.edges(vn + '/v' + i).length); + } }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief compare results with different buckets -//////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////////// + // / @brief compare results with different buckets + // ////////////////////////////////////////////////////////////////////////////// - testRemoveEdgeBuckets : function () { - var i, j, n = 40; + testRemoveEdgeBuckets: function () { + var i; + var j; + var n = 40; for (i = 0; i < n; ++i) { for (j = 0; j < n; ++j) { - edge1.save(vn + "/v" + i, vn + "/v" + j, { _key: i + "-" + j }); - edge2.save(vn + "/v" + i, vn + "/v" + j, { _key: i + "-" + j }); - edge3.save(vn + "/v" + i, vn + "/v" + j, { _key: i + "-" + j }); - } + edge1.save(vn + '/v' + i, vn + '/v' + j, { _key: i + '-' + j }); + edge2.save(vn + '/v' + i, vn + '/v' + j, { _key: i + '-' + j }); + edge3.save(vn + '/v' + i, vn + '/v' + j, { _key: i + '-' + j }); + } } // remove a few random documents @@ -188,7 +192,7 @@ function EdgeIndexBucketsSuite () { edge2 = db._collection(en2); edge3 = db._collection(en3); - edge1.toArray().forEach(function(doc) { + edge1.toArray().forEach(function (doc) { var from = doc._from; var to = doc._to; var ref; @@ -214,12 +218,11 @@ function EdgeIndexBucketsSuite () { }; } - function EdgeIndexSuite () { - var vn = "UnitTestsCollectionVertex"; + var vn = 'UnitTestsCollectionVertex'; var vertex = null; - var en = "UnitTestsCollectionEdge"; + var en = 'UnitTestsCollectionEdge'; var edge = null; var v1 = null; @@ -227,26 +230,26 @@ function EdgeIndexSuite () { return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief set up -//////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////////// + // / @brief set up + // ////////////////////////////////////////////////////////////////////////////// - setUp : function () { + setUp: function () { db._drop(en); edge = db._createEdgeCollection(en); db._drop(vn); vertex = db._create(vn); - v1 = vertex.save({ a : 1 }); - v2 = vertex.save({ a : 2 }); + v1 = vertex.save({ a: 1 }); + v2 = vertex.save({ a: 2 }); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief tear down -//////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////////// + // / @brief tear down + // ////////////////////////////////////////////////////////////////////////////// - tearDown : function () { + tearDown: function () { edge.drop(); vertex.drop(); edge = null; @@ -254,77 +257,84 @@ function EdgeIndexSuite () { wait(0.0); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test batch size limit -//////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////////// + // / @brief test batch size limit + // ////////////////////////////////////////////////////////////////////////////// - testIndexBatchsizeLimit : function () { - [20, 900, 1000, 1100, 2000].forEach( function(n){ + testIndexBatchsizeLimit: function () { + [20, 900, 1000, 1100, 2000].forEach(function (n) { var toKeys = []; for (var i = 0; i < n; ++i) { - var to = "b" + n + "/"+i; - edge.insert({_from : "a/" + n, _to : to}); - toKeys.push(to); + var to = 'b' + n + '/' + i; + edge.insert({ + _from: 'a/' + n, + _to: to + }); + toKeys.push(to); } - assertEqual(n,edge.byExample({ _from : "a/" + n }).toArray().length, "compare 1"); - assertEqual(n,edge.byExample({ _from : "a/" + n }).toArray().length, "compare 2"); - var rv = edge.byExample({ _from : "a/" + n }).toArray(); - assertEqual(n,rv.length, "compare 3"); + assertEqual(n, edge.byExample({ + _from: 'a/' + n + }).toArray().length, 'compare 1'); - //assert equal values - if(n <= 1001){ - var keys = rv.map(function(x){ return x._to; }); - keys.sort(); - toKeys.sort(); - keys.forEach(function(x,i){ - assertEqual(x,toKeys[i], "compare exact values"); - }); + assertEqual(n, edge.byExample({ + _from: 'a/' + n + }).toArray().length, 'compare 2'); + + var rv = edge.byExample({ _from: 'a/' + n }).toArray(); + assertEqual(n, rv.length, 'compare 3'); + + // assert equal values + if (n <= 1001) { + var keys = rv.map(function (x) { return x._to; }); + keys.sort(); + toKeys.sort(); + keys.forEach(function (x, i) { + assertEqual(x, toKeys[i], 'compare exact values'); + }); } - }); }, + // ////////////////////////////////////////////////////////////////////////////// + // / @brief test index presence + // ////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -/// @brief test index presence -//////////////////////////////////////////////////////////////////////////////// - - testIndexPresence : function () { + testIndexPresence: function () { var indexes = edge.getIndexes(); assertEqual(2, indexes.length); - assertEqual("edge", indexes[1].type); - assertEqual([ "_from", "_to" ], indexes[1].fields); + assertEqual('edge', indexes[1].type); + assertEqual([ '_from', '_to' ], indexes[1].fields); assertFalse(indexes[1].unique); assertFalse(indexes[1].sparse); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test index selectivity -//////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////////// + // / @brief test index selectivity + // ////////////////////////////////////////////////////////////////////////////// - testIndexSelectivityEmpty : function () { + testIndexSelectivityEmpty: function () { var edgeIndex = edge.getIndexes()[1]; - assertTrue(edgeIndex.hasOwnProperty("selectivityEstimate")); + assertTrue(edgeIndex.hasOwnProperty('selectivityEstimate')); assertEqual(1, edgeIndex.selectivityEstimate); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test index selectivity -//////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////////// + // / @brief test index selectivity + // ////////////////////////////////////////////////////////////////////////////// - testIndexSelectivityOneDoc : function () { + testIndexSelectivityOneDoc: function () { edge.save(v1, v2, { }); var edgeIndex = edge.getIndexes()[1]; - assertTrue(edgeIndex.hasOwnProperty("selectivityEstimate")); + assertTrue(edgeIndex.hasOwnProperty('selectivityEstimate')); assertEqual(1, edgeIndex.selectivityEstimate); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test index selectivity -//////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////////// + // / @brief test index selectivity + // ////////////////////////////////////////////////////////////////////////////// - testIndexSelectivityDuplicateDocs : function () { + testIndexSelectivityDuplicateDocs: function () { var i, c, edgeIndex, expectedSelectivity; for (i = 0; i < 1000; ++i) { @@ -348,57 +358,54 @@ function EdgeIndexSuite () { expectedSelectivity = (c === 0 ? 1 : 1 / c); // allow for some floating-point deviations assertTrue(Math.abs(expectedSelectivity - edgeIndex.selectivityEstimate) <= 0.001); - } + } }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test index selectivity -//////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////////// + // / @brief test index selectivity + // ////////////////////////////////////////////////////////////////////////////// - testIndexSelectivityUniqueDocs : function () { + testIndexSelectivityUniqueDocs: function () { for (var i = 0; i < 1000; ++i) { - edge.save(vn + "/from" + i, vn + "/to" + i, { }); + edge.save(vn + '/from' + i, vn + '/to' + i, { }); var edgeIndex = edge.getIndexes()[1]; assertTrue(1, edgeIndex.selectivityEstimate); } }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test index selectivity -//////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////////// + // / @brief test index selectivity + // ////////////////////////////////////////////////////////////////////////////// - testIndexSelectivityUniqueDocsFrom : function () { + testIndexSelectivityUniqueDocsFrom: function () { for (var i = 0; i < 1000; ++i) { - edge.save(vn + "/from" + i, vn + "/1", { }); + edge.save(vn + '/from' + i, vn + '/1', { }); var edgeIndex = edge.getIndexes()[1]; var expectedSelectivity = (1 + (1 / (i + 1))) * 0.5; assertTrue(Math.abs(expectedSelectivity - edgeIndex.selectivityEstimate) <= 0.001); } }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test index selectivity -//////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////////// + // / @brief test index selectivity + // ////////////////////////////////////////////////////////////////////////////// - testIndexSelectivityRepeatingDocs : function () { + testIndexSelectivityRepeatingDocs: function () { for (var i = 0; i < 1000; ++i) { if (i > 0) { var edgeIndex = edge.getIndexes()[1]; var expectedSelectivity = (1 + (Math.min(i, 20) / i)) * 0.5; assertTrue(Math.abs(expectedSelectivity - edgeIndex.selectivityEstimate) <= 0.001); } - edge.save(vn + "/from" + (i % 20), vn + "/to" + i, { }); + edge.save(vn + '/from' + (i % 20), vn + '/to' + i, { }); } } - - }; } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief executes the test suite -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief executes the test suite +// ////////////////////////////////////////////////////////////////////////////// jsunity.run(EdgeIndexSuite); jsunity.run(EdgeIndexBucketsSuite); diff --git a/js/common/tests/shell/shell-figures-mmfiles-noncluster.js b/js/common/tests/shell/shell-figures-mmfiles-noncluster.js index 30e5e5bc93..052aa2fabf 100644 --- a/js/common/tests/shell/shell-figures-mmfiles-noncluster.js +++ b/js/common/tests/shell/shell-figures-mmfiles-noncluster.js @@ -1,55 +1,54 @@ -/*jshint globalstrict:false, strict:false */ -/*global assertEqual, assertTrue, assertEqual, assertNotEqual, fail */ +/* jshint globalstrict:false, strict:false */ +/* global assertEqual, assertTrue, assertEqual, assertNotEqual, fail */ -//////////////////////////////////////////////////////////////////////////////// -/// @brief test the collection interface -/// -/// @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 Dr. Frank Celler -/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test the collection interface +// / +// / @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 Dr. Frank Celler +// / @author Copyright 2012, triAGENS GmbH, Cologne, Germany +// ////////////////////////////////////////////////////////////////////////////// -var jsunity = require("jsunity"); +var jsunity = require('jsunity'); -var arangodb = require("@arangodb"); -var internal = require("internal"); +var arangodb = require('@arangodb'); +var internal = require('internal'); var db = arangodb.db; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test suite: FiguresSuite -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test suite: FiguresSuite +// ////////////////////////////////////////////////////////////////////////////// function FiguresSuite () { 'use strict'; return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief figures -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief figures +// ////////////////////////////////////////////////////////////////////////////// - testFigures : function () { - var collection = "example"; + testFigures: function () { + var collection = 'testFigures'; db._drop(collection); var c1 = db._create(collection); @@ -65,7 +64,7 @@ function FiguresSuite () { assertEqual(0, f.dead.size); assertEqual(0, f.dead.deletion); - var d1 = c1.save({ hello : 1 }); + var d1 = c1.save({ hello: 1 }); internal.wal.flush(true, true); @@ -89,7 +88,7 @@ function FiguresSuite () { assertEqual(0, f.dead.size); assertEqual(0, f.dead.deletion); - var d2 = c1.save({ hello : 2 }); + var d2 = c1.save({ hello: 2 }); internal.wal.flush(true, true); tries = 0; @@ -159,12 +158,12 @@ function FiguresSuite () { db._drop(collection); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief check figures -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief check figures +// ////////////////////////////////////////////////////////////////////////////// - testFiguresAfterOperations : function () { - var cnName = "example"; + testFiguresAfterOperations: function () { + var cnName = 'FiguresAfterOperations'; db._drop(cnName); var collection = db._create(cnName); @@ -172,9 +171,9 @@ function FiguresSuite () { collection.load(); var figures; - collection.save({ _key : "a1" }); - collection.save({ _key : "a2" }); - collection.save({ _key : "a3" }); + collection.save({ _key: 'a1' }); + collection.save({ _key: 'a2' }); + collection.save({ _key: 'a3' }); internal.wal.flush(true, true); var tries = 0; @@ -191,17 +190,15 @@ function FiguresSuite () { // insert a few duplicates try { - collection.save({ _key : "a1" }); + collection.save({ _key: 'a1' }); fail(); + } catch (e1) { } - catch (e1) { - } - + try { - collection.save({ _key : "a2" }); + collection.save({ _key: 'a2' }); fail(); - } - catch (e2) { + } catch (e2) { } // we should see the same figures @@ -212,8 +209,8 @@ function FiguresSuite () { assertEqual(0, figures.dead.count); // now remove some documents - collection.remove("a2"); - collection.remove("a3"); + collection.remove('a2'); + collection.remove('a3'); // we should see two live docs less internal.wal.flush(true, true); @@ -230,7 +227,7 @@ function FiguresSuite () { assertEqual(2, figures.dead.count); // replacing one document does not change alive, but increases dead! - collection.replace("a1", { }); + collection.replace('a1', { }); internal.wal.flush(true, true); tries = 0; @@ -247,10 +244,9 @@ function FiguresSuite () { // this doc does not exist. should not change the figures try { - collection.replace("a2", { }); + collection.replace('a2', { }); fail(); - } - catch (e3) { + } catch (e3) { } internal.wal.flush(true, true); @@ -258,17 +254,16 @@ function FiguresSuite () { assertEqual(1, figures.alive.count); assertEqual(3, figures.dead.count); + collection.unload(); + collection.drop(); } }; } - - -//////////////////////////////////////////////////////////////////////////////// -/// @brief executes the test suites -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief executes the test suites +// ////////////////////////////////////////////////////////////////////////////// jsunity.run(FiguresSuite); return jsunity.done(); - diff --git a/js/common/tests/shell/shell-simple-query.js b/js/common/tests/shell/shell-simple-query.js index a4741ac965..1ec165d60c 100644 --- a/js/common/tests/shell/shell-simple-query.js +++ b/js/common/tests/shell/shell-simple-query.js @@ -1,97 +1,96 @@ -/*jshint globalstrict:false, strict:false */ -/*global assertEqual, assertNotNull, assertNull, assertTrue, assertMatch, +/* jshint globalstrict:false, strict:false */ +/* global assertEqual, assertNotNull, assertNull, assertTrue, assertMatch, assertFalse */ -//////////////////////////////////////////////////////////////////////////////// -/// @brief test the graph class -/// -/// @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 Dr. Frank Celler, Lucas Dohmen -/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test the graph class +// / +// / @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 Dr. Frank Celler, Lucas Dohmen +// / @author Copyright 2012, triAGENS GmbH, Cologne, Germany +// ////////////////////////////////////////////////////////////////////////////// -var jsunity = require("jsunity"); +var jsunity = require('jsunity'); -var db = require("@arangodb").db; -var SimpleQueryArray = require("@arangodb/simple-query").SimpleQueryArray; +var db = require('@arangodb').db; +var SimpleQueryArray = require('@arangodb/simple-query').SimpleQueryArray; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test lookup-by-key API -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test lookup-by-key API +// ////////////////////////////////////////////////////////////////////////////// function SimpleQueryLookupByKeysSuite () { 'use strict'; - var cn = "example"; + var cn = 'SimpleQueryLookupByKeysSuite'; var c = null; return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief set up -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief set up +// ////////////////////////////////////////////////////////////////////////////// - setUp : function () { + setUp: function () { db._drop(cn); c = db._create(cn); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief tear down -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tear down +// ////////////////////////////////////////////////////////////////////////////// - tearDown : function () { + tearDown: function () { db._drop(cn); c = null; }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief lookup in empty collection -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief lookup in empty collection +// ////////////////////////////////////////////////////////////////////////////// - testEmptyCollection : function () { - var result = c.documents([ "foo", "bar", "baz" ]); + testEmptyCollection: function () { + var result = c.documents([ 'foo', 'bar', 'baz' ]); assertEqual({ documents: [ ] }, result); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief lookup in empty collection and empty lookup list -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief lookup in empty collection and empty lookup list +// ////////////////////////////////////////////////////////////////////////////// - testEmptyCollectionAndArray : function () { + testEmptyCollectionAndArray: function () { var result = c.documents([ ]); assertEqual({ documents: [ ] }, result); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief lookup in collection with empty lookup list -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief lookup in collection with empty lookup list +// ////////////////////////////////////////////////////////////////////////////// - testEmptyArray : function () { + testEmptyArray: function () { for (var i = 0; i < 100; ++i) { - c.insert({ _key: "test" + i }); + c.insert({ _key: 'test' + i }); } var result = c.documents([ ]); @@ -103,16 +102,16 @@ function SimpleQueryLookupByKeysSuite () { assertEqual({ documents: [ ] }, result); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief lookup in collection with document ids -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief lookup in collection with document ids +// ////////////////////////////////////////////////////////////////////////////// - testDocumentIds : function () { + testDocumentIds: function () { var keys = [ ]; for (var i = 0; i < 100; ++i) { - c.insert({ _key: "test" + i }); - keys.push(c.name() + "/test" + i); + c.insert({ _key: 'test' + i }); + keys.push(c.name() + '/test' + i); } // should have matches @@ -120,18 +119,18 @@ function SimpleQueryLookupByKeysSuite () { assertEqual(100, result.documents.length); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief lookup in collection with document ids -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief lookup in collection with document ids +// ////////////////////////////////////////////////////////////////////////////// - testDocumentIdDuplicates : function () { + testDocumentIdDuplicates: function () { var keys = [ ]; for (var i = 0; i < 100; ++i) { - c.insert({ _key: "test" + i }); + c.insert({ _key: 'test' + i }); // each document is here exactly twice - keys.push(c.name() + "/test" + i); - keys.push(c.name() + "/test" + i); + keys.push(c.name() + '/test' + i); + keys.push(c.name() + '/test' + i); } // should have matches @@ -139,16 +138,16 @@ function SimpleQueryLookupByKeysSuite () { assertEqual(100, result.documents.length); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief lookup in collection with document ids -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief lookup in collection with document ids +// ////////////////////////////////////////////////////////////////////////////// - testDocumentIdNonExisting : function () { + testDocumentIdNonExisting: function () { var keys = [ ]; for (var i = 0; i < 100; ++i) { - c.insert({ _key: "test" + i }); - keys.push(c.name() + "/foo" + i); + c.insert({ _key: 'test' + i }); + keys.push(c.name() + '/foo' + i); } // should not have matches @@ -156,16 +155,16 @@ function SimpleQueryLookupByKeysSuite () { assertEqual(0, result.documents.length); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief lookup in collection with document ids -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief lookup in collection with document ids +// ////////////////////////////////////////////////////////////////////////////// - testDocumentIdsInvalid : function () { + testDocumentIdsInvalid: function () { var keys = [ ]; for (var i = 0; i < 100; ++i) { - c.insert({ _key: "test" + i }); - keys.push(c.name() + "/"); + c.insert({ _key: 'test' + i }); + keys.push(c.name() + '/'); } // should not have matches @@ -173,16 +172,16 @@ function SimpleQueryLookupByKeysSuite () { assertEqual(0, result.documents.length); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief lookup in collection with document ids -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief lookup in collection with document ids +// ////////////////////////////////////////////////////////////////////////////// - testDocumentIdsOtherCollection : function () { + testDocumentIdsOtherCollection: function () { var keys = [ ]; for (var i = 0; i < 100; ++i) { - c.insert({ _key: "test" + i }); - keys.push("Another" + c.name() + "/test" + i); + c.insert({ _key: 'test' + i }); + keys.push('Another' + c.name() + '/test' + i); } // should not have matches @@ -190,161 +189,160 @@ function SimpleQueryLookupByKeysSuite () { assertEqual(0, result.documents.length); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief lookup in collection with numeric keys -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief lookup in collection with numeric keys +// ////////////////////////////////////////////////////////////////////////////// - testNumericKeys : function () { + testNumericKeys: function () { for (var i = 0; i < 100; ++i) { c.insert({ _key: String(i) }); } // should have matches - var result = c.documents([ "1", "2", "3", "0" ]); + var result = c.documents([ '1', '2', '3', '0' ]); assertEqual(4, result.documents.length); - + // try with alias method - result = c.lookupByKeys([ "1", "2", "3", "0" ]); + result = c.lookupByKeys([ '1', '2', '3', '0' ]); assertEqual(4, result.documents.length); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief lookup using invalid keys -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief lookup using invalid keys +// ////////////////////////////////////////////////////////////////////////////// - testInvalidKeys : function () { - var result = c.documents([ " ", "* ", " bfffff/\\&, ", "////.,;::" ]); + testInvalidKeys: function () { + var result = c.documents([ ' ', '* ', ' bfffff/\\&, ', '////.,;::' ]); assertEqual({ documents: [ ] }, result); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief lookup in collection -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief lookup in collection +// ////////////////////////////////////////////////////////////////////////////// - testLookup : function () { + testLookup: function () { var keys = [ ]; for (var i = 0; i < 1000; ++i) { - c.insert({ _key: "test" + i, value: i }); - keys.push("test" + i); + c.insert({ _key: 'test' + i, value: i }); + keys.push('test' + i); } var result = c.documents(keys); assertEqual(1000, result.documents.length); - result.documents.forEach(function(doc) { - assertTrue(doc.hasOwnProperty("_id")); - assertTrue(doc.hasOwnProperty("_key")); - assertTrue(doc.hasOwnProperty("_rev")); - assertTrue(doc.hasOwnProperty("value")); + result.documents.forEach(function (doc) { + assertTrue(doc.hasOwnProperty('_id')); + assertTrue(doc.hasOwnProperty('_key')); + assertTrue(doc.hasOwnProperty('_rev')); + assertTrue(doc.hasOwnProperty('value')); assertMatch(/^test\d+$/, doc._key); - assertEqual(cn + "/" + doc._key, doc._id); - assertEqual(doc._key, "test" + doc.value); + assertEqual(cn + '/' + doc._key, doc._id); + assertEqual(doc._key, 'test' + doc.value); }); - + // try with alias method result = c.lookupByKeys(keys); assertEqual(1000, result.documents.length); - result.documents.forEach(function(doc) { - assertTrue(doc.hasOwnProperty("_id")); - assertTrue(doc.hasOwnProperty("_key")); - assertTrue(doc.hasOwnProperty("_rev")); - assertTrue(doc.hasOwnProperty("value")); + result.documents.forEach(function (doc) { + assertTrue(doc.hasOwnProperty('_id')); + assertTrue(doc.hasOwnProperty('_key')); + assertTrue(doc.hasOwnProperty('_rev')); + assertTrue(doc.hasOwnProperty('value')); assertMatch(/^test\d+$/, doc._key); - assertEqual(cn + "/" + doc._key, doc._id); - assertEqual(doc._key, "test" + doc.value); + assertEqual(cn + '/' + doc._key, doc._id); + assertEqual(doc._key, 'test' + doc.value); }); }, - -//////////////////////////////////////////////////////////////////////////////// -/// @brief lookup in collection -//////////////////////////////////////////////////////////////////////////////// - testLookupDuplicate : function () { +// ////////////////////////////////////////////////////////////////////////////// +// / @brief lookup in collection +// ////////////////////////////////////////////////////////////////////////////// + + testLookupDuplicate: function () { var keys = [ ]; for (var i = 0; i < 100; ++i) { - c.insert({ _key: "test" + i, value: i }); + c.insert({ _key: 'test' + i, value: i }); // add same key twice - keys.push("test" + i); - keys.push("test" + i); + keys.push('test' + i); + keys.push('test' + i); } var result = c.documents(keys); assertEqual(100, result.documents.length); - result.documents.forEach(function(doc) { - assertTrue(doc.hasOwnProperty("_id")); - assertTrue(doc.hasOwnProperty("_key")); - assertTrue(doc.hasOwnProperty("_rev")); - assertTrue(doc.hasOwnProperty("value")); + result.documents.forEach(function (doc) { + assertTrue(doc.hasOwnProperty('_id')); + assertTrue(doc.hasOwnProperty('_key')); + assertTrue(doc.hasOwnProperty('_rev')); + assertTrue(doc.hasOwnProperty('value')); assertMatch(/^test\d+$/, doc._key); - assertEqual(cn + "/" + doc._key, doc._id); - assertEqual(doc._key, "test" + doc.value); + assertEqual(cn + '/' + doc._key, doc._id); + assertEqual(doc._key, 'test' + doc.value); }); } }; } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test remove-by-keys API -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test remove-by-keys API +// ////////////////////////////////////////////////////////////////////////////// function SimpleQueryRemoveByKeysSuite () { 'use strict'; - var cn = "example"; + var cn = 'SimpleQueryRemoveByKeysSuite'; var c = null; return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief set up -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief set up +// ////////////////////////////////////////////////////////////////////////////// - setUp : function () { + setUp: function () { db._drop(cn); c = db._create(cn); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief tear down -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tear down +// ////////////////////////////////////////////////////////////////////////////// - tearDown : function () { + tearDown: function () { db._drop(cn); c = null; }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief remove in empty collection -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief remove in empty collection +// ////////////////////////////////////////////////////////////////////////////// - testEmptyCollection : function () { - var result = c.removeByKeys([ "foo", "bar", "baz" ]); + testEmptyCollection: function () { + var result = c.removeByKeys([ 'foo', 'bar', 'baz' ]); assertEqual({ removed: 0, ignored: 3 }, result); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief remove in empty collection and empty lookup list -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief remove in empty collection and empty lookup list +// ////////////////////////////////////////////////////////////////////////////// - testEmptyCollectionAndArray : function () { + testEmptyCollectionAndArray: function () { var result = c.removeByKeys([ ]); assertEqual({ removed: 0, ignored: 0 }, result); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief remove in collection with empty lookup list -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief remove in collection with empty lookup list +// ////////////////////////////////////////////////////////////////////////////// - testEmptyArray : function () { + testEmptyArray: function () { for (var i = 0; i < 100; ++i) { - c.insert({ _key: "test" + i }); + c.insert({ _key: 'test' + i }); } var result = c.removeByKeys([ ]); @@ -352,20 +350,19 @@ function SimpleQueryRemoveByKeysSuite () { assertEqual({ removed: 0, ignored: 0 }, result); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief remove in collection with existing and nonexisting keys -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief remove in collection with existing and nonexisting keys +// ////////////////////////////////////////////////////////////////////////////// - testMixed : function () { + testMixed: function () { var keys = [ ]; for (var i = 0; i < 500; ++i) { - c.insert({ _key: "test" + i }); + c.insert({ _key: 'test' + i }); if (i % 2 === 0) { - keys.push("test" + i); - } - else { - keys.push("foobar" + i); + keys.push('test' + i); + } else { + keys.push('foobar' + i); } } @@ -376,14 +373,14 @@ function SimpleQueryRemoveByKeysSuite () { assertEqual(250, c.count()); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief remove in collection with nonexisting keys -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief remove in collection with nonexisting keys +// ////////////////////////////////////////////////////////////////////////////// - testNonExisting : function () { + testNonExisting: function () { var keys = [ ]; for (var i = 0; i < 100; ++i) { - keys.push("test" + i); + keys.push('test' + i); } var result = c.removeByKeys(keys); @@ -391,39 +388,39 @@ function SimpleQueryRemoveByKeysSuite () { assertEqual({ removed: 0, ignored: 100 }, result); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief remove in collection with numeric keys -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief remove in collection with numeric keys +// ////////////////////////////////////////////////////////////////////////////// - testNumericKeys : function () { + testNumericKeys: function () { for (var i = 0; i < 100; ++i) { c.insert({ _key: String(i) }); } // should have matches - var result = c.removeByKeys([ "1", "2", "3", "0" ]); + var result = c.removeByKeys([ '1', '2', '3', '0' ]); assertEqual({ removed: 4, ignored: 0 }, result); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief remove using invalid keys -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief remove using invalid keys +// ////////////////////////////////////////////////////////////////////////////// - testInvalidKeys : function () { - var result = c.removeByKeys([ " ", "* ", " bfffff/\\&, ", "////.,;::" ]); + testInvalidKeys: function () { + var result = c.removeByKeys([ ' ', '* ', ' bfffff/\\&, ', '////.,;::' ]); assertEqual({ removed: 0, ignored: 4 }, result); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief remove in collection -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief remove in collection +// ////////////////////////////////////////////////////////////////////////////// - testRemove : function () { + testRemove: function () { var keys = [ ]; for (var i = 0; i < 1000; ++i) { - c.insert({ _key: "test" + i, value: i }); - keys.push("test" + i); + c.insert({ _key: 'test' + i, value: i }); + keys.push('test' + i); } var result = c.removeByKeys(keys); @@ -432,84 +429,83 @@ function SimpleQueryRemoveByKeysSuite () { assertEqual(0, c.count()); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief remove in collection -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief remove in collection +// ////////////////////////////////////////////////////////////////////////////// - testRemoveTwice : function () { + testRemoveTwice: function () { var keys = [ ]; for (var i = 0; i < 1000; ++i) { - c.insert({ _key: "test" + i, value: i }); - keys.push("test" + i); + c.insert({ _key: 'test' + i, value: i }); + keys.push('test' + i); } var result = c.removeByKeys(keys); assertEqual({ removed: 1000, ignored: 0 }, result); - + assertEqual(0, c.count()); - c.insert({ _key: "test3" }); - c.insert({ _key: "test1000" }); - + c.insert({ _key: 'test3' }); + c.insert({ _key: 'test1000' }); + result = c.removeByKeys(keys); assertEqual({ removed: 1, ignored: 999 }, result); - + assertEqual(1, c.count()); }, - -//////////////////////////////////////////////////////////////////////////////// -/// @brief remove in collection -//////////////////////////////////////////////////////////////////////////////// - testRemoveDuplicate : function () { +// ////////////////////////////////////////////////////////////////////////////// +// / @brief remove in collection +// ////////////////////////////////////////////////////////////////////////////// + + testRemoveDuplicate: function () { var keys = [ ]; for (var i = 0; i < 100; ++i) { - c.insert({ _key: "test" + i, value: i }); + c.insert({ _key: 'test' + i, value: i }); // add same key twice - keys.push("test" + i); - keys.push("test" + i); + keys.push('test' + i); + keys.push('test' + i); } var result = c.removeByKeys(keys); assertEqual({ removed: 100, ignored: 100 }, result); - + assertEqual(0, c.count()); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief remove in collection -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief remove in collection +// ////////////////////////////////////////////////////////////////////////////// - testRemovePartial : function () { + testRemovePartial: function () { var keys = [ ]; for (var i = 0; i < 2000; ++i) { - c.insert({ _key: "test" + i, value: i }); + c.insert({ _key: 'test' + i, value: i }); if (i % 2 === 0) { - keys.push("test" + i); + keys.push('test' + i); } } // result should have been de-duplicated? var result = c.removeByKeys(keys); assertEqual({ removed: 1000, ignored: 0 }, result); - + assertEqual(1000, c.count()); - assertFalse(c.exists("test0")); - assertTrue(c.exists("test1")); - assertFalse(c.exists("test2")); - assertTrue(c.exists("test3")); + assertFalse(c.exists('test0')); + assertTrue(c.exists('test1')); + assertFalse(c.exists('test2')); + assertTrue(c.exists('test3')); // ... - assertFalse(c.exists("test1998")); - assertTrue(c.exists("test1999")); + assertFalse(c.exists('test1998')); + assertTrue(c.exists('test1999')); } }; } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test suite: skip and limit with a collection -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test suite: skip and limit with a collection +// ////////////////////////////////////////////////////////////////////////////// function SimpleQueryArraySkipLimitSuite () { 'use strict'; @@ -518,35 +514,35 @@ function SimpleQueryArraySkipLimitSuite () { return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief set up -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief set up +// ////////////////////////////////////////////////////////////////////////////// - setUp : function () { - numbers = [0,1,2,3,4,5,6,7,8,9]; + setUp: function () { + numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; query = new SimpleQueryArray(numbers); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: skip -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: skip +// ////////////////////////////////////////////////////////////////////////////// - testSkip : function () { + testSkip: function () { var n = query.clone().skip(0).toArray(); assertEqual(n, numbers); n = query.clone().skip(1).toArray(); - assertEqual(n, numbers.slice(1,10)); + assertEqual(n, numbers.slice(1, 10)); n = query.clone().skip(2).toArray(); - assertEqual(n, numbers.slice(2,10)); + assertEqual(n, numbers.slice(2, 10)); n = query.clone().skip(1).skip(1).toArray(); - assertEqual(n, numbers.slice(2,10)); + assertEqual(n, numbers.slice(2, 10)); n = query.clone().skip(10).toArray(); @@ -565,29 +561,29 @@ function SimpleQueryArraySkipLimitSuite () { assertEqual(n, []); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: limit -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: limit +// ////////////////////////////////////////////////////////////////////////////// - testLimit : function () { + testLimit: function () { var n = query.clone().limit(10).toArray(); assertEqual(n, numbers); n = query.clone().limit(9).toArray(); - assertEqual(n, numbers.slice(0,9)); + assertEqual(n, numbers.slice(0, 9)); n = query.clone().limit(9).limit(8).limit(7).toArray(); - assertEqual(n, numbers.slice(0,7)); + assertEqual(n, numbers.slice(0, 7)); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: skip and limit -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: skip and limit +// ////////////////////////////////////////////////////////////////////////////// - testSkipLimit : function () { + testSkipLimit: function () { var n = query.clone().skip(0).limit(10).toArray(); assertEqual(n, numbers); @@ -598,80 +594,79 @@ function SimpleQueryArraySkipLimitSuite () { n = query.clone().limit(9).skip(1).toArray(); - assertEqual(n, numbers.slice(1,9)); + assertEqual(n, numbers.slice(1, 9)); n = query.clone().limit(9).skip(1).limit(7).toArray(); - assertEqual(n, numbers.slice(1,8)); + assertEqual(n, numbers.slice(1, 8)); n = query.clone().skip(-5).limit(3).toArray(); - assertEqual(n, numbers.slice(5,8)); + assertEqual(n, numbers.slice(5, 8)); n = query.clone().skip(-8).limit(7).skip(1).limit(4).toArray(); - assertEqual(n, numbers.slice(3,7)); + assertEqual(n, numbers.slice(3, 7)); n = query.clone().skip(-10).limit(9).skip(1).limit(7).toArray(); - assertEqual(n, numbers.slice(1,8)); + assertEqual(n, numbers.slice(1, 8)); } }; } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test suite: skip and limit with a collection -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test suite: skip and limit with a collection +// ////////////////////////////////////////////////////////////////////////////// function SimpleQueryAllSkipLimitSuite () { 'use strict'; - var cn = "UnitTestsCollectionSkipLimit"; + var cn = 'UnitTestsCollectionSkipLimit'; var collection = null; var numbers = null; - var num = function(d) { return d.n; }; + var num = function (d) { return d.n; }; return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief set up -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief set up +// ////////////////////////////////////////////////////////////////////////////// - setUp : function () { + setUp: function () { db._drop(cn); - collection = db._create(cn, { waitForSync : false }); + collection = db._create(cn, { waitForSync: false }); - for (var i = 0; i < 10; ++i) { - collection.save({ n : i }); + for (var i = 0; i < 10; ++i) { + collection.save({ n: i }); } numbers = collection.all().toArray().map(num); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief tear down -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tear down +// ////////////////////////////////////////////////////////////////////////////// - tearDown : function () { + tearDown: function () { collection.drop(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: skip -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: skip +// ////////////////////////////////////////////////////////////////////////////// - testAllSkip : function () { + testAllSkip: function () { var n = collection.all().skip(0).toArray().map(num); assertEqual(n, numbers); n = collection.all().skip(1).toArray().map(num); - assertEqual(n, numbers.slice(1,10)); + assertEqual(n, numbers.slice(1, 10)); n = collection.all().skip(2).toArray().map(num); - assertEqual(n, numbers.slice(2,10)); + assertEqual(n, numbers.slice(2, 10)); n = collection.all().skip(1).skip(1).toArray().map(num); - assertEqual(n, numbers.slice(2,10)); + assertEqual(n, numbers.slice(2, 10)); n = collection.all().skip(10).toArray().map(num); assertEqual(n, []); @@ -686,26 +681,26 @@ function SimpleQueryAllSkipLimitSuite () { assertEqual(n, []); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: limit -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: limit +// ////////////////////////////////////////////////////////////////////////////// - testAllLimit : function () { + testAllLimit: function () { var n = collection.all().limit(10).toArray().map(num); assertEqual(n, numbers); n = collection.all().limit(9).toArray().map(num); - assertEqual(n, numbers.slice(0,9)); + assertEqual(n, numbers.slice(0, 9)); n = collection.all().limit(9).limit(8).limit(7).toArray().map(num); - assertEqual(n, numbers.slice(0,7)); + assertEqual(n, numbers.slice(0, 7)); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: skip and limit -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: skip and limit +// ////////////////////////////////////////////////////////////////////////////// - testAllSkipLimit : function () { + testAllSkipLimit: function () { var n = collection.all().skip(0).limit(10).toArray().map(num); assertEqual(n, numbers); @@ -721,87 +716,86 @@ function SimpleQueryAllSkipLimitSuite () { }; } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test suite: query-by-example -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test suite: query-by-example +// ////////////////////////////////////////////////////////////////////////////// function SimpleQueryByExampleSuite () { 'use strict'; - var cn = "UnitTestsCollectionByExample"; + var cn = 'UnitTestsCollectionByExample'; var collection = null; - var id = function(d) { return d._id; }; + var id = function (d) { return d._id; }; return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief set up -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief set up +// ////////////////////////////////////////////////////////////////////////////// - setUp : function () { + setUp: function () { db._drop(cn); collection = db._create(cn); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief tear down -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tear down +// ////////////////////////////////////////////////////////////////////////////// - tearDown : function () { + tearDown: function () { collection.drop(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using indexes -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using indexes +// ////////////////////////////////////////////////////////////////////////////// - testByExampleHash1 : function () { + testByExampleHash1: function () { var d, s; - var example = { "a" : { "b" : true, "c" : "foo" }, "d" : true }; + var example = { 'a': { 'b': true, 'c': 'foo' }, 'd': true }; - collection.ensureHashIndex("d"); + collection.ensureHashIndex('d'); d = collection.save(example); - s = collection.firstExample({ "d" : true }); + s = collection.firstExample({ 'd': true }); assertEqual(d._id, s._id); - s = collection.firstExample({ "d" : false }); + s = collection.firstExample({ 'd': false }); assertNull(s); - s = collection.firstExample({ "a.b" : true }); + s = collection.firstExample({ 'a.b': true }); assertEqual(d._id, s._id); - s = collection.firstExample({ "a.c" : "foo" }); + s = collection.firstExample({ 'a.c': 'foo' }); assertEqual(d._id, s._id); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using indexes -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using indexes +// ////////////////////////////////////////////////////////////////////////////// - testByExampleHash2 : function () { - var d1, d2, d3, d4, s; - var example1 = { "a" : { "b" : true } }; - var example2 = { "a" : { "b" : "foo" } }; - var example3 = { "a" : { "b" : null } }; - var example4 = { "c" : 1 }; + testByExampleHash2: function () { + var d1, d2, d4, s; + var example1 = { 'a': { 'b': true } }; + var example2 = { 'a': { 'b': 'foo' } }; + var example3 = { 'a': { 'b': null } }; + var example4 = { 'c': 1 }; - collection.ensureHashIndex("a.b"); + collection.ensureHashIndex('a.b'); d1 = collection.save(example1); d2 = collection.save(example2); - d3 = collection.save(example3); + collection.save(example3); d4 = collection.save(example4); - s = collection.firstExample({ "a.b" : true }); + s = collection.firstExample({ 'a.b': true }); assertEqual(d1._id, s._id); - s = collection.firstExample({ "a.b" : "foo" }); + s = collection.firstExample({ 'a.b': 'foo' }); assertEqual(d2._id, s._id); - s = collection.firstExample({ "a.b" : false }); + s = collection.firstExample({ 'a.b': false }); assertNull(s); - s = collection.firstExample({ "a.b" : null }); + s = collection.firstExample({ 'a.b': null }); assertNotNull(s); - s = collection.firstExample({ "c" : 1 }); + s = collection.firstExample({ 'c': 1 }); assertEqual(d4._id, s._id); s = collection.firstExample(example1); @@ -810,33 +804,33 @@ function SimpleQueryByExampleSuite () { assertEqual(d2._id, s._id); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using indexes -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using indexes +// ////////////////////////////////////////////////////////////////////////////// - testByExampleSparseHash : function () { - var d1, d2, d3, d4, s; - var example1 = { "a" : { "b" : true } }; - var example2 = { "a" : { "b" : "foo" } }; - var example3 = { "a" : { "b" : null } }; - var example4 = { "c" : 1 }; + testByExampleSparseHash: function () { + var d1, d2, d4, s; + var example1 = { 'a': { 'b': true } }; + var example2 = { 'a': { 'b': 'foo' } }; + var example3 = { 'a': { 'b': null } }; + var example4 = { 'c': 1 }; - collection.ensureHashIndex("a.b", { sparse: true }); + collection.ensureHashIndex('a.b', { sparse: true }); d1 = collection.save(example1); d2 = collection.save(example2); - d3 = collection.save(example3); + collection.save(example3); d4 = collection.save(example4); - s = collection.firstExample({ "a.b" : true }); + s = collection.firstExample({ 'a.b': true }); assertEqual(d1._id, s._id); - s = collection.firstExample({ "a.b" : "foo" }); + s = collection.firstExample({ 'a.b': 'foo' }); assertEqual(d2._id, s._id); - s = collection.firstExample({ "a.b" : false }); + s = collection.firstExample({ 'a.b': false }); assertNull(s); - s = collection.firstExample({ "a.b" : null }); + s = collection.firstExample({ 'a.b': null }); assertNotNull(s); - s = collection.firstExample({ "c" : 1 }); + s = collection.firstExample({ 'c': 1 }); assertEqual(d4._id, s._id); s = collection.firstExample(example1); @@ -845,57 +839,57 @@ function SimpleQueryByExampleSuite () { assertEqual(d2._id, s._id); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using indexes -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using indexes +// ////////////////////////////////////////////////////////////////////////////// - testByExampleSkiplist1 : function () { + testByExampleSkiplist1: function () { var d, s; - var example = { "a" : { "b" : true, "c" : "foo" }, "d" : true }; + var example = { 'a': { 'b': true, 'c': 'foo' }, 'd': true }; - collection.ensureSkiplist("d"); + collection.ensureSkiplist('d'); d = collection.save(example); - s = collection.firstExample({ "d" : true }); + s = collection.firstExample({ 'd': true }); assertEqual(d._id, s._id); - s = collection.firstExample({ "d" : false }); + s = collection.firstExample({ 'd': false }); assertNull(s); - s = collection.firstExample({ "a.b" : true }); + s = collection.firstExample({ 'a.b': true }); assertEqual(d._id, s._id); - s = collection.firstExample({ "a.c" : "foo" }); + s = collection.firstExample({ 'a.c': 'foo' }); assertEqual(d._id, s._id); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using indexes -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using indexes +// ////////////////////////////////////////////////////////////////////////////// - testByExampleSkiplist2 : function () { - var d1, d2, d3, d4, s; - var example1 = { "a" : { "b" : true } }; - var example2 = { "a" : { "b" : "foo" } }; - var example3 = { "a" : { "b" : null } }; - var example4 = { "c" : 1 }; + testByExampleSkiplist2: function () { + var d1, d2, d4, s; + var example1 = { 'a': { 'b': true } }; + var example2 = { 'a': { 'b': 'foo' } }; + var example3 = { 'a': { 'b': null } }; + var example4 = { 'c': 1 }; - collection.ensureSkiplist("a.b"); + collection.ensureSkiplist('a.b'); d1 = collection.save(example1); d2 = collection.save(example2); - d3 = collection.save(example3); + collection.save(example3); d4 = collection.save(example4); - s = collection.firstExample({ "a.b" : true }); + s = collection.firstExample({ 'a.b': true }); assertEqual(d1._id, s._id); - s = collection.firstExample({ "a.b" : "foo" }); + s = collection.firstExample({ 'a.b': 'foo' }); assertEqual(d2._id, s._id); - s = collection.firstExample({ "a.b" : false }); + s = collection.firstExample({ 'a.b': false }); assertNull(s); - s = collection.firstExample({ "a.b" : null }); + s = collection.firstExample({ 'a.b': null }); assertNotNull(s); - s = collection.firstExample({ "c" : 1 }); + s = collection.firstExample({ 'c': 1 }); assertEqual(d4._id, s._id); s = collection.firstExample(example1); @@ -904,33 +898,33 @@ function SimpleQueryByExampleSuite () { assertEqual(d2._id, s._id); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using indexes -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using indexes +// ////////////////////////////////////////////////////////////////////////////// - testByExampleSparseSkiplist : function () { - var d1, d2, d3, d4, s; - var example1 = { "a" : { "b" : true } }; - var example2 = { "a" : { "b" : "foo" } }; - var example3 = { "a" : { "b" : null } }; - var example4 = { "c" : 1 }; + testByExampleSparseSkiplist: function () { + var d1, d2, d4, s; + var example1 = { 'a': { 'b': true } }; + var example2 = { 'a': { 'b': 'foo' } }; + var example3 = { 'a': { 'b': null } }; + var example4 = { 'c': 1 }; - collection.ensureSkiplist("a.b", { sparse: true }); + collection.ensureSkiplist('a.b', { sparse: true }); d1 = collection.save(example1); d2 = collection.save(example2); - d3 = collection.save(example3); + collection.save(example3); d4 = collection.save(example4); - s = collection.firstExample({ "a.b" : true }); + s = collection.firstExample({ 'a.b': true }); assertEqual(d1._id, s._id); - s = collection.firstExample({ "a.b" : "foo" }); + s = collection.firstExample({ 'a.b': 'foo' }); assertEqual(d2._id, s._id); - s = collection.firstExample({ "a.b" : false }); + s = collection.firstExample({ 'a.b': false }); assertNull(s); - s = collection.firstExample({ "a.b" : null }); + s = collection.firstExample({ 'a.b': null }); assertNotNull(s); - s = collection.firstExample({ "c" : 1 }); + s = collection.firstExample({ 'c': 1 }); assertEqual(d4._id, s._id); s = collection.firstExample(example1); @@ -939,453 +933,453 @@ function SimpleQueryByExampleSuite () { assertEqual(d2._id, s._id); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample +// ////////////////////////////////////////////////////////////////////////////// - testByExampleMultipleValues : function () { - [ null, 1, 2, true, false, "1", "2", "foo", "barbazbark", [ ] ].forEach(function(v) { + testByExampleMultipleValues: function () { + [ null, 1, 2, true, false, '1', '2', 'foo', 'barbazbark', [ ] ].forEach(function (v) { for (var i = 0; i < 5; ++i) { collection.save({ value: v }); } - + var result = collection.byExample({ value: v }).toArray(); assertEqual(5, result.length); }); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample +// ////////////////////////////////////////////////////////////////////////////// - testByExampleMultipleValuesHashIndex : function () { - collection.ensureHashIndex("value"); + testByExampleMultipleValuesHashIndex: function () { + collection.ensureHashIndex('value'); - [ null, 1, 2, true, false, "1", "2", "foo", "barbazbark", [ ] ].forEach(function(v) { + [ null, 1, 2, true, false, '1', '2', 'foo', 'barbazbark', [ ] ].forEach(function (v) { for (var i = 0; i < 5; ++i) { collection.save({ value: v }); } - + var result = collection.byExample({ value: v }).toArray(); assertEqual(5, result.length); }); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample +// ////////////////////////////////////////////////////////////////////////////// - testByExampleMultipleValuesSparseHashIndex : function () { - collection.ensureHashIndex("value", { sparse: true }); + testByExampleMultipleValuesSparseHashIndex: function () { + collection.ensureHashIndex('value', { sparse: true }); - [ null, 1, 2, true, false, "1", "2", "foo", "barbazbark", [ ] ].forEach(function(v) { + [ null, 1, 2, true, false, '1', '2', 'foo', 'barbazbark', [ ] ].forEach(function (v) { for (var i = 0; i < 5; ++i) { collection.save({ value: v }); } - + var result = collection.byExample({ value: v }).toArray(); assertEqual(5, result.length); }); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample +// ////////////////////////////////////////////////////////////////////////////// - testByExampleMultipleValuesSkiplist : function () { - collection.ensureSkiplist("value"); + testByExampleMultipleValuesSkiplist: function () { + collection.ensureSkiplist('value'); - [ null, 1, 2, true, false, "1", "2", "foo", "barbazbark", [ ] ].forEach(function(v) { + [ null, 1, 2, true, false, '1', '2', 'foo', 'barbazbark', [ ] ].forEach(function (v) { for (var i = 0; i < 5; ++i) { collection.save({ value: v }); } - + var result = collection.byExample({ value: v }).toArray(); assertEqual(5, result.length); }); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample +// ////////////////////////////////////////////////////////////////////////////// - testByExampleMultipleValuesSparseSkiplist : function () { - collection.ensureSkiplist("value", { sparse: true }); + testByExampleMultipleValuesSparseSkiplist: function () { + collection.ensureSkiplist('value', { sparse: true }); - [ null, 1, 2, true, false, "1", "2", "foo", "barbazbark", [ ] ].forEach(function(v) { + [ null, 1, 2, true, false, '1', '2', 'foo', 'barbazbark', [ ] ].forEach(function (v) { for (var i = 0; i < 5; ++i) { collection.save({ value: v }); } - + var result = collection.byExample({ value: v }).toArray(); assertEqual(5, result.length); }); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using _key -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using _key +// ////////////////////////////////////////////////////////////////////////////// - testByExampleKey : function () { + testByExampleKey: function () { var d, s; - d = collection.save({ _key: "meow" }); - s = collection.firstExample({ _key: "foo" }); + d = collection.save({ _key: 'meow' }); + s = collection.firstExample({ _key: 'foo' }); assertNull(s); - s = collection.firstExample({ _key: "meow" }); + s = collection.firstExample({ _key: 'meow' }); assertEqual(d._id, s._id); assertEqual(d._key, s._key); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using _key & others -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using _key & others +// ////////////////////////////////////////////////////////////////////////////// - testByExampleKeyMore : function () { + testByExampleKeyMore: function () { var d, s; - d = collection.save({ _key: "meow" }); - s = collection.firstExample({ _key: "meow", a: 1 }); + d = collection.save({ _key: 'meow' }); + s = collection.firstExample({ _key: 'meow', a: 1 }); assertNull(s); - d = collection.save({ _key: "foo", a: 2 }); - s = collection.firstExample({ _key: "foo", a: 2 }); + d = collection.save({ _key: 'foo', a: 2 }); + s = collection.firstExample({ _key: 'foo', a: 2 }); assertEqual(d._id, s._id); assertEqual(d._key, s._key); assertEqual(2, s.a); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using _rev -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using _rev +// ////////////////////////////////////////////////////////////////////////////// - testByExampleRev : function () { + testByExampleRev: function () { var d, s; - d = collection.save({ _key: "meow" }); + d = collection.save({ _key: 'meow' }); s = collection.firstExample({ _rev: d._rev }); assertEqual(d._rev, s._rev); - s = collection.firstExample({ _rev: "foo" }); + s = collection.firstExample({ _rev: 'foo' }); assertNull(s); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using _rev -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using _rev +// ////////////////////////////////////////////////////////////////////////////// - testByExampleRevId : function () { + testByExampleRevId: function () { var d, s; - d = collection.save({ _key: "meow" }); - s = collection.firstExample({ _rev: d._rev, _id: cn + "/meow" }); + d = collection.save({ _key: 'meow' }); + s = collection.firstExample({ _rev: d._rev, _id: cn + '/meow' }); assertEqual(d._rev, s._rev); - - s = collection.firstExample({ _rev: d._rev, _id: cn + "/foo" }); + + s = collection.firstExample({ _rev: d._rev, _id: cn + '/foo' }); assertNull(s); - s = collection.firstExample({ _rev: "foo", _id: cn + "/meow" }); + s = collection.firstExample({ _rev: 'foo', _id: cn + '/meow' }); assertNull(s); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using _rev -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using _rev +// ////////////////////////////////////////////////////////////////////////////// - testByExampleRevMore : function () { + testByExampleRevMore: function () { var d, s; - d = collection.save({ _key: "meow", a: 1, b: 2 }); + d = collection.save({ _key: 'meow', a: 1, b: 2 }); s = collection.firstExample({ _rev: d._rev, b: 2, a: 1 }); assertEqual(d._rev, s._rev); - assertEqual("meow", s._key); + assertEqual('meow', s._key); s = collection.firstExample({ _rev: d._rev, a: 1 }); assertEqual(d._rev, s._rev); - assertEqual("meow", s._key); - + assertEqual('meow', s._key); + s = collection.firstExample({ _rev: d._rev, b: 2 }); assertEqual(d._rev, s._rev); - assertEqual("meow", s._key); + assertEqual('meow', s._key); s = collection.firstExample({ _rev: d._rev, a: 2 }); assertNull(s); - + s = collection.firstExample({ _rev: d._rev, b: 1 }); assertNull(s); - + s = collection.firstExample({ _rev: d._rev, a: 1, b: 3 }); assertNull(s); - - s = collection.firstExample({ _rev: "foo", a: 1 }); + + s = collection.firstExample({ _rev: 'foo', a: 1 }); assertNull(s); - - s = collection.firstExample({ _rev: "foo", b: 2 }); + + s = collection.firstExample({ _rev: 'foo', b: 2 }); assertNull(s); - - s = collection.firstExample({ _rev: "foo", a: 1, b: 2 }); + + s = collection.firstExample({ _rev: 'foo', a: 1, b: 2 }); assertNull(s); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using _id -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using _id +// ////////////////////////////////////////////////////////////////////////////// - testByExampleId : function () { + testByExampleId: function () { var d, s; - d = collection.save({ _key: "meow" }); - s = collection.firstExample({ _id: cn + "/foo" }); + d = collection.save({ _key: 'meow' }); + s = collection.firstExample({ _id: cn + '/foo' }); assertNull(s); - s = collection.firstExample({ _id: cn + "/meow" }); + s = collection.firstExample({ _id: cn + '/meow' }); assertEqual(d._id, s._id); assertEqual(d._key, s._key); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using _id & others -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using _id & others +// ////////////////////////////////////////////////////////////////////////////// - testByExampleIdMore : function () { + testByExampleIdMore: function () { var d, s; - d = collection.save({ _key: "meow" }); - s = collection.firstExample({ _id: cn + "/meow", a: 1 }); + d = collection.save({ _key: 'meow' }); + s = collection.firstExample({ _id: cn + '/meow', a: 1 }); assertEqual(null, s); - d = collection.save({ _key: "foo", a: 2 }); - s = collection.firstExample({ _id: cn + "/foo", a: 2 }); + d = collection.save({ _key: 'foo', a: 2 }); + s = collection.firstExample({ _id: cn + '/foo', a: 2 }); assertEqual(d._id, s._id); assertEqual(d._key, s._key); assertEqual(2, s.a); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using _id & sub-attributes -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using _id & sub-attributes +// ////////////////////////////////////////////////////////////////////////////// - testByExampleIdSubAttributes : function () { + testByExampleIdSubAttributes: function () { var d, s; - d = collection.save({ _key: "meow", foo: { bar: "baz" } }); - s = collection.firstExample({ _id: cn + "/meow", foo: { bar: "baz" } }); + d = collection.save({ _key: 'meow', foo: { bar: 'baz' } }); + s = collection.firstExample({ _id: cn + '/meow', foo: { bar: 'baz' } }); assertEqual(d._id, s._id); assertEqual(d._key, s._key); - assertEqual({ bar: "baz" }, s.foo); + assertEqual({ bar: 'baz' }, s.foo); - d = collection.save({ _key: "foo", values: [ { foo: "bar", baz: "bam" } ] }); - s = collection.firstExample({ _id: cn + "/foo", values: [ { foo: "bar", baz: "bam" } ] }); + d = collection.save({ _key: 'foo', values: [ { foo: 'bar', baz: 'bam' } ] }); + s = collection.firstExample({ _id: cn + '/foo', values: [ { foo: 'bar', baz: 'bam' } ] }); assertEqual(d._id, s._id); assertEqual(d._key, s._key); - assertEqual([ { foo: "bar", baz: "bam" } ], s.values); + assertEqual([ { foo: 'bar', baz: 'bam' } ], s.values); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using non existing system attribute -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using non existing system attribute +// ////////////////////////////////////////////////////////////////////////////// - testByExampleNonExisting : function () { - var d, s; - - d = collection.save({ _key: "meow" }); - s = collection.firstExample({ _foo: "foo" }); - assertEqual(null, s); - }, - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample -//////////////////////////////////////////////////////////////////////////////// - - testByExampleObject : function () { - var d1 = collection.save({ i : 1 }); - var d2 = collection.save({ i : 1, a : { j : 1 } }); - var d3 = collection.save({ i : 1, a : { j : 1, k : 1 } }); - var d4 = collection.save({ i : 1, a : { j : 2, k : 2 } }); - var d5 = collection.save({ i : 2 }); - var d6 = collection.save({ i : 2, a : 2 }); - var d7 = collection.save({ i : 2, a : { j : 2, k : 2 } }); + testByExampleNonExisting: function () { var s; - s = collection.byExample({ i : 1 }).toArray().map(id).sort(); - assertEqual([d1._id, d2._id, d3._id, d4._id].sort(), s); - - s = collection.byExample({ i : 2 }).toArray().map(id).sort(); - assertEqual([d5._id, d6._id, d7._id].sort(), s); - - s = collection.byExample({ a : { j : 1 } }).toArray().map(id).sort(); - assertEqual([d2._id], s); - - s = collection.byExample({ "a.j" : 1 }).toArray().map(id).sort(); - assertEqual([d2._id, d3._id].sort(), s); - - s = collection.byExample({ i : 2, "a.k" : 2 }).toArray().map(id).sort(); - assertEqual([d7._id], s); - - s = collection.firstExample({ "i" : 2, "a.k" : 2 }); - assertEqual(d7._id, s._id); - - s = collection.firstExample({ "i" : 2, "a.k" : 27 }); + collection.save({ _key: 'meow' }); + s = collection.firstExample({ _foo: 'foo' }); assertEqual(null, s); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample +// ////////////////////////////////////////////////////////////////////////////// - testByExampleList : function () { - var d1 = collection.save({ i : 1 }); - var d2 = collection.save({ i : 1, a : { j : 1 } }); - var d3 = collection.save({ i : 1, a : { j : 1, k : 1 } }); - var d4 = collection.save({ i : 1, a : { j : 2, k : 2 } }); - var d5 = collection.save({ i : 2 }); - var d6 = collection.save({ i : 2, a : 2 }); - var d7 = collection.save({ i : 2, a : { j : 2, k : 2 } }); + testByExampleObject: function () { + var d1 = collection.save({ i: 1 }); + var d2 = collection.save({ i: 1, a: { j: 1 } }); + var d3 = collection.save({ i: 1, a: { j: 1, k: 1 } }); + var d4 = collection.save({ i: 1, a: { j: 2, k: 2 } }); + var d5 = collection.save({ i: 2 }); + var d6 = collection.save({ i: 2, a: 2 }); + var d7 = collection.save({ i: 2, a: { j: 2, k: 2 } }); var s; - s = collection.byExample("i", 1).toArray().map(id).sort(); + s = collection.byExample({ i: 1 }).toArray().map(id).sort(); assertEqual([d1._id, d2._id, d3._id, d4._id].sort(), s); - s = collection.byExample("i", 2).toArray().map(id).sort(); + s = collection.byExample({ i: 2 }).toArray().map(id).sort(); assertEqual([d5._id, d6._id, d7._id].sort(), s); - s = collection.byExample("a", { j : 1 }).toArray().map(id).sort(); + s = collection.byExample({ a: { j: 1 } }).toArray().map(id).sort(); assertEqual([d2._id], s); - s = collection.byExample("a.j", 1).toArray().map(id).sort(); + s = collection.byExample({ 'a.j': 1 }).toArray().map(id).sort(); assertEqual([d2._id, d3._id].sort(), s); - s = collection.byExample("i", 2, "a.k", 2).toArray().map(id).sort(); + s = collection.byExample({ i: 2, 'a.k': 2 }).toArray().map(id).sort(); assertEqual([d7._id], s); - s = collection.firstExample("i", 2, "a.k", 2); + s = collection.firstExample({ 'i': 2, 'a.k': 2 }); assertEqual(d7._id, s._id); - s = collection.firstExample("i", 2, "a.k", 27); + s = collection.firstExample({ 'i': 2, 'a.k': 27 }); assertEqual(null, s); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: removeByExample -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample +// ////////////////////////////////////////////////////////////////////////////// - testRemoveByExample : function () { + testByExampleList: function () { + var d1 = collection.save({ i: 1 }); + var d2 = collection.save({ i: 1, a: { j: 1 } }); + var d3 = collection.save({ i: 1, a: { j: 1, k: 1 } }); + var d4 = collection.save({ i: 1, a: { j: 2, k: 2 } }); + var d5 = collection.save({ i: 2 }); + var d6 = collection.save({ i: 2, a: 2 }); + var d7 = collection.save({ i: 2, a: { j: 2, k: 2 } }); + var s; + + s = collection.byExample('i', 1).toArray().map(id).sort(); + assertEqual([d1._id, d2._id, d3._id, d4._id].sort(), s); + + s = collection.byExample('i', 2).toArray().map(id).sort(); + assertEqual([d5._id, d6._id, d7._id].sort(), s); + + s = collection.byExample('a', { j: 1 }).toArray().map(id).sort(); + assertEqual([d2._id], s); + + s = collection.byExample('a.j', 1).toArray().map(id).sort(); + assertEqual([d2._id, d3._id].sort(), s); + + s = collection.byExample('i', 2, 'a.k', 2).toArray().map(id).sort(); + assertEqual([d7._id], s); + + s = collection.firstExample('i', 2, 'a.k', 2); + assertEqual(d7._id, s._id); + + s = collection.firstExample('i', 2, 'a.k', 27); + assertEqual(null, s); + }, + +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: removeByExample +// ////////////////////////////////////////////////////////////////////////////// + + testRemoveByExample: function () { var deleted; for (var i = 0; i < 50; ++i) { - collection.save({ value : i }); + collection.save({ value: i }); } - deleted = collection.removeByExample({ value : 2 }); + deleted = collection.removeByExample({ value: 2 }); assertEqual(1, deleted); - deleted = collection.removeByExample({ value : 2 }); + deleted = collection.removeByExample({ value: 2 }); assertEqual(0, deleted); - deleted = collection.removeByExample({ value : 20 }); + deleted = collection.removeByExample({ value: 20 }); assertEqual(1, deleted); - deleted = collection.removeByExample({ value : 20 }); + deleted = collection.removeByExample({ value: 20 }); assertEqual(0, deleted); - deleted = collection.removeByExample({ value : 1 }); + deleted = collection.removeByExample({ value: 1 }); assertEqual(1, deleted); // not existing documents - deleted = collection.removeByExample({ value : 50 }); + deleted = collection.removeByExample({ value: 50 }); assertEqual(0, deleted); - deleted = collection.removeByExample({ value : null }); + deleted = collection.removeByExample({ value: null }); assertEqual(0, deleted); - deleted = collection.removeByExample({ value : "5" }); + deleted = collection.removeByExample({ value: '5' }); assertEqual(0, deleted); - deleted = collection.removeByExample({ peter : "meow" }); + deleted = collection.removeByExample({ peter: 'meow' }); assertEqual(0, deleted); collection.truncate(); - deleted = collection.removeByExample({ value : 4 }); + deleted = collection.removeByExample({ value: 4 }); assertEqual(0, deleted); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: removeByExample with new signature -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: removeByExample with new signature +// ////////////////////////////////////////////////////////////////////////////// - testRemoveByExampleWithNewSignature : function () { + testRemoveByExampleWithNewSignature: function () { var deleted; - collection.save({ b: 1, value : 2222 }); + collection.save({ b: 1, value: 2222 }); for (var i = 0; i < 50; ++i) { - collection.save({ a: 1, value : i }); + collection.save({ a: 1, value: i }); } // test default parameter - deleted = collection.removeByExample({ b : 1 }); + deleted = collection.removeByExample({ b: 1 }); assertEqual(1, deleted); - deleted = collection.removeByExample({ a : 1 }, {limit : 10}); + deleted = collection.removeByExample({ a: 1 }, {limit: 10}); assertEqual(10, deleted); - deleted = collection.removeByExample({ a : 1 }, {waitForSync: true, limit : 15}); + deleted = collection.removeByExample({ a: 1 }, {waitForSync: true, limit: 15}); assertEqual(15, deleted); // not existing documents - deleted = collection.removeByExample({ value : 500 }); + deleted = collection.removeByExample({ value: 500 }); assertEqual(0, deleted); - deleted = collection.removeByExample({ value : null }); + deleted = collection.removeByExample({ value: null }); assertEqual(0, deleted); - deleted = collection.removeByExample({ value : "5" }); + deleted = collection.removeByExample({ value: '5' }); assertEqual(0, deleted); - deleted = collection.removeByExample({ peter : "meow" }); + deleted = collection.removeByExample({ peter: 'meow' }); assertEqual(0, deleted); collection.truncate(); - deleted = collection.removeByExample({ value : 4 }); + deleted = collection.removeByExample({ value: 4 }); assertEqual(0, deleted); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: removeByExample -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: removeByExample +// ////////////////////////////////////////////////////////////////////////////// - testRemoveByExampleMult : function () { + testRemoveByExampleMult: function () { var deleted; for (var i = 0; i < 5; ++i) { for (var j = 0; j < 5; ++j) { - collection.save({ value1 : i, value2: j }); + collection.save({ value1: i, value2: j }); } } - deleted = collection.removeByExample({ value2 : 2 }); + deleted = collection.removeByExample({ value2: 2 }); assertEqual(5, deleted); - deleted = collection.removeByExample({ value2 : 2 }); + deleted = collection.removeByExample({ value2: 2 }); assertEqual(0, deleted); - deleted = collection.removeByExample({ value1 : 4 }); + deleted = collection.removeByExample({ value1: 4 }); assertEqual(4, deleted); - deleted = collection.removeByExample({ value1 : 4 }); + deleted = collection.removeByExample({ value1: 4 }); assertEqual(0, deleted); // not existing documents - deleted = collection.removeByExample({ value1 : 99 }); + deleted = collection.removeByExample({ value1: 99 }); assertEqual(0, deleted); - deleted = collection.removeByExample({ value1 : "0" }); + deleted = collection.removeByExample({ value1: '0' }); assertEqual(0, deleted); - deleted = collection.removeByExample({ meow : 1 }); + deleted = collection.removeByExample({ meow: 1 }); assertEqual(0, deleted); - deleted = collection.removeByExample({ meow : "peter" }); + deleted = collection.removeByExample({ meow: 'peter' }); assertEqual(0, deleted); collection.truncate(); @@ -1393,958 +1387,960 @@ function SimpleQueryByExampleSuite () { assertEqual(0, deleted); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: removeByExample -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: removeByExample +// ////////////////////////////////////////////////////////////////////////////// - testRemoveByExampleLimit : function () { + testRemoveByExampleLimit: function () { var deleted; for (var i = 0; i < 50; ++i) { - collection.save({ value : 1 }); + collection.save({ value: 1 }); } - deleted = collection.removeByExample({ value : 1 }, false, 10); + deleted = collection.removeByExample({ value: 1 }, false, 10); assertEqual(10, deleted); assertEqual(40, collection.count()); - deleted = collection.removeByExample({ value : 1 }, false, 20); + deleted = collection.removeByExample({ value: 1 }, false, 20); assertEqual(20, deleted); assertEqual(20, collection.count()); - deleted = collection.removeByExample({ value : 1 }, false, 20); + deleted = collection.removeByExample({ value: 1 }, false, 20); assertEqual(20, deleted); assertEqual(0, collection.count()); - deleted = collection.removeByExample({ value : 1 }, false, 20); + deleted = collection.removeByExample({ value: 1 }, false, 20); assertEqual(0, deleted); assertEqual(0, collection.count()); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: replaceByExample -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: replaceByExample +// ////////////////////////////////////////////////////////////////////////////// - testReplaceByExample : function () { + testReplaceByExample: function () { var replaced; for (var i = 0; i < 50; ++i) { - collection.save({ value : i }); + collection.save({ value: i }); } - replaced = collection.replaceByExample({ value : 2 }, { foo : "bar", bar : "baz" }); + replaced = collection.replaceByExample({ value: 2 }, { foo: 'bar', bar: 'baz' }); assertEqual(1, replaced); assertEqual(50, collection.count()); - var doc = collection.firstExample({ foo : "bar", bar : "baz" }); - assertEqual("bar", doc.foo); - assertEqual("baz", doc.bar); + var doc = collection.firstExample({ foo: 'bar', bar: 'baz' }); + assertEqual('bar', doc.foo); + assertEqual('baz', doc.bar); assertEqual(undefined, doc.value); // not existing documents - replaced = collection.replaceByExample({ meow : true }, { }); + replaced = collection.replaceByExample({ meow: true }, { }); assertEqual(0, replaced); - replaced = collection.replaceByExample({ value : 142 }, { }); + replaced = collection.replaceByExample({ value: 142 }, { }); assertEqual(0, replaced); - replaced = collection.replaceByExample({ value : "peng!" }, { }); + replaced = collection.replaceByExample({ value: 'peng!' }, { }); assertEqual(0, replaced); collection.truncate(); - replaced = collection.replaceByExample({ value : 6 }, { }); + replaced = collection.replaceByExample({ value: 6 }, { }); assertEqual(0, replaced); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: replaceByExampleWithNewSignature -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: replaceByExampleWithNewSignature +// ////////////////////////////////////////////////////////////////////////////// - testReplaceByExampleWithNewSignature : function () { + testReplaceByExampleWithNewSignature: function () { var replaced; for (var i = 0; i < 50; ++i) { collection.save({ value: 2, a: i, b: i + 1 }); } - replaced = collection.replaceByExample({ value : 2 }, - { foo : "bar", bar : "baz" }, - {limit : 20, waitForSync: true}); + replaced = collection.replaceByExample({ value: 2 }, + { foo: 'bar', bar: 'baz' }, + {limit: 20, waitForSync: true}); assertEqual(20, replaced); assertEqual(50, collection.count()); - var doc = collection.firstExample({ foo : "bar", bar : "baz" }); - assertEqual("bar", doc.foo); - assertEqual("baz", doc.bar); + var doc = collection.firstExample({ foo: 'bar', bar: 'baz' }); + assertEqual('bar', doc.foo); + assertEqual('baz', doc.bar); assertEqual(undefined, doc.value); assertEqual(undefined, doc.a); assertEqual(undefined, doc.b); // not existing documents - replaced = collection.replaceByExample({ meow : true }, { }); + replaced = collection.replaceByExample({ meow: true }, { }); assertEqual(0, replaced); - replaced = collection.replaceByExample({ value : 142 }, { }); + replaced = collection.replaceByExample({ value: 142 }, { }); assertEqual(0, replaced); - replaced = collection.replaceByExample({ value : "peng!" }, { }); + replaced = collection.replaceByExample({ value: 'peng!' }, { }); assertEqual(0, replaced); collection.truncate(); - replaced = collection.replaceByExample({ value : 6 }, { }); + replaced = collection.replaceByExample({ value: 6 }, { }); assertEqual(0, replaced); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: replaceByExample -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: replaceByExample +// ////////////////////////////////////////////////////////////////////////////// - testReplaceByExampleLimit : function () { + testReplaceByExampleLimit: function () { var replaced, docs; for (var i = 0; i < 50; ++i) { - collection.save({ value : 1 }); + collection.save({ value: 1 }); } - replaced = collection.replaceByExample({ value : 1 }, { foo : "bar", bar : "baz" }, false, 10); + replaced = collection.replaceByExample({ value: 1 }, { foo: 'bar', bar: 'baz' }, false, 10); assertEqual(10, replaced); assertEqual(50, collection.count()); - docs = collection.byExample({ foo : "bar", bar : "baz" }).toArray(); + docs = collection.byExample({ foo: 'bar', bar: 'baz' }).toArray(); assertEqual(10, docs.length); - docs = collection.byExample({ value : 1 }).toArray(); + docs = collection.byExample({ value: 1 }).toArray(); assertEqual(40, docs.length); - replaced = collection.replaceByExample({ value : 1 }, { meow : false }, false, 15); + replaced = collection.replaceByExample({ value: 1 }, { meow: false }, false, 15); assertEqual(15, replaced); assertEqual(50, collection.count()); - docs = collection.byExample({ foo : "bar", bar : "baz" }).toArray(); + docs = collection.byExample({ foo: 'bar', bar: 'baz' }).toArray(); assertEqual(10, docs.length); - docs = collection.byExample({ meow : false }).toArray(); + docs = collection.byExample({ meow: false }).toArray(); assertEqual(15, docs.length); - docs = collection.byExample({ value : 1 }).toArray(); + docs = collection.byExample({ value: 1 }).toArray(); assertEqual(25, docs.length); // not existing documents - replaced = collection.replaceByExample({ meow : true }, { }, false, 99); + replaced = collection.replaceByExample({ meow: true }, { }, false, 99); assertEqual(0, replaced); - replaced = collection.replaceByExample({ value : 42 }, { }, false, 99); + replaced = collection.replaceByExample({ value: 42 }, { }, false, 99); assertEqual(0, replaced); - replaced = collection.replaceByExample({ value : "peng!" }, { }, false, 99); + replaced = collection.replaceByExample({ value: 'peng!' }, { }, false, 99); assertEqual(0, replaced); // check counts - docs = collection.byExample({ foo : "bar", bar : "baz" }).toArray(); + docs = collection.byExample({ foo: 'bar', bar: 'baz' }).toArray(); assertEqual(10, docs.length); - docs = collection.byExample({ meow : false }).toArray(); + docs = collection.byExample({ meow: false }).toArray(); assertEqual(15, docs.length); - docs = collection.byExample({ value : 1 }).toArray(); + docs = collection.byExample({ value: 1 }).toArray(); assertEqual(25, docs.length); collection.truncate(); - replaced = collection.replaceByExample({ value : 1 }, { }, false); + replaced = collection.replaceByExample({ value: 1 }, { }, false); assertEqual(0, replaced); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: updateByExample -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: updateByExample +// ////////////////////////////////////////////////////////////////////////////// - testUpdateByExample : function () { + testUpdateByExample: function () { var updated; for (var i = 0; i < 50; ++i) { - collection.save({ value : i }); + collection.save({ value: i }); } // update and keep old values - updated = collection.updateByExample({ value : 2 }, { foo : "bar", bar : "baz" }); + updated = collection.updateByExample({ value: 2 }, { foo: 'bar', bar: 'baz' }); assertEqual(1, updated); assertEqual(50, collection.count()); - var doc = collection.firstExample({ foo : "bar", bar : "baz" }); - assertEqual("bar", doc.foo); - assertEqual("baz", doc.bar); + var doc = collection.firstExample({ foo: 'bar', bar: 'baz' }); + assertEqual('bar', doc.foo); + assertEqual('baz', doc.bar); assertEqual(2, doc.value); // update and remove old values - updated = collection.updateByExample({ value : 5 }, { foo : "bart", bar : "baz", value : null }, false); + updated = collection.updateByExample({ value: 5 }, { foo: 'bart', bar: 'baz', value: null }, false); assertEqual(1, updated); - doc = collection.firstExample({ foo : "bart", bar : "baz" }); - assertEqual("bart", doc.foo); - assertEqual("baz", doc.bar); + doc = collection.firstExample({ foo: 'bart', bar: 'baz' }); + assertEqual('bart', doc.foo); + assertEqual('baz', doc.bar); assertEqual(undefined, doc.value); // update and overwrite old values - updated = collection.updateByExample({ value : 17 }, { foo : "barw", bar : "baz", value : 9 }, false); + updated = collection.updateByExample({ value: 17 }, { foo: 'barw', bar: 'baz', value: 9 }, false); assertEqual(1, updated); - doc = collection.firstExample({ foo : "barw", bar : "baz" }); - assertEqual("barw", doc.foo); - assertEqual("baz", doc.bar); + doc = collection.firstExample({ foo: 'barw', bar: 'baz' }); + assertEqual('barw', doc.foo); + assertEqual('baz', doc.bar); assertEqual(9, doc.value); // not existing documents - updated = collection.updateByExample({ meow : true }, { }); + updated = collection.updateByExample({ meow: true }, { }); assertEqual(0, updated); - updated = collection.updateByExample({ value : 142 }, { }); + updated = collection.updateByExample({ value: 142 }, { }); assertEqual(0, updated); - updated = collection.updateByExample({ value : "peng!" }, { }); + updated = collection.updateByExample({ value: 'peng!' }, { }); assertEqual(0, updated); collection.truncate(); - updated = collection.updateByExample({ value : 6 }, { }); + updated = collection.updateByExample({ value: 6 }, { }); assertEqual(0, updated); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: updateByExample with new Signature -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: updateByExample with new Signature +// ////////////////////////////////////////////////////////////////////////////// - testUpdateByExampleWithNewSignature : function () { + testUpdateByExampleWithNewSignature: function () { var updated; for (var i = 0; i < 50; ++i) { - collection.save({ value : i , a : 1}); + collection.save({ + value: i, + a: 1 + }); } // update and keep old values - updated = collection.updateByExample({ value : 2 }, { foo : "bar", bar : "baz" }); + updated = collection.updateByExample({ value: 2 }, { foo: 'bar', bar: 'baz' }); assertEqual(1, updated); assertEqual(50, collection.count()); - var doc = collection.firstExample({ foo : "bar", bar : "baz" }); - assertEqual("bar", doc.foo); - assertEqual("baz", doc.bar); + var doc = collection.firstExample({ foo: 'bar', bar: 'baz' }); + assertEqual('bar', doc.foo); + assertEqual('baz', doc.bar); assertEqual(2, doc.value); // update and remove old values - updated = collection.updateByExample({ value : 5 }, - { foo : "bart", bar : "baz", value : null }, + updated = collection.updateByExample({ value: 5 }, + { foo: 'bart', bar: 'baz', value: null }, {keepNull: false}); assertEqual(1, updated); - doc = collection.firstExample({ foo : "bart", bar : "baz" }); - assertEqual("bart", doc.foo); - assertEqual("baz", doc.bar); + doc = collection.firstExample({ foo: 'bart', bar: 'baz' }); + assertEqual('bart', doc.foo); + assertEqual('baz', doc.bar); assertEqual(undefined, doc.value); // update and overwrite old values - updated = collection.updateByExample({ value : 17 }, { foo : "barw", bar : "baz", value : 9 }, {keepNull: false}); + updated = collection.updateByExample({ value: 17 }, { foo: 'barw', bar: 'baz', value: 9 }, {keepNull: false}); assertEqual(1, updated); - doc = collection.firstExample({ foo : "barw", bar : "baz" }); - assertEqual("barw", doc.foo); - assertEqual("baz", doc.bar); + doc = collection.firstExample({ foo: 'barw', bar: 'baz' }); + assertEqual('barw', doc.foo); + assertEqual('baz', doc.bar); assertEqual(9, doc.value); // update and remove old values keep null values - updated = collection.updateByExample({ value : 6 }, - { foo : "bart6", bar : "baz6", value : null }, + updated = collection.updateByExample({ value: 6 }, + { foo: 'bart6', bar: 'baz6', value: null }, {keepNull: true}); assertEqual(1, updated); - doc = collection.firstExample({ foo : "bart6", bar : "baz6" }); - assertEqual("bart6", doc.foo); - assertEqual("baz6", doc.bar); + doc = collection.firstExample({ foo: 'bart6', bar: 'baz6' }); + assertEqual('bart6', doc.foo); + assertEqual('baz6', doc.bar); assertEqual(null, doc.value); // not existing documents - updated = collection.updateByExample({ meow : true }, { }); + updated = collection.updateByExample({ meow: true }, { }); assertEqual(0, updated); - updated = collection.updateByExample({ nonExistentValue : "foo" }, { }); + updated = collection.updateByExample({ nonExistentValue: 'foo' }, { }); assertEqual(0, updated); collection.truncate(); - updated = collection.updateByExample({ value : 6 }, { }); + updated = collection.updateByExample({ value: 6 }, { }); assertEqual(0, updated); for (i = 0; i < 50; ++i) { - collection.save({ test : i , limitTest : 1}); + collection.save({ + test: i, + limitTest: 1 + }); } // update and remove old values keep null values updated = collection.updateByExample( - { limitTest : 1 }, - { foo : "bart", bar : "baz", value : null }, - {keepNull: true, limit : 30}); + { limitTest: 1 }, + { foo: 'bart', bar: 'baz', value: null }, + {keepNull: true, limit: 30}); assertEqual(30, updated); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: updateByExample -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: updateByExample +// ////////////////////////////////////////////////////////////////////////////// - testUpdateByExampleLimit : function () { + testUpdateByExampleLimit: function () { var updated, docs; for (var i = 0; i < 50; ++i) { - collection.save({ value : 1 }); + collection.save({ value: 1 }); } // update some, keep old values - updated = collection.updateByExample({ value : 1 }, { foo : "bar", bar : "baz" }, false, false, 10); + updated = collection.updateByExample({ value: 1 }, { foo: 'bar', bar: 'baz' }, false, false, 10); assertEqual(10, updated); assertEqual(50, collection.count()); - docs = collection.byExample({ foo : "bar", bar : "baz" }).toArray(); + docs = collection.byExample({ foo: 'bar', bar: 'baz' }).toArray(); assertEqual(10, docs.length); - docs = collection.byExample({ value : 1 }).toArray(); + docs = collection.byExample({ value: 1 }).toArray(); assertEqual(50, docs.length); // update some others - updated = collection.updateByExample({ value : 1 }, { meow : false }, false, false, 15); + updated = collection.updateByExample({ value: 1 }, { meow: false }, false, false, 15); assertEqual(15, updated); assertEqual(50, collection.count()); - docs = collection.byExample({ foo : "bar", bar : "baz" }).toArray(); + docs = collection.byExample({ foo: 'bar', bar: 'baz' }).toArray(); assertEqual(10, docs.length); - docs = collection.byExample({ meow : false }).toArray(); + docs = collection.byExample({ meow: false }).toArray(); assertEqual(15, docs.length); - docs = collection.byExample({ value : 1 }).toArray(); + docs = collection.byExample({ value: 1 }).toArray(); assertEqual(50, docs.length); // update some, remove old values - updated = collection.updateByExample({ value : 1 }, { value : null, fox : true }, false, false, 5); + updated = collection.updateByExample({ value: 1 }, { value: null, fox: true }, false, false, 5); assertEqual(5, updated); assertEqual(50, collection.count()); - docs = collection.byExample({ fox : true }).toArray(); + docs = collection.byExample({ fox: true }).toArray(); assertEqual(5, docs.length); - docs = collection.byExample({ value : 1 }).toArray(); + docs = collection.byExample({ value: 1 }).toArray(); assertEqual(45, docs.length); // update some, overwrite old values - updated = collection.updateByExample({ value : 1 }, { value : 16 }, false, false, 10); + updated = collection.updateByExample({ value: 1 }, { value: 16 }, false, false, 10); assertEqual(10, updated); assertEqual(50, collection.count()); - docs = collection.byExample({ value : 16 }).toArray(); + docs = collection.byExample({ value: 16 }).toArray(); assertEqual(10, docs.length); - docs = collection.byExample({ fox : true }).toArray(); + docs = collection.byExample({ fox: true }).toArray(); assertEqual(5, docs.length); - docs = collection.byExample({ value : 1 }).toArray(); + docs = collection.byExample({ value: 1 }).toArray(); assertEqual(35, docs.length); // not existing documents - updated = collection.updateByExample({ meow : true }, { }, false, false, 99); + updated = collection.updateByExample({ meow: true }, { }, false, false, 99); assertEqual(0, updated); - updated = collection.updateByExample({ value : 42 }, { }, false, false, 99); + updated = collection.updateByExample({ value: 42 }, { }, false, false, 99); assertEqual(0, updated); - updated = collection.updateByExample({ value : "peng!" }, { }, false, false, 99); + updated = collection.updateByExample({ value: 'peng!' }, { }, false, false, 99); assertEqual(0, updated); collection.truncate(); - updated = collection.updateByExample({ value : 1 }, { }); + updated = collection.updateByExample({ value: 1 }, { }); assertEqual(0, updated); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: updateByExample, mergeObjects -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: updateByExample, mergeObjects +// ////////////////////////////////////////////////////////////////////////////// - testUpdateByExampleMergeObjectsSameUnspecified : function () { + testUpdateByExampleMergeObjectsSameUnspecified: function () { var updated; - collection.save({ _key: "one", value : { foo: "test" } }); + collection.save({ _key: 'one', value: { foo: 'test' } }); // update don't specify mergeObjects behavior - updated = collection.updateByExample({ value: { foo : "test" } }, { value: { foo : "baz" } }); + updated = collection.updateByExample({ value: { foo: 'test' } }, { value: { foo: 'baz' } }); assertEqual(1, updated); - var doc = collection.document("one"); - assertEqual({ foo: "baz" }, doc.value); + var doc = collection.document('one'); + assertEqual({ foo: 'baz' }, doc.value); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: updateByExample, mergeObjects -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: updateByExample, mergeObjects +// ////////////////////////////////////////////////////////////////////////////// - testUpdateByExampleMergeObjectsUnspecified : function () { + testUpdateByExampleMergeObjectsUnspecified: function () { var updated; - collection.save({ _key: "one", value : { foo: "test" } }); + collection.save({ _key: 'one', value: { foo: 'test' } }); // update don't specify mergeObjects behavior - updated = collection.updateByExample({ value: { foo : "test" } }, - { value: { bar : "baz" } }); + updated = collection.updateByExample({ value: { foo: 'test' } }, + { value: { bar: 'baz' } }); assertEqual(1, updated); - var doc = collection.document("one"); - assertEqual({ foo: "test", bar: "baz" }, doc.value); + var doc = collection.document('one'); + assertEqual({ foo: 'test', bar: 'baz' }, doc.value); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: updateByExample, mergeObjects -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: updateByExample, mergeObjects +// ////////////////////////////////////////////////////////////////////////////// - testUpdateByExampleMergeObjectsTrue : function () { + testUpdateByExampleMergeObjectsTrue: function () { var updated; - collection.save({ _key: "one", value : { foo: "test" } }); + collection.save({ _key: 'one', value: { foo: 'test' } }); // update don't specify mergeObjects behavior - updated = collection.updateByExample({ value: { foo : "test" } }, - { value: { bar : "baz" } }, + updated = collection.updateByExample({ value: { foo: 'test' } }, + { value: { bar: 'baz' } }, { mergeObjects: true }); assertEqual(1, updated); - var doc = collection.document("one"); - assertEqual({ foo: "test", bar: "baz" }, doc.value); + var doc = collection.document('one'); + assertEqual({ foo: 'test', bar: 'baz' }, doc.value); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: updateByExample, mergeObjects -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: updateByExample, mergeObjects +// ////////////////////////////////////////////////////////////////////////////// - testUpdateByExampleMergeObjectsFalse : function () { + testUpdateByExampleMergeObjectsFalse: function () { var updated; - collection.save({ _key: "one", value : { foo: "test" } }); + collection.save({ _key: 'one', value: { foo: 'test' } }); // update don't specify mergeObjects behavior - updated = collection.updateByExample({ value: { foo : "test" } }, - { value: { bar : "baz" } }, + updated = collection.updateByExample({ value: { foo: 'test' } }, + { value: { bar: 'baz' } }, { mergeObjects: false }); assertEqual(1, updated); - var doc = collection.document("one"); - assertEqual({ bar: "baz" }, doc.value); + var doc = collection.document('one'); + assertEqual({ bar: 'baz' }, doc.value); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: updateByExample, mergeObjects -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: updateByExample, mergeObjects +// ////////////////////////////////////////////////////////////////////////////// - testUpdateByExampleMergeObjectsEmptyObject : function () { + testUpdateByExampleMergeObjectsEmptyObject: function () { var updated; - collection.save({ _key: "one", value : { foo: "test" } }); + collection.save({ _key: 'one', value: { foo: 'test' } }); // update don't specify mergeObjects behavior - updated = collection.updateByExample({ value: { foo : "test" } }, { value: { } }); + updated = collection.updateByExample({ value: { foo: 'test' } }, { value: { } }); assertEqual(1, updated); - var doc = collection.document("one"); - assertEqual({ foo: "test" }, doc.value); + var doc = collection.document('one'); + assertEqual({ foo: 'test' }, doc.value); } }; } -//////////////////////////////////////////////////////////////////////////////// -/// @brief test suite: query-by-example -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test suite: query-by-example +// ////////////////////////////////////////////////////////////////////////////// function SimpleQueryByExampleEdgeSuite () { 'use strict'; - var cn = "UnitTestsCollectionByExample"; - var c1 = "UnitTestsCollectionByExampleEdge"; + var cn = 'UnitTestsCollectionByExample'; + var c1 = 'UnitTestsCollectionByExampleEdge'; var collection = null; var edge = null; return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief set up -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief set up +// ////////////////////////////////////////////////////////////////////////////// - setUp : function () { + setUp: function () { db._drop(cn); db._drop(c1); collection = db._create(cn); edge = db._createEdgeCollection(c1); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief tear down -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tear down +// ////////////////////////////////////////////////////////////////////////////// - tearDown : function () { + tearDown: function () { collection.drop(); edge.drop(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using edge index -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using edge index +// ////////////////////////////////////////////////////////////////////////////// - testByExampleEdgeFrom : function () { - edge.save(cn + "/foo", cn + "/bar", { _key: "e1", foo: "bar" }); - edge.save(cn + "/bar", cn + "/foo", { _key: "e2", bar: "foo" }); + testByExampleEdgeFrom: function () { + edge.save(cn + '/foo', cn + '/bar', { _key: 'e1', foo: 'bar' }); + edge.save(cn + '/bar', cn + '/foo', { _key: 'e2', bar: 'foo' }); var doc; - doc = edge.firstExample({ _from: cn + "/foo" }); - assertEqual(c1 + "/e1", doc._id); - assertEqual("e1", doc._key); - assertEqual("bar", doc.foo); - assertEqual(cn + "/foo", doc._from); - assertEqual(cn + "/bar", doc._to); + doc = edge.firstExample({ _from: cn + '/foo' }); + assertEqual(c1 + '/e1', doc._id); + assertEqual('e1', doc._key); + assertEqual('bar', doc.foo); + assertEqual(cn + '/foo', doc._from); + assertEqual(cn + '/bar', doc._to); - doc = edge.firstExample({ _from: cn + "/barbaz" }); + doc = edge.firstExample({ _from: cn + '/barbaz' }); assertNull(doc); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using edge index -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using edge index +// ////////////////////////////////////////////////////////////////////////////// - testByExampleEdgeFromMore : function () { - edge.save(cn + "/foo", cn + "/bar", { _key: "e1", foo: "bar" }); - edge.save(cn + "/bar", cn + "/foo", { _key: "e2", bar: "foo" }); + testByExampleEdgeFromMore: function () { + edge.save(cn + '/foo', cn + '/bar', { _key: 'e1', foo: 'bar' }); + edge.save(cn + '/bar', cn + '/foo', { _key: 'e2', bar: 'foo' }); var doc; - doc = edge.firstExample({ _from: cn + "/foo", foo: "bar" }); - assertEqual(c1 + "/e1", doc._id); - assertEqual("e1", doc._key); - assertEqual("bar", doc.foo); - assertEqual(cn + "/foo", doc._from); - assertEqual(cn + "/bar", doc._to); + doc = edge.firstExample({ _from: cn + '/foo', foo: 'bar' }); + assertEqual(c1 + '/e1', doc._id); + assertEqual('e1', doc._key); + assertEqual('bar', doc.foo); + assertEqual(cn + '/foo', doc._from); + assertEqual(cn + '/bar', doc._to); - doc = edge.firstExample({ _from: cn + "/foo", foo: "baz" }); + doc = edge.firstExample({ _from: cn + '/foo', foo: 'baz' }); assertNull(doc); - doc = edge.firstExample({ _from: cn + "/foo", bar: "foo" }); + doc = edge.firstExample({ _from: cn + '/foo', bar: 'foo' }); assertNull(doc); - doc = edge.firstExample({ _from: cn + "/foo", boo: "far" }); + doc = edge.firstExample({ _from: cn + '/foo', boo: 'far' }); assertNull(doc); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using edge index -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using edge index +// ////////////////////////////////////////////////////////////////////////////// - testByExampleEdgeTo : function () { - edge.save(cn + "/foo", cn + "/bar", { _key: "e1", foo: "bar" }); - edge.save(cn + "/bar", cn + "/foo", { _key: "e2", bar: "foo" }); + testByExampleEdgeTo: function () { + edge.save(cn + '/foo', cn + '/bar', { _key: 'e1', foo: 'bar' }); + edge.save(cn + '/bar', cn + '/foo', { _key: 'e2', bar: 'foo' }); var doc; - doc = edge.firstExample({ _to: cn + "/foo" }); - assertEqual(c1 + "/e2", doc._id); - assertEqual("e2", doc._key); - assertEqual("foo", doc.bar); - assertEqual(cn + "/bar", doc._from); - assertEqual(cn + "/foo", doc._to); + doc = edge.firstExample({ _to: cn + '/foo' }); + assertEqual(c1 + '/e2', doc._id); + assertEqual('e2', doc._key); + assertEqual('foo', doc.bar); + assertEqual(cn + '/bar', doc._from); + assertEqual(cn + '/foo', doc._to); - doc = edge.firstExample({ _to: cn + "/bart" }); + doc = edge.firstExample({ _to: cn + '/bart' }); assertNull(doc); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using edge index -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using edge index +// ////////////////////////////////////////////////////////////////////////////// - testByExampleEdgeToMore : function () { - edge.save(cn + "/foo", cn + "/bar", { _key: "e1", foo: "bar" }); - edge.save(cn + "/bar", cn + "/foo", { _key: "e2", bar: "foo" }); + testByExampleEdgeToMore: function () { + edge.save(cn + '/foo', cn + '/bar', { _key: 'e1', foo: 'bar' }); + edge.save(cn + '/bar', cn + '/foo', { _key: 'e2', bar: 'foo' }); var doc; - doc = edge.firstExample({ _to: cn + "/foo", bar: "foo" }); - assertEqual(c1 + "/e2", doc._id); - assertEqual("e2", doc._key); - assertEqual("foo", doc.bar); - assertEqual(cn + "/bar", doc._from); - assertEqual(cn + "/foo", doc._to); + doc = edge.firstExample({ _to: cn + '/foo', bar: 'foo' }); + assertEqual(c1 + '/e2', doc._id); + assertEqual('e2', doc._key); + assertEqual('foo', doc.bar); + assertEqual(cn + '/bar', doc._from); + assertEqual(cn + '/foo', doc._to); - doc = edge.firstExample({ _to: cn + "/foo", bar: "baz" }); + doc = edge.firstExample({ _to: cn + '/foo', bar: 'baz' }); assertNull(doc); - doc = edge.firstExample({ _to: cn + "/foo", foo: "bar" }); + doc = edge.firstExample({ _to: cn + '/foo', foo: 'bar' }); assertNull(doc); - doc = edge.firstExample({ _to: cn + "/foo", boo: "far" }); + doc = edge.firstExample({ _to: cn + '/foo', boo: 'far' }); assertNull(doc); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using edge index -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using edge index +// ////////////////////////////////////////////////////////////////////////////// - testByExampleEdgeFromTo : function () { - edge.save(cn + "/foo", cn + "/bar", { _key: "e1", foo: "bar" }); - edge.save(cn + "/bar", cn + "/foo", { _key: "e2", bar: "foo" }); + testByExampleEdgeFromTo: function () { + edge.save(cn + '/foo', cn + '/bar', { _key: 'e1', foo: 'bar' }); + edge.save(cn + '/bar', cn + '/foo', { _key: 'e2', bar: 'foo' }); var doc; - doc = edge.firstExample({ _to: cn + "/foo", _from: cn + "/bar" }); - assertEqual(c1 + "/e2", doc._id); - assertEqual("e2", doc._key); - assertEqual("foo", doc.bar); - assertEqual(cn + "/bar", doc._from); - assertEqual(cn + "/foo", doc._to); + doc = edge.firstExample({ _to: cn + '/foo', _from: cn + '/bar' }); + assertEqual(c1 + '/e2', doc._id); + assertEqual('e2', doc._key); + assertEqual('foo', doc.bar); + assertEqual(cn + '/bar', doc._from); + assertEqual(cn + '/foo', doc._to); - doc = edge.firstExample({ _to: cn + "/foo", _from: cn + "/baz" }); + doc = edge.firstExample({ _to: cn + '/foo', _from: cn + '/baz' }); assertNull(doc); - doc = edge.firstExample({ _to: cn + "/bar", _from: cn + "/bar" }); + doc = edge.firstExample({ _to: cn + '/bar', _from: cn + '/bar' }); assertNull(doc); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: byExample, using edge index -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: byExample, using edge index +// ////////////////////////////////////////////////////////////////////////////// - testByExampleEdgeFromToMore : function () { - edge.save(cn + "/foo", cn + "/bar", { _key: "e1", foo: "bar" }); - edge.save(cn + "/bar", cn + "/foo", { _key: "e2", bar: "foo" }); + testByExampleEdgeFromToMore: function () { + edge.save(cn + '/foo', cn + '/bar', { _key: 'e1', foo: 'bar' }); + edge.save(cn + '/bar', cn + '/foo', { _key: 'e2', bar: 'foo' }); var doc; - doc = edge.firstExample({ _to: cn + "/foo", _from: cn + "/bar", bar: "foo" }); - assertEqual(c1 + "/e2", doc._id); - assertEqual("e2", doc._key); - assertEqual("foo", doc.bar); - assertEqual(cn + "/bar", doc._from); - assertEqual(cn + "/foo", doc._to); + doc = edge.firstExample({ _to: cn + '/foo', _from: cn + '/bar', bar: 'foo' }); + assertEqual(c1 + '/e2', doc._id); + assertEqual('e2', doc._key); + assertEqual('foo', doc.bar); + assertEqual(cn + '/bar', doc._from); + assertEqual(cn + '/foo', doc._to); - doc = edge.firstExample({ _to: cn + "/foo", _from: cn + "/baz", bar: "baz" }); + doc = edge.firstExample({ _to: cn + '/foo', _from: cn + '/baz', bar: 'baz' }); assertNull(doc); - doc = edge.firstExample({ _to: cn + "/foo", _from: cn + "/baz", foo: "bar" }); + doc = edge.firstExample({ _to: cn + '/foo', _from: cn + '/baz', foo: 'bar' }); assertNull(doc); - doc = edge.firstExample({ _to: cn + "/bar", _from: cn + "/bar", boo: "far" }); + doc = edge.firstExample({ _to: cn + '/bar', _from: cn + '/bar', boo: 'far' }); assertNull(doc); } }; } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test suite: range -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test suite: range +// ////////////////////////////////////////////////////////////////////////////// function SimpleQueryRangeSuite () { 'use strict'; - var cn = "UnitTestsCollectionRange"; + var cn = 'UnitTestsCollectionRange'; var collection = null; - var age = function(d) { return d.age; }; - var ageSort = function(l, r) { if (l !== r) { if (l < r) { return -1; } return 1; } return 0; }; + var age = function (d) { return d.age; }; + var ageSort = function (l, r) { if (l !== r) { if (l < r) { return -1; } return 1; } return 0; }; return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief set up -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief set up +// ////////////////////////////////////////////////////////////////////////////// - setUp : function () { + setUp: function () { db._drop(cn); collection = db._create(cn); - for (var i = 0; i < 100; ++i) { - collection.save({ age : i }); + for (var i = 0; i < 100; ++i) { + collection.save({ age: i }); } - collection.ensureSkiplist("age"); + collection.ensureSkiplist('age'); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief tear down -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tear down +// ////////////////////////////////////////////////////////////////////////////// - tearDown : function () { + tearDown: function () { collection.drop(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: range -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: range +// ////////////////////////////////////////////////////////////////////////////// - testRange : function () { - var l = collection.range("age", 10, 13).toArray().map(age).sort(ageSort); + testRange: function () { + var l = collection.range('age', 10, 13).toArray().map(age).sort(ageSort); assertEqual([ 10, 11, 12 ], l); - l = collection.closedRange("age", 10, 13).toArray().map(age).sort(ageSort); + l = collection.closedRange('age', 10, 13).toArray().map(age).sort(ageSort); assertEqual([ 10, 11, 12, 13 ], l); - l = collection.range("age", null, 13).toArray().map(age).sort(ageSort); + l = collection.range('age', null, 13).toArray().map(age).sort(ageSort); assertEqual([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ], l); - l = collection.closedRange("age", null, 13).toArray().map(age).sort(ageSort); + l = collection.closedRange('age', null, 13).toArray().map(age).sort(ageSort); assertEqual([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ], l); } }; } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test suite: range -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test suite: range +// ////////////////////////////////////////////////////////////////////////////// function SimpleQuerySparseRangeSuite () { 'use strict'; - var cn = "UnitTestsCollectionRange"; + var cn = 'UnitTestsCollectionRange'; var collection = null; - var age = function(d) { return d.age; }; - var ageSort = function(l, r) { if (l !== r) { if (l < r) { return -1; } return 1; } return 0; }; + var age = function (d) { return d.age; }; + var ageSort = function (l, r) { if (l !== r) { if (l < r) { return -1; } return 1; } return 0; }; return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief set up -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief set up +// ////////////////////////////////////////////////////////////////////////////// - setUp : function () { + setUp: function () { db._drop(cn); collection = db._create(cn); - for (var i = 0; i < 100; ++i) { - collection.save({ age : i }); + for (var i = 0; i < 100; ++i) { + collection.save({ age: i }); } - collection.ensureSkiplist("age", { sparse: true }); + collection.ensureSkiplist('age', { sparse: true }); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief tear down -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tear down +// ////////////////////////////////////////////////////////////////////////////// - tearDown : function () { + tearDown: function () { collection.drop(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: range -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: range +// ////////////////////////////////////////////////////////////////////////////// - testRange : function () { - var l = collection.range("age", 10, 13).toArray().map(age).sort(ageSort); + testRange: function () { + var l = collection.range('age', 10, 13).toArray().map(age).sort(ageSort); assertEqual([ 10, 11, 12 ], l); - l = collection.closedRange("age", 10, 13).toArray().map(age).sort(ageSort); + l = collection.closedRange('age', 10, 13).toArray().map(age).sort(ageSort); assertEqual([ 10, 11, 12, 13 ], l); - l = collection.range("age", null, 13).toArray().map(age).sort(ageSort); + l = collection.range('age', null, 13).toArray().map(age).sort(ageSort); assertEqual([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ], l); - - l = collection.closedRange("age", null, 13).toArray().map(age).sort(ageSort); + + l = collection.closedRange('age', null, 13).toArray().map(age).sort(ageSort); assertEqual([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ], l); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: range -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: range +// ////////////////////////////////////////////////////////////////////////////// - testRangeMultipleIndexes : function () { + testRangeMultipleIndexes: function () { // now we have a sparse and a non-sparse index - collection.ensureSkiplist("age", { sparse: false }); + collection.ensureSkiplist('age', { sparse: false }); - var l = collection.range("age", 10, 13).toArray().map(age).sort(ageSort); + var l = collection.range('age', 10, 13).toArray().map(age).sort(ageSort); assertEqual([ 10, 11, 12 ], l); - l = collection.closedRange("age", 10, 13).toArray().map(age).sort(ageSort); + l = collection.closedRange('age', 10, 13).toArray().map(age).sort(ageSort); assertEqual([ 10, 11, 12, 13 ], l); - l = collection.range("age", null, 13).toArray().map(age).sort(ageSort); + l = collection.range('age', null, 13).toArray().map(age).sort(ageSort); assertEqual([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ], l); - l = collection.closedRange("age", null, 13).toArray().map(age).sort(ageSort); + l = collection.closedRange('age', null, 13).toArray().map(age).sort(ageSort); assertEqual([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ], l); } }; } -//////////////////////////////////////////////////////////////////////////////// -/// @brief test suite: range -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test suite: range +// ////////////////////////////////////////////////////////////////////////////// function SimpleQueryUniqueRangeSuite () { 'use strict'; - var cn = "UnitTestsCollectionRange"; + var cn = 'UnitTestsCollectionRange'; var collection = null; - var age = function(d) { return d.age; }; - var ageSort = function(l, r) { if (l !== r) { if (l < r) { return -1; } return 1; } return 0; }; + var age = function (d) { return d.age; }; + var ageSort = function (l, r) { if (l !== r) { if (l < r) { return -1; } return 1; } return 0; }; return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief set up -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief set up +// ////////////////////////////////////////////////////////////////////////////// - setUp : function () { + setUp: function () { db._drop(cn); collection = db._create(cn); - for (var i = 0; i < 100; ++i) { - collection.save({ age : i }); + for (var i = 0; i < 100; ++i) { + collection.save({ age: i }); } - collection.ensureUniqueSkiplist("age"); + collection.ensureUniqueSkiplist('age'); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief tear down -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tear down +// ////////////////////////////////////////////////////////////////////////////// - tearDown : function () { + tearDown: function () { collection.drop(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: range -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: range +// ////////////////////////////////////////////////////////////////////////////// - testRange : function () { - var l = collection.range("age", 10, 13).toArray().map(age).sort(ageSort); + testRange: function () { + var l = collection.range('age', 10, 13).toArray().map(age).sort(ageSort); assertEqual([ 10, 11, 12 ], l); - l = collection.closedRange("age", 10, 13).toArray().map(age).sort(ageSort); + l = collection.closedRange('age', 10, 13).toArray().map(age).sort(ageSort); assertEqual([ 10, 11, 12, 13 ], l); - l = collection.range("age", null, 13).toArray().map(age).sort(ageSort); + l = collection.range('age', null, 13).toArray().map(age).sort(ageSort); assertEqual([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ], l); - l = collection.closedRange("age", null, 13).toArray().map(age).sort(ageSort); + l = collection.closedRange('age', null, 13).toArray().map(age).sort(ageSort); assertEqual([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ], l); } }; } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test suite: range -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test suite: range +// ////////////////////////////////////////////////////////////////////////////// function SimpleQueryUniqueSparseRangeSuite () { 'use strict'; - var cn = "UnitTestsCollectionRange"; + var cn = 'UnitTestsCollectionRange'; var collection = null; - var age = function(d) { return d.age; }; - var ageSort = function(l, r) { if (l !== r) { if (l < r) { return -1; } return 1; } return 0; }; + var age = function (d) { return d.age; }; + var ageSort = function (l, r) { if (l !== r) { if (l < r) { return -1; } return 1; } return 0; }; return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief set up -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief set up +// ////////////////////////////////////////////////////////////////////////////// - setUp : function () { + setUp: function () { db._drop(cn); collection = db._create(cn); - for (var i = 0; i < 100; ++i) { - collection.save({ age : i }); + for (var i = 0; i < 100; ++i) { + collection.save({ age: i }); } - collection.ensureUniqueSkiplist("age", { sparse: true }); + collection.ensureUniqueSkiplist('age', { sparse: true }); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief tear down -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tear down +// ////////////////////////////////////////////////////////////////////////////// - tearDown : function () { + tearDown: function () { collection.drop(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: range -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: range +// ////////////////////////////////////////////////////////////////////////////// - testRange : function () { - var l = collection.range("age", 10, 13).toArray().map(age).sort(ageSort); + testRange: function () { + var l = collection.range('age', 10, 13).toArray().map(age).sort(ageSort); assertEqual([ 10, 11, 12 ], l); - l = collection.closedRange("age", 10, 13).toArray().map(age).sort(ageSort); + l = collection.closedRange('age', 10, 13).toArray().map(age).sort(ageSort); assertEqual([ 10, 11, 12, 13 ], l); - - l = collection.range("age", null, 13).toArray().map(age).sort(ageSort); + + l = collection.range('age', null, 13).toArray().map(age).sort(ageSort); assertEqual([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ], l); - l = collection.closedRange("age", null, 13).toArray().map(age).sort(ageSort); + l = collection.closedRange('age', null, 13).toArray().map(age).sort(ageSort); assertEqual([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ], l); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: range -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: range +// ////////////////////////////////////////////////////////////////////////////// - testRangeMultipleIndexes : function () { + testRangeMultipleIndexes: function () { // now we have a sparse and a non-sparse index - collection.ensureUniqueSkiplist("age", { sparse: false }); + collection.ensureUniqueSkiplist('age', { sparse: false }); - var l = collection.range("age", 10, 13).toArray().map(age).sort(ageSort); + var l = collection.range('age', 10, 13).toArray().map(age).sort(ageSort); assertEqual([ 10, 11, 12 ], l); - l = collection.closedRange("age", 10, 13).toArray().map(age).sort(ageSort); + l = collection.closedRange('age', 10, 13).toArray().map(age).sort(ageSort); assertEqual([ 10, 11, 12, 13 ], l); - l = collection.range("age", null, 13).toArray().map(age).sort(ageSort); + l = collection.range('age', null, 13).toArray().map(age).sort(ageSort); assertEqual([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ], l); - l = collection.closedRange("age", null, 13).toArray().map(age).sort(ageSort); + l = collection.closedRange('age', null, 13).toArray().map(age).sort(ageSort); assertEqual([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ], l); } }; } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test suite: range -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test suite: range +// ////////////////////////////////////////////////////////////////////////////// function SimpleQueryAnySuite () { 'use strict'; - var cn = "UnitTestsCollectionAny"; + var cn = 'UnitTestsCollectionAny'; var collectionEmpty = null; var collectionOne = null; return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief set up -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief set up +// ////////////////////////////////////////////////////////////////////////////// - setUp : function () { + setUp: function () { var name; - name = cn + "Empty"; + name = cn + 'Empty'; db._drop(name); collectionEmpty = db._create(name); - name = cn + "One"; + name = cn + 'One'; db._drop(name); - collectionOne = db._create(name, { waitForSync : false }); - collectionOne.save({ age : 1 }); + collectionOne = db._create(name, { waitForSync: false }); + collectionOne.save({ age: 1 }); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief tear down -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tear down +// ////////////////////////////////////////////////////////////////////////////// - tearDown : function () { + tearDown: function () { collectionEmpty.drop(); collectionOne.drop(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test: any -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test: any +// ////////////////////////////////////////////////////////////////////////////// - testAny : function () { + testAny: function () { var d = collectionEmpty.any(); assertEqual(null, d); @@ -2355,10 +2351,9 @@ function SimpleQueryAnySuite () { }; } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief executes the test suites -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief executes the test suites +// ////////////////////////////////////////////////////////////////////////////// jsunity.run(SimpleQueryLookupByKeysSuite); jsunity.run(SimpleQueryRemoveByKeysSuite); diff --git a/js/server/tests/aql/aql-optimizer-edge-index.js b/js/server/tests/aql/aql-optimizer-edge-index.js index f897f56999..bdc09425fb 100644 --- a/js/server/tests/aql/aql-optimizer-edge-index.js +++ b/js/server/tests/aql/aql-optimizer-edge-index.js @@ -1,125 +1,124 @@ -/*jshint globalstrict:false, strict:false, maxlen: 500 */ -/*global assertEqual, AQL_EXECUTE */ +/* jshint globalstrict:false, strict:false, maxlen: 500 */ +/* global assertEqual, AQL_EXECUTE */ -//////////////////////////////////////////////////////////////////////////////// -/// @brief tests for index usage -/// -/// @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 -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tests for index usage +// / +// / @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 db = require("@arangodb").db; +var jsunity = require('jsunity'); +var db = require('@arangodb').db; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test suite -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test suite +// ////////////////////////////////////////////////////////////////////////////// function optimizerEdgeIndexTestSuite () { - var c; var e; return { - setUp : function () { - db._drop("UnitTestsCollection"); - db._drop("UnitTestsEdgeCollection"); - c = db._create("UnitTestsCollection"); - e = db._createEdgeCollection("UnitTestsEdgeCollection"); + setUp: function () { + db._drop('UnitTestsCollection'); + db._drop('UnitTestsEdgeCollection'); + db._create('UnitTestsCollection'); + e = db._createEdgeCollection('UnitTestsEdgeCollection'); for (var i = 0; i < 2000; i += 100) { var j; for (j = 0; j < i; ++j) { - e.save("UnitTestsCollection/from" + i, "UnitTestsCollection/nono", { value: i + "-" + j }); + e.save('UnitTestsCollection/from' + i, 'UnitTestsCollection/nono', { value: i + '-' + j }); } for (j = 0; j < i; ++j) { - e.save("UnitTestsCollection/nono", "UnitTestsCollection/to" + i, { value: i + "-" + j }); + e.save('UnitTestsCollection/nono', 'UnitTestsCollection/to' + i, { value: i + '-' + j }); } } }, - tearDown : function () { - db._drop("UnitTestsCollection"); + tearDown: function () { + db._drop('UnitTestsCollection'); + db._drop('UnitTestsEdgeCollection'); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test continuous index scan -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test continuous index scan +// ////////////////////////////////////////////////////////////////////////////// - testFindContinuous : function () { + testFindContinuous: function () { for (var i = 0; i < 20; ++i) { - var query = "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/nono' && i._to == 'UnitTestsCollection/to" + i + "' LIMIT 1 RETURN i._key"; + var query = 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/nono" && i._to == "UnitTestsCollection/to' + i + '" LIMIT 1 RETURN i._key'; var results = AQL_EXECUTE(query); assertEqual(0, results.json.length, query); } }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test index usage -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test index usage +// ////////////////////////////////////////////////////////////////////////////// - testFindNone : function () { + testFindNone: function () { var queries = [ - "FOR i IN " + e.name() + " FILTER i._from == '' RETURN i._key", - "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from0' RETURN i._key", - "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from1' RETURN i._key", - "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from2' RETURN i._key", - "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/' RETURN i._key", - "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection' RETURN i._key", - "FOR i IN " + e.name() + " FILTER i._from == '/' RETURN i._key", - "FOR i IN " + e.name() + " FILTER i._from == '--foobar--' RETURN i._key", - "FOR i IN " + e.name() + " FILTER i._to == '' RETURN i._key", - "FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/from0' RETURN i._key", - "FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/from1' RETURN i._key", - "FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/from2' RETURN i._key", - "FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/' RETURN i._key", - "FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection' RETURN i._key", - "FOR i IN " + e.name() + " FILTER i._to == '/' RETURN i._key", - "FOR i IN " + e.name() + " FILTER i._to == '--foobar--' RETURN i._key" + 'FOR i IN ' + e.name() + ' FILTER i._from == "" RETURN i._key', + 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from0" RETURN i._key', + 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from1" RETURN i._key', + 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from2" RETURN i._key', + 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/" RETURN i._key', + 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection" RETURN i._key', + 'FOR i IN ' + e.name() + ' FILTER i._from == "/" RETURN i._key', + 'FOR i IN ' + e.name() + ' FILTER i._from == "--foobar--" RETURN i._key', + 'FOR i IN ' + e.name() + ' FILTER i._to == "" RETURN i._key', + 'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/from0" RETURN i._key', + 'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/from1" RETURN i._key', + 'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/from2" RETURN i._key', + 'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/" RETURN i._key', + 'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection" RETURN i._key', + 'FOR i IN ' + e.name() + ' FILTER i._to == "/" RETURN i._key', + 'FOR i IN ' + e.name() + ' FILTER i._to == "--foobar--" RETURN i._key' ]; - queries.forEach(function(query) { + queries.forEach(function (query) { var results = AQL_EXECUTE(query); assertEqual([ ], results.json, query); assertEqual(0, results.stats.scannedFull); }); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test index usage -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test index usage +// ////////////////////////////////////////////////////////////////////////////// - testFindFrom : function () { + testFindFrom: function () { var queries = [ - [ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from100' RETURN i._key", 100 ], - [ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from200' RETURN i._key", 200 ], - [ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from1000' RETURN i._key", 1000 ], - [ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from1100' RETURN i._key", 1100 ], - [ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from1900' RETURN i._key", 1900 ] + [ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from100" RETURN i._key', 100 ], + [ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from200" RETURN i._key', 200 ], + [ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from1000" RETURN i._key', 1000 ], + [ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from1100" RETURN i._key', 1100 ], + [ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from1900" RETURN i._key', 1900 ] ]; - queries.forEach(function(query) { + queries.forEach(function (query) { var results = AQL_EXECUTE(query[0]); assertEqual(query[1], results.json.length, query[0]); assertEqual(0, results.stats.scannedFull); @@ -127,20 +126,20 @@ function optimizerEdgeIndexTestSuite () { }); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test index usage -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test index usage +// ////////////////////////////////////////////////////////////////////////////// - testFindTo : function () { + testFindTo: function () { var queries = [ - [ "FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/to100' RETURN i._key", 100 ], - [ "FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/to200' RETURN i._key", 200 ], - [ "FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/to1000' RETURN i._key", 1000 ], - [ "FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/to1100' RETURN i._key", 1100 ], - [ "FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/to1900' RETURN i._key", 1900 ] + [ 'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/to100" RETURN i._key', 100 ], + [ 'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/to200" RETURN i._key', 200 ], + [ 'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/to1000" RETURN i._key', 1000 ], + [ 'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/to1100" RETURN i._key', 1100 ], + [ 'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/to1900" RETURN i._key', 1900 ] ]; - queries.forEach(function(query) { + queries.forEach(function (query) { var results = AQL_EXECUTE(query[0]); assertEqual(query[1], results.json.length, query[0]); assertEqual(0, results.stats.scannedFull); @@ -148,20 +147,20 @@ function optimizerEdgeIndexTestSuite () { }); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief test index usage -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test index usage +// ////////////////////////////////////////////////////////////////////////////// - testFindFromTo : function () { + testFindFromTo: function () { var queries = [ - [ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from100' && i._to == 'UnitTestsCollection/nono' RETURN i._key", 100 ], - [ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from200' && i._to == 'UnitTestsCollection/nono' RETURN i._key", 200 ], - [ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from1000' && i._to == 'UnitTestsCollection/nono' RETURN i._key", 1000 ], - [ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from1100' && i._to == 'UnitTestsCollection/nono' RETURN i._key", 1100 ], - [ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from1900' && i._to == 'UnitTestsCollection/nono' RETURN i._key", 1900 ] + [ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from100" && i._to == "UnitTestsCollection/nono" RETURN i._key', 100 ], + [ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from200" && i._to == "UnitTestsCollection/nono" RETURN i._key', 200 ], + [ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from1000" && i._to == "UnitTestsCollection/nono" RETURN i._key', 1000 ], + [ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from1100" && i._to == "UnitTestsCollection/nono" RETURN i._key', 1100 ], + [ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from1900" && i._to == "UnitTestsCollection/nono" RETURN i._key', 1900 ] ]; - queries.forEach(function(query) { + queries.forEach(function (query) { var results = AQL_EXECUTE(query[0]); assertEqual(query[1], results.json.length, query[0]); assertEqual(0, results.stats.scannedFull); diff --git a/js/server/tests/shell/shell-foxx-legacy-console.js b/js/server/tests/shell/shell-foxx-legacy-console.js index 7b70769d76..d439e9bb0a 100644 --- a/js/server/tests/shell/shell-foxx-legacy-console.js +++ b/js/server/tests/shell/shell-foxx-legacy-console.js @@ -1,31 +1,31 @@ -/*jshint globalstrict:false, strict:false */ +/* jshint globalstrict:false, strict:false */ -//////////////////////////////////////////////////////////////////////////////// -/// @brief tests for Foxx console -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2015 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 Alan Plum -/// @author Copyright 2015, triAGENS GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tests for Foxx console +// / +// / @file +// / +// / DISCLAIMER +// / +// / Copyright 2015 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 Alan Plum +// / @author Copyright 2015, triAGENS GmbH, Cologne, Germany +// ////////////////////////////////////////////////////////////////////////////// var jsunity = require('jsunity'); var expect = require('chai').expect; @@ -37,21 +37,22 @@ var internal = require('internal'); var AssertionError = require('assert').AssertionError; var mountPath = '##TEST##'; +var foxxlogCol = '_foxxlog'; function clear () { 'use strict'; if (!db._foxxlog) { return []; } return db._query( - qb.for('entry').in('_foxxlog') + qb.for('entry').in(foxxlogCol) .filter(qb.eq('entry.mount', qb.str(mountPath))) - .remove('entry').in('_foxxlog') + .remove('entry').in(foxxlogCol) ).toArray(); } -//////////////////////////////////////////////////////////////////////////////// -/// @brief test suite -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief test suite +// ////////////////////////////////////////////////////////////////////////////// function ConsoleTestSuite () { 'use strict'; @@ -59,26 +60,26 @@ function ConsoleTestSuite () { return { -//////////////////////////////////////////////////////////////////////////////// -/// @brief set up -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief set up +// ////////////////////////////////////////////////////////////////////////////// setUp: function () { console = new Console(mountPath); clear(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief tear down -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tear down +// ////////////////////////////////////////////////////////////////////////////// tearDown: function () { clear(); }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief tests -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief tests +// ////////////////////////////////////////////////////////////////////////////// testConsoleLogLogsMessage: function () { clear(); @@ -135,7 +136,11 @@ function ConsoleTestSuite () { testConsoleDirUsesInspect: function () { const args = [ 'lol', - {_PRINT: function (ctx) {ctx.output += 'hello';}} + { + _PRINT: function (ctx) { + ctx.output += 'hello'; + } + } ]; args.forEach(function (arg) { clear(); @@ -279,11 +284,20 @@ function ConsoleTestSuite () { }; } -//////////////////////////////////////////////////////////////////////////////// -/// @brief executes the test suite -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// +// / @brief executes the test suite +// ////////////////////////////////////////////////////////////////////////////// jsunity.run(ConsoleTestSuite); -return jsunity.done(); +let rc = jsunity.done(); +db._useDatabase('_system'); +try { + db._drop(foxxlogCol, { + isSystem: true + }); +} catch (x) { +} + +return rc;