Skip to content

Commit

Permalink
Test coverage with less overheads
Browse files Browse the repository at this point in the history
  • Loading branch information
t2ym committed Jan 8, 2017
1 parent 83632b2 commit 3dcf63c
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 43 deletions.
60 changes: 28 additions & 32 deletions Suite.es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,47 +242,43 @@ Copyright (c) 2016, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
description = description.replace(/"/g, '\\"').replace(/\n/g, ' ');
}
var prefix = !_this2.classSyntaxSupport && typeof Suite._createClass === 'function' && (typeof window === 'undefined' ? 'undefined' : _typeof(window)) !== 'object' ? 'self.constructor.' : '';
var checkAndThrough = self.constructor.debug ? function (f) {
new (f(function A() {
_classCallCheck(this, A);
}))().description;return f;
} : function (f) {
return f;
};
expression = chain.length === 1 && name === expression ? 'return ' + name : name === chain[chain.length - 1] ? 'return ' + expression : self.classSyntaxSupport ? 'return class ' + name + ' extends ' + expression + (description ? ' { get description() { return "' + description + '"; } }' : ' {}') : function (subclass, base, description) {
// generate ES5 class by manipulating transpiled func.toString()
return 'return (' + checkAndThrough(description ? function (__BASE_CLASS__) {
return function (_BASE_CLASS__) {
_inherits(__SUBCLASS__, _BASE_CLASS__);
return 'return (' + function () {
/* istanbul ignore next */
return description ? function (__BASE_CLASS__) {
return function (_BASE_CLASS__) {
_inherits(__SUBCLASS__, _BASE_CLASS__);

function __SUBCLASS__() {
_classCallCheck(this, __SUBCLASS__);
function __SUBCLASS__() {
_classCallCheck(this, __SUBCLASS__);

return _possibleConstructorReturn(this, (__SUBCLASS__.__proto__ || Object.getPrototypeOf(__SUBCLASS__)).apply(this, arguments));
}

_createClass(__SUBCLASS__, [{
key: 'description',
get: function get() {
return 314159265358;
return _possibleConstructorReturn(this, (__SUBCLASS__.__proto__ || Object.getPrototypeOf(__SUBCLASS__)).apply(this, arguments));
}
}]);

return __SUBCLASS__;
}(__BASE_CLASS__);
} : function (__BASE_CLASS__) {
return function (_BASE_CLASS__2) {
_inherits(__SUBCLASS__, _BASE_CLASS__2);
_createClass(__SUBCLASS__, [{
key: 'description',
get: function get() {
return 314159265358;
}
}]);

function __SUBCLASS__() {
_classCallCheck(this, __SUBCLASS__);
return __SUBCLASS__;
}(__BASE_CLASS__);
} : function (__BASE_CLASS__) {
return function (_BASE_CLASS__2) {
_inherits(__SUBCLASS__, _BASE_CLASS__2);

return _possibleConstructorReturn(this, (__SUBCLASS__.__proto__ || Object.getPrototypeOf(__SUBCLASS__)).apply(this, arguments));
}
function __SUBCLASS__() {
_classCallCheck(this, __SUBCLASS__);

return __SUBCLASS__;
}(__BASE_CLASS__);
}).toString().replace(/__cov_[^. ]*[.][a-z]\[\'[0-9]*\'\](\[[0-9]*\])?\+\+[;,]?/g, '') // trim istanbul coverage counters
return _possibleConstructorReturn(this, (__SUBCLASS__.__proto__ || Object.getPrototypeOf(__SUBCLASS__)).apply(this, arguments));
}

return __SUBCLASS__;
}(__BASE_CLASS__);
};
}().toString().replace(/__cov_[^. ]*[.][a-z]\[\'[0-9]*\'\](\[[0-9]*\])?\+\+[;,]?/g, '') // trim istanbul coverage counters
.replace(/__SUBCLASS__/g, subclass).replace(/_inherits|_classCallCheck|_createClass|_possibleConstructorReturn/g, prefix + '$&').replace(/ 314159265358;?/g, ' "' + description + '";') + ')(' + base + ');';
}(name, expression, description);
self.classes[name] = new Function('self', expression)(self);
Expand Down
6 changes: 3 additions & 3 deletions Suite.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ class Suite {
description = description.replace(/"/g,'\\"').replace(/\n/g, ' ');
}
let prefix = !this.classSyntaxSupport && typeof Suite._createClass === 'function' && typeof window !== 'object' ? 'self.constructor.' : '';
let checkAndThrough = self.constructor.debug ? function (f) { (new (f(class A {}))()).description; return f; } : f => f;
expression = chain.length === 1 && name === expression
? 'return ' + name
: name === chain[chain.length - 1]
Expand All @@ -274,10 +273,11 @@ class Suite {
? 'return class ' + name + ' extends ' + expression + (description ? ' { get description() { return "' + description + '"; } }' : ' {}')
: (function (subclass, base, description) { // generate ES5 class by manipulating transpiled func.toString()
return 'return (' +
checkAndThrough(description
(() => { /* istanbul ignore next */
return description
? function (__BASE_CLASS__) { return class __SUBCLASS__ extends __BASE_CLASS__ { get description() { return 314159265358; } } }
: function (__BASE_CLASS__) { return class __SUBCLASS__ extends __BASE_CLASS__ {} }
).toString()
})().toString()
.replace(/__cov_[^. ]*[.][a-z]\[\'[0-9]*\'\](\[[0-9]*\])?\+\+[;,]?/g, '') // trim istanbul coverage counters
.replace(/__SUBCLASS__/g, subclass)
.replace(/_inherits|_classCallCheck|_createClass|_possibleConstructorReturn/g, prefix + '$&')
Expand Down
6 changes: 3 additions & 3 deletions Suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ class Suite {
description = description.replace(/"/g,'\\"').replace(/\n/g, ' ');
}
let prefix = !this.classSyntaxSupport && typeof Suite._createClass === 'function' && typeof window !== 'object' ? 'self.constructor.' : '';
let checkAndThrough = self.constructor.debug ? function (f) { (new (f(class A {}))()).description; return f; } : f => f;
expression = chain.length === 1 && name === expression
? 'return ' + name
: name === chain[chain.length - 1]
Expand All @@ -304,10 +303,11 @@ class Suite {
? 'return class ' + name + ' extends ' + expression + (description ? ' { get description() { return "' + description + '"; } }' : ' {}')
: (function (subclass, base, description) { // generate ES5 class by manipulating transpiled func.toString()
return 'return (' +
checkAndThrough(description
(() => { /* istanbul ignore next */
return description
? function (__BASE_CLASS__) { return class __SUBCLASS__ extends __BASE_CLASS__ { get description() { return 314159265358; } } }
: function (__BASE_CLASS__) { return class __SUBCLASS__ extends __BASE_CLASS__ {} }
).toString()
})().toString()
.replace(/__cov_[^. ]*[.][a-z]\[\'[0-9]*\'\](\[[0-9]*\])?\+\+[;,]?/g, '') // trim istanbul coverage counters
.replace(/__SUBCLASS__/g, subclass)
.replace(/_inherits|_classCallCheck|_createClass|_possibleConstructorReturn/g, prefix + '$&')
Expand Down
Loading

0 comments on commit 3dcf63c

Please sign in to comment.