Skip to content

Commit

Permalink
Organize tests and more
Browse files Browse the repository at this point in the history
  • Loading branch information
keik committed Jun 19, 2017
1 parent fec3215 commit 655c805
Show file tree
Hide file tree
Showing 16 changed files with 323 additions and 790 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/fixtures
2 changes: 1 addition & 1 deletion .eslintrc → .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
module.exports = {
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 6
Expand Down
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
var sourceMap = require('source-map'),
SourceMapConsumer = sourceMap.SourceMapConsumer,
SourceMapGenerator = sourceMap.SourceMapGenerator
var sourceMap = require('source-map')
var SourceMapConsumer = sourceMap.SourceMapConsumer
var SourceMapGenerator = sourceMap.SourceMapGenerator

module.exports = merge

/**
* Merge old source map and new source map and return merged.
* If old or new source map value is falsy, return another one as it is.
*
* @param {object|undefined} oldMap old source map object
* @param {object|undefined} newmap new source map object
* @param {object|string} [oldMap] old source map object
* @param {object|string} [newmap] new source map object
* @return {object|undefined} merged source map object, or undefined when both old and new source map are undefined
*/
function merge(oldMap, newMap) {
Expand All @@ -19,9 +19,9 @@ function merge(oldMap, newMap) {
if (!newMap)
return oldMap

var oldMapConsumer = new SourceMapConsumer(oldMap),
newMapConsumer = new SourceMapConsumer(newMap),
mergedMapGenerator = new SourceMapGenerator()
var oldMapConsumer = new SourceMapConsumer(oldMap)
var newMapConsumer = new SourceMapConsumer(newMap)
var mergedMapGenerator = new SourceMapGenerator()

// iterate on new map and overwrite original position of new map with one of old map
newMapConsumer.eachMapping(function(m) {
Expand Down
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@
"source-map"
],
"dependencies": {
"source-map": "^0.5.3"
"source-map": "^0.5.6"
},
"devDependencies": {
"babel-core": "^6.14.0",
"babel-preset-es2015": "^6.14.0",
"coffee-script": "^1.10.0",
"convert-source-map": "^1.3.0",
"babel-core": "^6.25.0",
"babel-plugin-syntax-object-rest-spread": "^6.13.0",
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
"babel-plugin-transform-es2015-spread": "^6.22.0",
"coffee-script": "^1.12.6",
"convert-source-map": "^1.5.0",
"escodegen": "^1.8.1",
"eslint": "^3.5.0",
"esprima": "^3.0.0",
"estraverse": "^4.1.1",
"nyc": "^8.3.0",
"tape": "^4.5.1"
"eslint": "^3.19.0",
"esprima": "^3.1.3",
"estraverse": "^4.2.0",
"nyc": "^8.4.0",
"tape": "^4.6.3"
},
"files": []
}
34 changes: 34 additions & 0 deletions test/fixtures/coffee-script/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(function () {
var a, b;
a = 1;
a = 1;
b = function (arg1, arg2) {
console.log(arg1);
console.log(arg1);
console.log(arg2);
console.log(arg2);
};
b = function (arg1, arg2) {
console.log(arg1);
console.log(arg1);
console.log(arg2);
console.log(arg2);
};
}.call(this));
(function () {
var a, b;
a = 1;
a = 1;
b = function (arg1, arg2) {
console.log(arg1);
console.log(arg1);
console.log(arg2);
console.log(arg2);
};
b = function (arg1, arg2) {
console.log(arg1);
console.log(arg1);
console.log(arg2);
console.log(arg2);
};
}.call(this));
6 changes: 6 additions & 0 deletions test/fixtures/coffee-script/expected.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
a = 1
b = (arg1, arg2) ->
console.log arg1
# comment
console.log arg2
return
14 changes: 14 additions & 0 deletions test/fixtures/coffee-script/expected.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions test/fixtures/coffee-script/expected.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions test/fixtures/es2015/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }

var concatFooBar = function (args) {
const f = 'foo';
const b = 'bar';
return [f, b].concat(_toConsumableArray(args));
};
5 changes: 5 additions & 0 deletions test/fixtures/es2015/expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var concatFooBar = (args) => {
const f = 'foo'
const b = 'bar'
return [f, b, ...args]
}
Loading

0 comments on commit 655c805

Please sign in to comment.