mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2026-01-25 13:14:21 +01:00
should append names
This commit is contained in:
@@ -4,19 +4,19 @@
|
||||
window.core.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")
|
||||
this.check(isFinite(num), append(name, "is an infinite number"));
|
||||
},
|
||||
|
||||
bePositiveInteger: function(num) {
|
||||
bePositiveInteger: function(num, name) {
|
||||
this.beNumber(num);
|
||||
this.check(num >= 0, "Should be positive integer")
|
||||
this.check(num >= 0, append(name, "should be positive integer"));
|
||||
},
|
||||
|
||||
notBeNull: function (obj, name) {
|
||||
this.check(obj != null, name + " is null or undefined");
|
||||
this.check(obj != null, append(name, "is null or undefined"));
|
||||
},
|
||||
|
||||
beString: function(obj) {
|
||||
beString: function(obj, name) {
|
||||
this.check(typeof obj == "string", "should be a string");
|
||||
},
|
||||
check: function(assertion, message) {
|
||||
@@ -25,6 +25,10 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function append(name, msg) {
|
||||
return typeof name == "string" ? name + " " + msg : msg;
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user