Document and test ol.getUid sequence behavior
This commit is contained in:
@@ -270,8 +270,8 @@ ol.nullFunction = function() {};
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a unique ID for an object. This mutates the object so that further calls
|
* Gets a unique ID for an object. This mutates the object so that further calls
|
||||||
* with the same object as a parameter returns the same value. Adapted from
|
* with the same object as a parameter returns the same value. Unique IDs are generated
|
||||||
* goog.getUid.
|
* as a strictly increasing sequence. Adapted from goog.getUid.
|
||||||
*
|
*
|
||||||
* @param {Object} obj The object to get the unique ID for.
|
* @param {Object} obj The object to get the unique ID for.
|
||||||
* @return {number} The unique ID for the object.
|
* @return {number} The unique ID for the object.
|
||||||
|
|||||||
23
test/spec/ol/index.test.js
Normal file
23
test/spec/ol/index.test.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
goog.provide('ol.test');
|
||||||
|
goog.require('ol');
|
||||||
|
|
||||||
|
describe('getUid()', function() {
|
||||||
|
it('is constant once generated', function() {
|
||||||
|
var a = {};
|
||||||
|
expect(ol.getUid(a)).to.be(ol.getUid(a));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('generates a strictly increasing sequence', function() {
|
||||||
|
var a = {} , b = {}, c = {};
|
||||||
|
ol.getUid(a);
|
||||||
|
ol.getUid(c);
|
||||||
|
ol.getUid(b);
|
||||||
|
|
||||||
|
//uid order should be a < c < b
|
||||||
|
expect(ol.getUid(a)).to.be.lessThan(ol.getUid(c));
|
||||||
|
expect(ol.getUid(c)).to.be.lessThan(ol.getUid(b));
|
||||||
|
expect(ol.getUid(a)).to.be.lessThan(ol.getUid(b));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user