Skip to content

Instantly share code, notes, and snippets.

@antoniogarrote
Created February 24, 2011 09:09
Show Gist options
  • Save antoniogarrote/841945 to your computer and use it in GitHub Desktop.
Save antoniogarrote/841945 to your computer and use it in GitHub Desktop.
var repeat = function(c,max,floop,fend,env) {
if(arguments.length===4) { env = {}; }
if(c<max) {
env._i = c;
floop(function(floop,env){
repeat(c+1, max, floop, fend, env);
},env);
} else {
fend(env);
}
}
exports.rangeQueryTest = function(test) {
new QuadIndex.BPlusTree({order: 2}, function(tree){
repeat(0, 10, function(k,env){
var floop = arguments.callee;
tree.insert(quadBuilder(env._i,0,0), function(){
k(floop, env);
});
}, function(env){
repeat(5, 10, function(k,env){
var floop = arguments.callee;
tree.insert(quadBuilder(5,env._i,0), function(){
k(floop, env);
});
}, function(env){
tree.range(patternBuiler(5,null,null), function(results){
for(var i=0; i<results.length; i++) {
test.ok(results[i].subject === 5);
}
test.ok(results.length === 6);
test.done();
});
})
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment