diff options
author | John Christopher Anderson <jchris@apache.org> | 2010-08-07 20:33:33 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2010-08-07 20:33:33 +0000 |
commit | b870261adcd15b6ccd56f1ee15fd04cad14bc1a6 (patch) | |
tree | 604b16da93279192bf3df1bc9f594daad70e092a /share/www/script/test | |
parent | d67957c7d609ed9956c439af739da9569d4478fa (diff) |
builtin reduce functions more forgiving about trailing whitespace and other characters
git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.0.x@983307 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/test')
-rw-r--r-- | share/www/script/test/reduce_builtin.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/share/www/script/test/reduce_builtin.js b/share/www/script/test/reduce_builtin.js index 0db6bc09..d9635688 100644 --- a/share/www/script/test/reduce_builtin.js +++ b/share/www/script/test/reduce_builtin.js @@ -72,6 +72,26 @@ couchTests.reduce_builtin = function(debug) { T(result.rows[0].value == 2*(summate(numDocs-i) - summate(i-1))); } + // test for trailing characters after builtin functions, desired behaviour + // is to disregard any trailing characters + // I think the behavior should be a prefix test, so that even "_statsorama" + // or "_stats\nare\awesome" should work just as "_stats" does. - JChris + + var trailing = ["\u000a", "orama", "\nare\nawesome", " ", " \n "]; + + for(var i=0; i < trailing.length; i++) { + result = db.query(map, "_sum" + trailing[i]); + T(result.rows[0].value == 2*summate(numDocs)); + result = db.query(map, "_count" + trailing[i]); + T(result.rows[0].value == 1000); + result = db.query(map, "_stats" + trailing[i]); + T(result.rows[0].value.sum == 2*summate(numDocs)); + T(result.rows[0].value.count == 1000); + T(result.rows[0].value.min == 1); + T(result.rows[0].value.max == 500); + T(result.rows[0].value.sumsqr == 2*sumsqr(numDocs)); + } + db.deleteDb(); db.createDb(); |