// 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. couchTests.view_collation_raw = function(debug) { var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"}); db.deleteDb(); db.createDb(); if (debug) debugger; // NOTE, the values are already in their correct sort order. Consider this // a specification of collation of json types. var values = []; // numbers values.push(1); values.push(2); values.push(3); values.push(4); values.push(false); values.push(null); values.push(true); // then object, compares each key value in the list until different. // larger objects sort after their subset objects. values.push({a:1}); values.push({a:2}); values.push({b:1}); values.push({b:2}); values.push({b:2, a:1}); // Member order does matter for collation. // CouchDB preserves member order // but doesn't require that clients will. // (this test might fail if used with a js engine // that doesn't preserve order) values.push({b:2, c:2}); // then arrays. compared element by element until different. // Longer arrays sort after their prefixes values.push(["a"]); values.push(["b"]); values.push(["b","c"]); values.push(["b","c", "a"]); values.push(["b","d"]); values.push(["b","d", "e"]); // then text, case sensitive values.push("A"); values.push("B"); values.push("a"); values.push("aa"); values.push("b"); values.push("ba"); values.push("bb"); for (var i=0; i