Remove goog.asserts.*

This pull requests replaces type check hint assertions with type casts,
library sanity check assertions with conditional console.assert statements
in debug mode, and runtime sanity checks with assertions that throw an
ol.AssertionError with an error code for lookup outside the library.
This commit is contained in:
Andreas Hocevar
2016-07-19 16:39:58 +02:00
parent f50f1f401c
commit 6f5ed17fc5
158 changed files with 1488 additions and 1629 deletions

37
test/spec/ol/ol.test.js Normal file
View File

@@ -0,0 +1,37 @@
goog.provide('ol.test');
describe('ol', function() {
describe('ol.assert', function() {
it('throws an exception', function() {
expect(function() {
ol.assert(false, 42);
}).to.throwException();
});
});
describe('ol.AssertionError', function() {
it('generates a message', function() {
var error = new ol.AssertionError(42);
expect(error.message).to.be('Assertion failed. See /doc/errors.html#42 for details.');
});
it('generates a message with a versioned url', function() {
var origVersion = ol.VERSION;
ol.VERSION = 'foo';
var error = new ol.AssertionError(42);
expect(error.message).to.be('Assertion failed. See http://openlayers.org/en/foo/doc/errors.html#42 for details.');
ol.VERSION = origVersion;
});
it('has an error code', function() {
var error = new ol.AssertionError(42);
expect(error.code).to.be(42);
});
it('has a name', function() {
var error = new ol.AssertionError(42);
expect(error.name).to.be('AssertionError');
})
});
});
goog.require('ol');