|
@@ -3,25 +3,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
// setup
|
|
// setup
|
|
|
-function Thing() {}
|
|
|
|
|
-var thing = new Thing();
|
|
|
|
|
|
|
+var Thing = function Thing() {},
|
|
|
|
|
+ thing = new Thing(),
|
|
|
|
|
+ objToStr = Object.prototype.toString,
|
|
|
|
|
+ getTypeStr = function getTypeStr2(obj) {
|
|
|
|
|
+ return objToStr.call(obj);
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
|
|
|
|
|
// tests
|
|
// tests
|
|
|
exports.typeIsExact = {
|
|
exports.typeIsExact = {
|
|
|
|
|
|
|
|
- "instanceof, constructor matches": function() {
|
|
|
|
|
- thing instanceof Thing && thing.constructor === Thing;
|
|
|
|
|
|
|
+ "getTypeStr (Object#toString.call)": function() {
|
|
|
|
|
+ getTypeStr(thing) === "[object Function]";
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- "not undefined, not null, constructor matches": function() {
|
|
|
|
|
- thing !== undefined && thing !== null && thing.constructor === Thing;
|
|
|
|
|
|
|
+ "instanceof, constructor matches": function() {
|
|
|
|
|
+ thing instanceof Thing && thing.constructor === Thing;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
"truthy, constructor matches": function() {
|
|
"truthy, constructor matches": function() {
|
|
|
thing && thing.constructor === Thing;
|
|
thing && thing.constructor === Thing;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
+ "not undefined, not null, constructor matches": function() {
|
|
|
|
|
+ thing !== undefined && thing !== null && thing.constructor === Thing;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
"typeof, not null, constructor matches": function() {
|
|
"typeof, not null, constructor matches": function() {
|
|
|
typeof thing === "object" && thing !== null && thing.constructor === Thing;
|
|
typeof thing === "object" && thing !== null && thing.constructor === Thing;
|
|
|
},
|
|
},
|
|
@@ -30,4 +38,4 @@ exports.typeIsExact = {
|
|
|
|
|
|
|
|
|
|
|
|
|
// if run directly run benchmarks
|
|
// if run directly run benchmarks
|
|
|
-if (!module.main) require("benchmarksman").runner(exports);
|
|
|
|
|
|
|
+if (!module.parent) require("benchmarksman").runner(exports);
|