Throw an exception if an ol.structs.RBush is modified while reading

This commit is contained in:
Tom Payne
2013-11-27 14:44:05 +01:00
parent fab0fe5e7a
commit 665781ee03
2 changed files with 100 additions and 1 deletions

View File

@@ -55,6 +55,27 @@ describe('ol.structs.RBush', function() {
});
describe('#insert', function() {
it('throws an exception if called while iterating over all values',
function() {
expect(function() {
rBush.forEach(function(value) {
rBush.insert([0, 0, 1, 1], {});
});
}).to.throwException();
});
it('throws an exception if called while iterating over an extent',
function() {
expect(function() {
rBush.forEachInExtent([-10, -10, 10, 10], function(value) {
rBush.insert([0, 0, 1, 1], {});
});
}).to.throwException();
});
});
describe('#remove', function() {
it('can remove each object', function() {
@@ -66,6 +87,45 @@ describe('ol.structs.RBush', function() {
}
});
it('throws an exception if called while iterating over all values',
function() {
expect(function() {
rBush.forEach(function(value) {
rBush.remove(value);
});
}).to.throwException();
});
it('throws an exception if called while iterating over an extent',
function() {
expect(function() {
rBush.forEachInExtent([-10, -10, 10, 10], function(value) {
rBush.remove(value);
});
}).to.throwException();
});
});
describe('#update', function() {
it('throws an exception if called while iterating over all values',
function() {
expect(function() {
rBush.forEach(function(value) {
rBush.update([0, 0, 1, 1], objs[1]);
});
}).to.throwException();
});
it('throws an exception if called while iterating over an extent',
function() {
expect(function() {
rBush.forEachInExtent([-10, -10, 10, 10], function(value) {
rBush.update([0, 0, 1, 1], objs[1]);
});
}).to.throwException();
});
});
});