mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2025-12-13 16:32:17 +01:00
29 lines
799 B
JavaScript
29 lines
799 B
JavaScript
(function(){
|
|
window.should = {
|
|
beNumber: function (num, name) {
|
|
this.check(typeof num == "number" && !isNaN(num), num + " is not a number");
|
|
this.check(isFinite(num), num + "is an infinite number")
|
|
},
|
|
|
|
bePositiveInteger: function(num) {
|
|
this.beNumber(num);
|
|
this.check(num >= 0, "Should be positive integer")
|
|
},
|
|
|
|
notBeNull: function (obj, name) {
|
|
this.check(obj != null, name + " is null or undefined");
|
|
},
|
|
|
|
beString: function(obj) {
|
|
this.check(typeof obj == "string", "should be a string");
|
|
},
|
|
check: function(assertion, message) {
|
|
if(assertion !== true) {
|
|
throw new Error (message);
|
|
}
|
|
}
|
|
};
|
|
})();
|
|
|
|
|