Skip to content
This repository has been archived by the owner on Dec 31, 2019. It is now read-only.

Commit

Permalink
Merge pull request #91 from douglasduteil/feat-dep-babel-6-compatibility
Browse files Browse the repository at this point in the history
Feat dep babel 6 compatibility
  • Loading branch information
douglasduteil committed Nov 13, 2015
2 parents bb51079 + ee4cb75 commit 1e3c696
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 78 deletions.
7 changes: 6 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"stage": 0
"presets": [
"es2015"
],
"plugins": [
"transform-object-rest-spread"
]
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"license": "WTFPL",
"dependencies": {
"babel-core": "^5.8.25",
"babel-core": "^6.1.4",
"escodegen": "^1.6.1",
"esprima": "^2.1.0",
"istanbul": "^0.4.0",
Expand All @@ -49,7 +49,10 @@
"which": "^1.0.9"
},
"devDependencies": {
"babel": "^5.8.23",
"babel-cli": "^6.1.4",
"babel-polyfill": "^6.1.4",
"babel-preset-es2015": "^6.1.4",
"babel-plugin-transform-object-rest-spread": "^6.1.4",
"chai": "^3.2.0",
"hide-stack-frames-from": "^1.0.0",
"mocha": "^2.2.1",
Expand Down
5 changes: 2 additions & 3 deletions src/instrumenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {transform as babelTransform} from 'babel-core';
import esprima from 'esprima';
import escodegen from 'escodegen';

import {SourceMapConsumer, SourceMapGenerator} from 'source-map';
import {SourceMapConsumer} from 'source-map';

const POSITIONS = ['start', 'end'];

Expand All @@ -24,7 +24,7 @@ export class Instrumenter extends istanbul.Instrumenter {

instrumentSync(code, fileName) {

let result = this._r =
const result = this._r =
babelTransform(code, { ...this.babelOptions, filename: fileName });
this._babelMap = new SourceMapConsumer(result.map);

Expand Down Expand Up @@ -151,4 +151,3 @@ export class Instrumenter extends istanbul.Instrumenter {
};

}

2 changes: 1 addition & 1 deletion src/isparta.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from 'istanbul';
export {Store, Collector, hook, Report, config, Reporter, utils, matcherFor, Writer, ContentWriter, FileWriter, _yuiLoadHook, TreeSummarizer, assetsDir} from 'istanbul';
export {Instrumenter} from './instrumenter';
export {VERSION} from '../package.json';
48 changes: 20 additions & 28 deletions test/fixtures/es6-classes/compiled.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
"use strict";
'use strict';

var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
Object.defineProperty(exports, "__esModule", {
value: true
});

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

//

Expand All @@ -11,36 +15,24 @@ var Animal = (function () {
_classCallCheck(this, Animal);
}

_prototypeProperties(Animal, {
getName: {
value: function getName() {
return "Animal";
},
writable: true,
configurable: true
_createClass(Animal, [{
key: 'sayHi',
value: function sayHi() {
return 'Hi, I am a ' + this.type() + '.';
}
}, {
sayHi: {
value: function sayHi() {
return "Hi, I am a " + this.type() + ".";
},
writable: true,
configurable: true
},
sayOther: {
value: function sayOther() {
return "WAT?!";
},
writable: true,
configurable: true
key: 'sayOther',
value: function sayOther() {
return 'WAT?!';
}
}], [{
key: 'getName',
value: function getName() {
return 'Animal';
}
});
}]);

return Animal;
})();

exports.Animal = Animal;
Object.defineProperty(exports, "__esModule", {
value: true
});

54 changes: 18 additions & 36 deletions test/fixtures/es6-classes/expectedCover.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ module.exports = {

fnMap: []
.concat(generateNSkipedFunction(
{name: '(anonymous_1)', line: 9},
{name: 'defineProperties', line: 9},
{name: '(anonymous_3)', line: 9},
{name: '_classCallCheck', line: 11}
{name: '(anonymous_1)', line: 3},
{name: 'defineProperties', line: 3},
{name: '(anonymous_3)', line: 3},
{name: '_classCallCheck', line: 9}
))
.concat([
// 5th fn
Expand All @@ -85,44 +85,26 @@ module.exports = {
.concat(generateNSkipedFunction(
{name: 'Animal', line: 14}
))
.concat([
// 7th fn
{
name: 'sayHi', line: 20,
loc: {
start: {line: 4, column: 7},
end: {line: 4, column: 10}
}
},
// 8th fn
{
name: 'sayOther', line: 25,
loc: {
start: {line: 8, column: 10},
end: {line: 8, column: 13}
}
},
// 9th fn
{
name: 'getName', line: 30,
loc: {
start: {line: 12, column: 16},
end: {line: 12, column: 19}
}
}
])
,
.concat(generateNSkipedFunction(
{name: 'sayHi', line: 20}
))
.concat(generateNSkipedFunction(
{name: 'sayOther', line: 25}
))
.concat(generateNSkipedFunction(
{name: 'getName', line: 30}
)),

branchMap: generateNSkipedBranch(
// 1th branch
{line: 9, type: 'binary-expr'},
{line: 3, type: 'binary-expr'},
// 2th branch
{line: 9, type: 'if'},
{line: 3, type: 'if'},
// 3th branch
{line: 9, type: 'if'},
{line: 3, type: 'if'},
// 4th branch
{line: 9, type: 'if'},
{line: 3, type: 'if'},
// 5th branch
{line: 11, type: 'if'}
{line: 9, type: 'if'}
)
};
18 changes: 12 additions & 6 deletions test/fixtures/virgin/expectedCover.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@ module.exports = {
// 4. return baz(bar ? 0 : 1);
// 5. };
start: {line: 3, column: 0},
end: {line: 5, column: 2}
end: {line: 5, column: 1}
},
{
// 4. return baz(bar ? 0 : 1);
start: {line: 4, column: 2},
end: {line: 4, column: 26}
},
{
// 5. };
// 6.
// 7. /* istanbul ignore next */
// 8. if (true) {
// 9. var a = 5;
// 10. }
start: {line: 8, column: 0},
start: {line: 5, column: 2},
end: {line: 10, column: 1},
skip: true
},
Expand Down Expand Up @@ -69,17 +72,20 @@ module.exports = {
]
},
{
// 5. };
// 6.
// 7. /* istanbul ignore next */
// 8. if (true) {
line: 8, type: 'if',
locations: [
{
start: {line: 8, column: 0},
end: {line: 8, column: 0},
start: {line: 5, column: 2},
end: {line: 5, column: 2},
skip: true
},
{
start: {line: 8, column: 0},
end: {line: 8, column: 0},
start: {line: 5, column: 2},
end: {line: 5, column: 2},
skip: true
}
]
Expand Down
3 changes: 2 additions & 1 deletion test/mocha.opts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--compilers babel:babel/register
--compilers babel:babel-core/register
--require babel-polyfill

0 comments on commit 1e3c696

Please sign in to comment.