From 71016432565568e2b7325b11cf07ae90d029c45b Mon Sep 17 00:00:00 2001 From: Takuto Wada Date: Mon, 25 May 2015 17:10:48 +0900 Subject: [PATCH] feat(espower): use `process.cwd()` for espower `sourceRoot` option value --- README.md | 10 ++++++++ lib/create-espower-visitor.js | 13 +++++----- test/fixtures/ArrayExpression/expected.js | 8 +++---- .../ArrowFunctionExpression/expected.js | 2 +- .../fixtures/AssignmentExpression/expected.js | 14 +++++------ test/fixtures/BinaryExpression/expected.js | 16 ++++++------- test/fixtures/CallExpression/expected.js | 24 +++++++++---------- .../ConditionalExpression/expected.js | 10 ++++---- test/fixtures/FunctionExpression/expected.js | 2 +- test/fixtures/Identifier/expected.js | 24 +++++++++---------- test/fixtures/Literal/expected.js | 8 +++---- test/fixtures/LogicalExpression/expected.js | 12 +++++----- test/fixtures/MemberExpression/expected.js | 24 +++++++++---------- test/fixtures/NewExpression/expected.js | 10 ++++---- test/fixtures/ObjectExpression/expected.js | 8 +++---- test/fixtures/Property/expected.js | 10 ++++---- test/fixtures/SpreadElement/expected.js | 6 ++--- .../TaggedTemplateExpression/expected.js | 6 ++--- test/fixtures/TemplateLiteral/expected.js | 6 ++--- test/fixtures/UnaryExpression/expected.js | 16 ++++++------- test/fixtures/UpdateExpression/expected.js | 8 +++---- test/fixtures/customPatterns/expected.js | 24 +++++++++---------- test/fixtures/inputSourceMap/expected.js | 2 +- test/test.js | 11 ++++++--- 24 files changed, 145 insertions(+), 129 deletions(-) diff --git a/README.md b/README.md index b45c185..12ea3cb 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,8 @@ $ ./node_modules/.bin/mocha /path/to/build/demo_test.js CUSTOMIZE --------------------------------------- +### var plugin = createEspowerPlugin(babel, [options]) + You can customize assertion patterns via [Babel API](http://babeljs.io/docs/usage/api/), ```javascript @@ -237,6 +239,14 @@ require('babel-core/register')({ }); ``` +#### options + +| type | default value | +|:---------|:--------------| +| `object` | (return value of `espower.defaultOptions()` with default `path`, `sourceRoot` and `sourceMap`) | + +Configuration options for internal `espower` module. If not passed, default options will be used (return value of `espower.defaultOptions()` with default `path`, `sourceRoot` and `sourceMap`. `path` is filename passed to babel. `sourceRoot` is be return value of `process.cwd()`, `sourceMap` is babel's internal SourceMap object). + CHANGELOG --------------------------------------- diff --git a/lib/create-espower-visitor.js b/lib/create-espower-visitor.js index 8990cb3..755afeb 100644 --- a/lib/create-espower-visitor.js +++ b/lib/create-espower-visitor.js @@ -5,7 +5,7 @@ var escallmatch = require('escallmatch'); var extend = require('xtend'); var find = require('array-find'); -function enterTraversalPath (traversalPath, currentNode, parentNode, scope, file, matchers, esTreePath) { +function enterTraversalPath (traversalPath, currentNode, parentNode, scope, file, matchers, esTreePath, options) { var treePath; var currentKey = traversalPath.key; var assertionVisitor = file.get('espowerAssertionVisitor'); @@ -25,10 +25,11 @@ function enterTraversalPath (traversalPath, currentNode, parentNode, scope, file var matcher = find(matchers, function (m) { return m.test(currentNode); }); if (matcher) { // entering assertion - var espowerOptions = { + var espowerOptions = extend(espower.defaultOptions(), { path: file.opts.filename, // or opts.sourceFileName? + sourceRoot: process.cwd(), sourceMap: file.opts.inputSourceMap - }; + }, options); treePath = esTreePath(traversalPath); assertionVisitor = new espower.AssertionVisitor(matcher, treePath, espowerOptions); assertionVisitor.enter(currentNode, parentNode); @@ -37,7 +38,7 @@ function enterTraversalPath (traversalPath, currentNode, parentNode, scope, file } } -function exitTraversalPath (traversalPath, currentNode, parentNode, scope, file, esTreePath) { +function exitTraversalPath (traversalPath, currentNode, parentNode, scope, file, esTreePath, options) { var currentKey = traversalPath.key; var resultTree = currentNode; var isTreeModified = false; @@ -82,10 +83,10 @@ module.exports = function createEspowerVisitor (babel, options) { return Object.keys(babel.types.VISITOR_KEYS).reduce(function (handlers, nodeType) { handlers[nodeType] = { enter: function (currentNode, parentNode, scope, file) { - enterTraversalPath(this, currentNode, parentNode, scope, file, matchers, esTreePath); + enterTraversalPath(this, currentNode, parentNode, scope, file, matchers, esTreePath, options); }, exit: function (currentNode, parentNode, scope, file) { - exitTraversalPath(this, currentNode, parentNode, scope, file, esTreePath); + exitTraversalPath(this, currentNode, parentNode, scope, file, esTreePath, options); } }; return handlers; diff --git a/test/fixtures/ArrayExpression/expected.js b/test/fixtures/ArrayExpression/expected.js index e79c5cd..f0a2a05 100644 --- a/test/fixtures/ArrayExpression/expected.js +++ b/test/fixtures/ArrayExpression/expected.js @@ -2,22 +2,22 @@ assert(assert._expr(assert._capt([assert._capt(foo, 'arguments/0/elements/0'), assert._capt(bar, 'arguments/0/elements/1')], 'arguments/0'), { content: 'assert([foo,bar])', - filepath: 'fixtures/ArrayExpression/fixture.js', + filepath: 'test/fixtures/ArrayExpression/fixture.js', line: 3 })); assert(assert._expr(assert._capt(assert._capt(typeof assert._capt([assert._capt([assert._capt(assert._capt(foo, 'arguments/0/left/argument/elements/0/elements/0/object').bar, 'arguments/0/left/argument/elements/0/elements/0'), assert._capt(baz(assert._capt(moo, 'arguments/0/left/argument/elements/0/elements/1/arguments/0')), 'arguments/0/left/argument/elements/0/elements/1')], 'arguments/0/left/argument/elements/0'), assert._capt(+assert._capt(fourStr, 'arguments/0/left/argument/elements/1/argument'), 'arguments/0/left/argument/elements/1')], 'arguments/0/left/argument'), 'arguments/0/left') === 'number', 'arguments/0'), { content: 'assert(typeof [[foo.bar,baz(moo)],+fourStr] === \'number\')', - filepath: 'fixtures/ArrayExpression/fixture.js', + filepath: 'test/fixtures/ArrayExpression/fixture.js', line: 5 })); assert.notDeepEqual(assert._expr(assert._capt([assert._capt(foo, 'arguments/0/elements/0'), assert._capt(bar, 'arguments/0/elements/1')], 'arguments/0'), { content: 'assert.notDeepEqual([foo,bar], [hoge,fuga,piyo])', - filepath: 'fixtures/ArrayExpression/fixture.js', + filepath: 'test/fixtures/ArrayExpression/fixture.js', line: 7 }), assert._expr(assert._capt([assert._capt(hoge, 'arguments/1/elements/0'), assert._capt(fuga, 'arguments/1/elements/1'), assert._capt(piyo, 'arguments/1/elements/2')], 'arguments/1'), { content: 'assert.notDeepEqual([foo,bar], [hoge,fuga,piyo])', - filepath: 'fixtures/ArrayExpression/fixture.js', + filepath: 'test/fixtures/ArrayExpression/fixture.js', line: 7 })); diff --git a/test/fixtures/ArrowFunctionExpression/expected.js b/test/fixtures/ArrowFunctionExpression/expected.js index 36f2194..56cfa31 100644 --- a/test/fixtures/ArrowFunctionExpression/expected.js +++ b/test/fixtures/ArrowFunctionExpression/expected.js @@ -16,6 +16,6 @@ assert(assert._expr(assert._capt(assert._capt(seven, 'arguments/0/left') === ass return v + i; })(assert._capt(four, 'arguments/0/right/arguments/0'), assert._capt(five, 'arguments/0/right/arguments/1')), 'arguments/0/right'), 'arguments/0'), { content: 'assert(seven === ((v, i) => v + i)(four, five))', - filepath: 'fixtures/ArrowFunctionExpression/fixture.js', + filepath: 'test/fixtures/ArrowFunctionExpression/fixture.js', line: 9 })); diff --git a/test/fixtures/AssignmentExpression/expected.js b/test/fixtures/AssignmentExpression/expected.js index a4623e2..71f1d2e 100644 --- a/test/fixtures/AssignmentExpression/expected.js +++ b/test/fixtures/AssignmentExpression/expected.js @@ -6,40 +6,40 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i assert(assert._expr(assert._capt(counter += 1, 'arguments/0'), { content: 'assert(counter += 1)', - filepath: 'fixtures/AssignmentExpression/fixture.js', + filepath: 'test/fixtures/AssignmentExpression/fixture.js', line: 3 })); assert(assert._expr(assert._capt(dog.age += 1, 'arguments/0'), { content: 'assert(dog.age += 1)', - filepath: 'fixtures/AssignmentExpression/fixture.js', + filepath: 'test/fixtures/AssignmentExpression/fixture.js', line: 5 })); assert(assert._expr(assert._capt(dog.age += 1, 'arguments/0'), { content: 'assert(dog.age += 1)', - filepath: 'fixtures/AssignmentExpression/fixture.js', + filepath: 'test/fixtures/AssignmentExpression/fixture.js', line: 7 })); assert.strictEqual(assert._expr(assert._capt(dog.age += 1, 'arguments/0'), { content: 'assert.strictEqual(dog.age += 1, three)', - filepath: 'fixtures/AssignmentExpression/fixture.js', + filepath: 'test/fixtures/AssignmentExpression/fixture.js', line: 9 }), assert._expr(assert._capt(three, 'arguments/1'), { content: 'assert.strictEqual(dog.age += 1, three)', - filepath: 'fixtures/AssignmentExpression/fixture.js', + filepath: 'test/fixtures/AssignmentExpression/fixture.js', line: 9 })); assert(assert._expr(assert._capt((_temp = assert._capt([3], 'arguments/0/right'), _temp2 = _slicedToArray(_temp, 1), x = _temp2[0], _temp), 'arguments/0'), { content: 'assert([x] = [3])', - filepath: 'fixtures/AssignmentExpression/fixture.js', + filepath: 'test/fixtures/AssignmentExpression/fixture.js', line: 11 })); assert(assert._expr(assert._capt((_temp3 = assert._capt([assert._capt(foo, 'arguments/0/right/elements/0')], 'arguments/0/right'), _temp32 = _slicedToArray(_temp3, 1), x = _temp32[0], _temp3), 'arguments/0'), { content: 'assert([x] = [foo])', - filepath: 'fixtures/AssignmentExpression/fixture.js', + filepath: 'test/fixtures/AssignmentExpression/fixture.js', line: 13 })); diff --git a/test/fixtures/BinaryExpression/expected.js b/test/fixtures/BinaryExpression/expected.js index aff8960..3681a4a 100644 --- a/test/fixtures/BinaryExpression/expected.js +++ b/test/fixtures/BinaryExpression/expected.js @@ -2,48 +2,48 @@ assert(assert._expr(assert._capt(4 !== 4, 'arguments/0'), { content: 'assert(4 !== 4)', - filepath: 'fixtures/BinaryExpression/fixture.js', + filepath: 'test/fixtures/BinaryExpression/fixture.js', line: 3 })); assert(assert._expr(assert._capt(assert._capt(fuga, 'arguments/0/left') !== 4, 'arguments/0'), { content: 'assert(fuga !== 4)', - filepath: 'fixtures/BinaryExpression/fixture.js', + filepath: 'test/fixtures/BinaryExpression/fixture.js', line: 5 })); assert(assert._expr(assert._capt(assert._capt(fuga, 'arguments/0/left') === assert._capt(piyo, 'arguments/0/right'), 'arguments/0'), { content: 'assert(fuga === piyo)', - filepath: 'fixtures/BinaryExpression/fixture.js', + filepath: 'test/fixtures/BinaryExpression/fixture.js', line: 7 })); assert(assert._expr(assert._capt(assert._capt(fuga, 'arguments/0/left') === assert._capt(piyo, 'arguments/0/right'), 'arguments/0'), { content: 'assert(fuga === piyo)', - filepath: 'fixtures/BinaryExpression/fixture.js', + filepath: 'test/fixtures/BinaryExpression/fixture.js', line: 9 })); assert(assert._expr(assert._capt(assert._capt(fuga, 'arguments/0/left') === assert._capt(piyo, 'arguments/0/right'), 'arguments/0'), { content: 'assert(fuga === piyo)', - filepath: 'fixtures/BinaryExpression/fixture.js', + filepath: 'test/fixtures/BinaryExpression/fixture.js', line: 13 })); assert(assert._expr(assert._capt(assert._capt(fuga, 'arguments/0/left') !== assert._capt(piyo, 'arguments/0/right'), 'arguments/0'), { content: 'assert(fuga !== piyo)', - filepath: 'fixtures/BinaryExpression/fixture.js', + filepath: 'test/fixtures/BinaryExpression/fixture.js', line: 15 })); assert.ok(assert._expr(assert._capt(assert._capt(hoge, 'arguments/0/left') === assert._capt(fuga, 'arguments/0/right'), 'arguments/0'), { content: 'assert.ok(hoge === fuga, \'comment\')', - filepath: 'fixtures/BinaryExpression/fixture.js', + filepath: 'test/fixtures/BinaryExpression/fixture.js', line: 17 }), 'comment'); assert(assert._expr(assert._capt(assert._capt(assert._capt(ary1, 'arguments/0/left/object').length, 'arguments/0/left') === assert._capt(assert._capt(ary2, 'arguments/0/right/object').length, 'arguments/0/right'), 'arguments/0'), { content: 'assert(ary1.length === ary2.length)', - filepath: 'fixtures/BinaryExpression/fixture.js', + filepath: 'test/fixtures/BinaryExpression/fixture.js', line: 19 })); diff --git a/test/fixtures/CallExpression/expected.js b/test/fixtures/CallExpression/expected.js index fa0f226..c689e06 100644 --- a/test/fixtures/CallExpression/expected.js +++ b/test/fixtures/CallExpression/expected.js @@ -2,70 +2,70 @@ assert(assert._expr(assert._capt(func(), 'arguments/0'), { content: 'assert(func())', - filepath: 'fixtures/CallExpression/fixture.js', + filepath: 'test/fixtures/CallExpression/fixture.js', line: 3 })); assert(assert._expr(assert._capt(assert._capt(obj, 'arguments/0/callee/object').age(), 'arguments/0'), { content: 'assert(obj.age())', - filepath: 'fixtures/CallExpression/fixture.js', + filepath: 'test/fixtures/CallExpression/fixture.js', line: 5 })); assert(assert._expr(assert._capt(isFalsy(assert._capt(positiveInt, 'arguments/0/arguments/0')), 'arguments/0'), { content: 'assert(isFalsy(positiveInt))', - filepath: 'fixtures/CallExpression/fixture.js', + filepath: 'test/fixtures/CallExpression/fixture.js', line: 7 })); assert(assert._expr(assert._capt(assert._capt(foo, 'arguments/0/callee/object')[assert._capt(propName, 'arguments/0/callee/property')](), 'arguments/0'), { content: 'assert(foo[propName]())', - filepath: 'fixtures/CallExpression/fixture.js', + filepath: 'test/fixtures/CallExpression/fixture.js', line: 9 })); assert(assert._expr(assert._capt(assert._capt(foo, 'arguments/0/callee/object')[assert._capt(assert._capt(hoge, 'arguments/0/callee/property/object')[assert._capt(assert._capt(fuga, 'arguments/0/callee/property/property/object')[assert._capt(piyo, 'arguments/0/callee/property/property/property')], 'arguments/0/callee/property/property')], 'arguments/0/callee/property')](), 'arguments/0'), { content: 'assert(foo[hoge[fuga[piyo]]]())', - filepath: 'fixtures/CallExpression/fixture.js', + filepath: 'test/fixtures/CallExpression/fixture.js', line: 11 })); assert(assert._expr(assert._capt(assert._capt(sum(assert._capt(one, 'arguments/0/left/arguments/0'), assert._capt(two, 'arguments/0/left/arguments/1'), assert._capt(three, 'arguments/0/left/arguments/2')), 'arguments/0/left') === assert._capt(seven, 'arguments/0/right'), 'arguments/0'), { content: 'assert(sum(one, two, three) === seven)', - filepath: 'fixtures/CallExpression/fixture.js', + filepath: 'test/fixtures/CallExpression/fixture.js', line: 13 })); assert(assert._expr(assert._capt(assert._capt(sum(assert._capt(sum(assert._capt(one, 'arguments/0/left/arguments/0/arguments/0'), assert._capt(two, 'arguments/0/left/arguments/0/arguments/1')), 'arguments/0/left/arguments/0'), assert._capt(three, 'arguments/0/left/arguments/1')), 'arguments/0/left') === assert._capt(sum(assert._capt(sum(assert._capt(two, 'arguments/0/right/arguments/0/arguments/0'), assert._capt(three, 'arguments/0/right/arguments/0/arguments/1')), 'arguments/0/right/arguments/0'), assert._capt(seven, 'arguments/0/right/arguments/1')), 'arguments/0/right'), 'arguments/0'), { content: 'assert(sum(sum(one, two), three) === sum(sum(two, three), seven))', - filepath: 'fixtures/CallExpression/fixture.js', + filepath: 'test/fixtures/CallExpression/fixture.js', line: 15 })); assert(assert._expr(assert._capt(assert._capt(assert._capt(assert._capt(math, 'arguments/0/left/callee/object/object').calc, 'arguments/0/left/callee/object').sum(assert._capt(one, 'arguments/0/left/arguments/0'), assert._capt(two, 'arguments/0/left/arguments/1'), assert._capt(three, 'arguments/0/left/arguments/2')), 'arguments/0/left') === assert._capt(seven, 'arguments/0/right'), 'arguments/0'), { content: 'assert(math.calc.sum(one, two, three) === seven)', - filepath: 'fixtures/CallExpression/fixture.js', + filepath: 'test/fixtures/CallExpression/fixture.js', line: 17 })); assert(assert._expr(assert._capt(assert._capt(assert._capt(three, 'arguments/0/left/left') * assert._capt(assert._capt(seven, 'arguments/0/left/right/left') * assert._capt(ten, 'arguments/0/left/right/right'), 'arguments/0/left/right'), 'arguments/0/left') === assert._capt(three, 'arguments/0/right'), 'arguments/0'), { content: 'assert(three * (seven * ten) === three)', - filepath: 'fixtures/CallExpression/fixture.js', + filepath: 'test/fixtures/CallExpression/fixture.js', line: 19 })); assert(assert._expr(assert._capt(!assert._capt(concat(assert._capt(fuga, 'arguments/0/argument/arguments/0'), assert._capt(piyo, 'arguments/0/argument/arguments/1')), 'arguments/0/argument'), 'arguments/0'), { content: 'assert(!concat(fuga, piyo))', - filepath: 'fixtures/CallExpression/fixture.js', + filepath: 'test/fixtures/CallExpression/fixture.js', line: 21 })); assert.strictEqual(assert._expr(assert._capt(assert._capt(three, 'arguments/0/left') * assert._capt(assert._capt(seven, 'arguments/0/right/left') * assert._capt(ten, 'arguments/0/right/right'), 'arguments/0/right'), 'arguments/0'), { content: 'assert.strictEqual(three * (seven * ten), math.calc.sum(one, two, three))', - filepath: 'fixtures/CallExpression/fixture.js', + filepath: 'test/fixtures/CallExpression/fixture.js', line: 23 }), assert._expr(assert._capt(assert._capt(assert._capt(math, 'arguments/1/callee/object/object').calc, 'arguments/1/callee/object').sum(assert._capt(one, 'arguments/1/arguments/0'), assert._capt(two, 'arguments/1/arguments/1'), assert._capt(three, 'arguments/1/arguments/2')), 'arguments/1'), { content: 'assert.strictEqual(three * (seven * ten), math.calc.sum(one, two, three))', - filepath: 'fixtures/CallExpression/fixture.js', + filepath: 'test/fixtures/CallExpression/fixture.js', line: 23 })); diff --git a/test/fixtures/ConditionalExpression/expected.js b/test/fixtures/ConditionalExpression/expected.js index cdec395..e6cd7e7 100644 --- a/test/fixtures/ConditionalExpression/expected.js +++ b/test/fixtures/ConditionalExpression/expected.js @@ -2,28 +2,28 @@ assert(assert._expr(assert._capt(foo, 'arguments/0/test') ? assert._capt(bar, 'arguments/0/consequent') : assert._capt(baz, 'arguments/0/alternate'), { content: 'assert(foo ? bar : baz)', - filepath: 'fixtures/ConditionalExpression/fixture.js', + filepath: 'test/fixtures/ConditionalExpression/fixture.js', line: 3 })); assert(assert._expr(assert._capt(falsy, 'arguments/0/test') ? assert._capt(truthy, 'arguments/0/consequent') : assert._capt(truthy, 'arguments/0/alternate/test') ? assert._capt(anotherFalsy, 'arguments/0/alternate/consequent') : assert._capt(truthy, 'arguments/0/alternate/alternate'), { content: 'assert(falsy ? truthy : truthy ? anotherFalsy : truthy)', - filepath: 'fixtures/ConditionalExpression/fixture.js', + filepath: 'test/fixtures/ConditionalExpression/fixture.js', line: 5 })); assert(assert._expr(assert._capt(foo(), 'arguments/0/test') ? assert._capt(assert._capt(bar, 'arguments/0/consequent/object').baz, 'arguments/0/consequent') : assert._capt(typeof goo, 'arguments/0/alternate'), { content: 'assert(foo() ? bar.baz : typeof goo)', - filepath: 'fixtures/ConditionalExpression/fixture.js', + filepath: 'test/fixtures/ConditionalExpression/fixture.js', line: 7 })); assert.equal(assert._expr(assert._capt(foo, 'arguments/0/test') ? assert._capt(bar, 'arguments/0/consequent') : assert._capt(baz, 'arguments/0/alternate'), { content: 'assert.equal(foo ? bar : baz, falsy ? truthy : truthy ? anotherFalsy : truthy)', - filepath: 'fixtures/ConditionalExpression/fixture.js', + filepath: 'test/fixtures/ConditionalExpression/fixture.js', line: 9 }), assert._expr(assert._capt(falsy, 'arguments/1/test') ? assert._capt(truthy, 'arguments/1/consequent') : assert._capt(truthy, 'arguments/1/alternate/test') ? assert._capt(anotherFalsy, 'arguments/1/alternate/consequent') : assert._capt(truthy, 'arguments/1/alternate/alternate'), { content: 'assert.equal(foo ? bar : baz, falsy ? truthy : truthy ? anotherFalsy : truthy)', - filepath: 'fixtures/ConditionalExpression/fixture.js', + filepath: 'test/fixtures/ConditionalExpression/fixture.js', line: 9 })); diff --git a/test/fixtures/FunctionExpression/expected.js b/test/fixtures/FunctionExpression/expected.js index fc86b57..9facf34 100644 --- a/test/fixtures/FunctionExpression/expected.js +++ b/test/fixtures/FunctionExpression/expected.js @@ -8,6 +8,6 @@ assert(assert._expr(assert._capt(assert._capt(baz, 'arguments/0/left') === asser return a + b; })(assert._capt(foo, 'arguments/0/right/arguments/0'), assert._capt(bar, 'arguments/0/right/arguments/1')), 'arguments/0/right'), 'arguments/0'), { content: 'assert(baz === function (a, b) {return a + b;}(foo, bar))', - filepath: 'fixtures/FunctionExpression/fixture.js', + filepath: 'test/fixtures/FunctionExpression/fixture.js', line: 5 })); diff --git a/test/fixtures/Identifier/expected.js b/test/fixtures/Identifier/expected.js index e399644..e234854 100644 --- a/test/fixtures/Identifier/expected.js +++ b/test/fixtures/Identifier/expected.js @@ -2,62 +2,62 @@ assert(assert._expr(assert._capt(falsyStr, 'arguments/0'), { content: 'assert(falsyStr)', - filepath: 'fixtures/Identifier/fixture.js', + filepath: 'test/fixtures/Identifier/fixture.js', line: 3 })); assert(assert._expr(assert._capt(falsyStr, 'arguments/0'), { content: 'assert(falsyStr, messageStr)', - filepath: 'fixtures/Identifier/fixture.js', + filepath: 'test/fixtures/Identifier/fixture.js', line: 5 }), messageStr); assert.equal(assert._expr(assert._capt(str, 'arguments/0'), { content: 'assert.equal(str, anotherStr)', - filepath: 'fixtures/Identifier/fixture.js', + filepath: 'test/fixtures/Identifier/fixture.js', line: 7 }), assert._expr(assert._capt(anotherStr, 'arguments/1'), { content: 'assert.equal(str, anotherStr)', - filepath: 'fixtures/Identifier/fixture.js', + filepath: 'test/fixtures/Identifier/fixture.js', line: 7 })); assert.equal(assert._expr(assert._capt(str, 'arguments/0'), { content: 'assert.equal(str, anotherStr)', - filepath: 'fixtures/Identifier/fixture.js', + filepath: 'test/fixtures/Identifier/fixture.js', line: 9 }), assert._expr(assert._capt(anotherStr, 'arguments/1'), { content: 'assert.equal(str, anotherStr)', - filepath: 'fixtures/Identifier/fixture.js', + filepath: 'test/fixtures/Identifier/fixture.js', line: 9 })); assert.equal(assert._expr(assert._capt(str, 'arguments/0'), { content: 'assert.equal(str, anotherStr, messageStr)', - filepath: 'fixtures/Identifier/fixture.js', + filepath: 'test/fixtures/Identifier/fixture.js', line: 14 }), assert._expr(assert._capt(anotherStr, 'arguments/1'), { content: 'assert.equal(str, anotherStr, messageStr)', - filepath: 'fixtures/Identifier/fixture.js', + filepath: 'test/fixtures/Identifier/fixture.js', line: 14 }), messageStr); assert.equal(assert._expr(assert._capt(str, 'arguments/0'), { content: 'assert.equal(str, anotherStr)', - filepath: 'fixtures/Identifier/fixture.js', + filepath: 'test/fixtures/Identifier/fixture.js', line: 16 }), assert._expr(assert._capt(anotherStr, 'arguments/1'), { content: 'assert.equal(str, anotherStr)', - filepath: 'fixtures/Identifier/fixture.js', + filepath: 'test/fixtures/Identifier/fixture.js', line: 16 })); assert.equal(assert._expr(assert._capt(str, 'arguments/0'), { content: 'assert.equal(str, yetAnotherStr)', - filepath: 'fixtures/Identifier/fixture.js', + filepath: 'test/fixtures/Identifier/fixture.js', line: 21 }), assert._expr(assert._capt(yetAnotherStr, 'arguments/1'), { content: 'assert.equal(str, yetAnotherStr)', - filepath: 'fixtures/Identifier/fixture.js', + filepath: 'test/fixtures/Identifier/fixture.js', line: 21 })); diff --git a/test/fixtures/Literal/expected.js b/test/fixtures/Literal/expected.js index d838bb0..d587e3c 100644 --- a/test/fixtures/Literal/expected.js +++ b/test/fixtures/Literal/expected.js @@ -12,25 +12,25 @@ assert(false, messageStr); assert.equal(assert._expr(assert._capt(foo, 'arguments/0'), { content: 'assert.equal(foo, \'bar\', \'msg\')', - filepath: 'fixtures/Literal/fixture.js', + filepath: 'test/fixtures/Literal/fixture.js', line: 13 }), 'bar', 'msg'); assert(assert._expr(assert._capt(/^not/.exec(assert._capt(str, 'arguments/0/arguments/0')), 'arguments/0'), { content: 'assert(/^not/.exec(str))', - filepath: 'fixtures/Literal/fixture.js', + filepath: 'test/fixtures/Literal/fixture.js', line: 15 })); assert(assert._expr(assert._capt(assert._capt(fuga, 'arguments/0/left') !== 'ふが', 'arguments/0'), { content: 'assert(fuga !== \'ふが\')', - filepath: 'fixtures/Literal/fixture.js', + filepath: 'test/fixtures/Literal/fixture.js', line: 17 })); assert(assert._expr(assert._capt('ほげ' !== 'ふが', 'arguments/0'), { content: 'assert(\'ほげ\' !== \'ふが\')', - filepath: 'fixtures/Literal/fixture.js', + filepath: 'test/fixtures/Literal/fixture.js', line: 19 })); diff --git a/test/fixtures/LogicalExpression/expected.js b/test/fixtures/LogicalExpression/expected.js index d382804..6b4546b 100644 --- a/test/fixtures/LogicalExpression/expected.js +++ b/test/fixtures/LogicalExpression/expected.js @@ -2,34 +2,34 @@ assert(assert._expr(assert._capt(assert._capt(5 < assert._capt(actual, 'arguments/0/left/right'), 'arguments/0/left') && assert._capt(assert._capt(actual, 'arguments/0/right/left') < 13, 'arguments/0/right'), 'arguments/0'), { content: 'assert(5 < actual && actual < 13)', - filepath: 'fixtures/LogicalExpression/fixture.js', + filepath: 'test/fixtures/LogicalExpression/fixture.js', line: 3 })); assert.ok(assert._expr(assert._capt(assert._capt(assert._capt(actual, 'arguments/0/left/left') < 5, 'arguments/0/left') || assert._capt(13 < assert._capt(actual, 'arguments/0/right/right'), 'arguments/0/right'), 'arguments/0'), { content: 'assert.ok(actual < 5 || 13 < actual)', - filepath: 'fixtures/LogicalExpression/fixture.js', + filepath: 'test/fixtures/LogicalExpression/fixture.js', line: 5 })); assert(assert._expr(assert._capt(assert._capt(2 > assert._capt(actual, 'arguments/0/left/right'), 'arguments/0/left') && assert._capt(assert._capt(actual, 'arguments/0/right/left') < 13, 'arguments/0/right'), 'arguments/0'), { content: 'assert(2 > actual && actual < 13)', - filepath: 'fixtures/LogicalExpression/fixture.js', + filepath: 'test/fixtures/LogicalExpression/fixture.js', line: 7 })); assert(assert._expr(assert._capt(assert._capt(2 > assert._capt(actual, 'arguments/0/left/right'), 'arguments/0/left') && assert._capt(assert._capt(actual, 'arguments/0/right/left') < 13, 'arguments/0/right'), 'arguments/0'), { content: 'assert(2 > actual && actual < 13)', - filepath: 'fixtures/LogicalExpression/fixture.js', + filepath: 'test/fixtures/LogicalExpression/fixture.js', line: 9 })); assert.equal(assert._expr(assert._capt(assert._capt(5 < assert._capt(actual, 'arguments/0/left/right'), 'arguments/0/left') && assert._capt(assert._capt(actual, 'arguments/0/right/left') < 13, 'arguments/0/right'), 'arguments/0'), { content: 'assert.equal(5 < actual && actual < 13, falsy)', - filepath: 'fixtures/LogicalExpression/fixture.js', + filepath: 'test/fixtures/LogicalExpression/fixture.js', line: 11 }), assert._expr(assert._capt(falsy, 'arguments/1'), { content: 'assert.equal(5 < actual && actual < 13, falsy)', - filepath: 'fixtures/LogicalExpression/fixture.js', + filepath: 'test/fixtures/LogicalExpression/fixture.js', line: 11 })); diff --git a/test/fixtures/MemberExpression/expected.js b/test/fixtures/MemberExpression/expected.js index c09b98c..82a7498 100644 --- a/test/fixtures/MemberExpression/expected.js +++ b/test/fixtures/MemberExpression/expected.js @@ -2,68 +2,68 @@ assert(assert._expr(assert._capt(assert._capt(foo, 'arguments/0/object').bar, 'arguments/0'), { content: 'assert(foo.bar)', - filepath: 'fixtures/MemberExpression/fixture.js', + filepath: 'test/fixtures/MemberExpression/fixture.js', line: 3 })); assert(assert._expr(assert._capt(assert._capt(assert._capt(foo, 'arguments/0/object/object').bar, 'arguments/0/object').baz, 'arguments/0'), { content: 'assert(foo.bar.baz)', - filepath: 'fixtures/MemberExpression/fixture.js', + filepath: 'test/fixtures/MemberExpression/fixture.js', line: 5 })); assert(assert._expr(assert._capt(assert._capt(foo, 'arguments/0/object')['bar'], 'arguments/0'), { content: 'assert(foo[\'bar\'])', - filepath: 'fixtures/MemberExpression/fixture.js', + filepath: 'test/fixtures/MemberExpression/fixture.js', line: 7 })); assert(assert._expr(assert._capt(assert._capt(foo, 'arguments/0/object')[assert._capt(propName, 'arguments/0/property')], 'arguments/0'), { content: 'assert(foo[propName])', - filepath: 'fixtures/MemberExpression/fixture.js', + filepath: 'test/fixtures/MemberExpression/fixture.js', line: 9 })); assert(assert._expr(assert._capt(assert._capt(foo, 'arguments/0/object')[assert._capt(propName, 'arguments/0/property')], 'arguments/0'), { content: 'assert(foo[propName])', - filepath: 'fixtures/MemberExpression/fixture.js', + filepath: 'test/fixtures/MemberExpression/fixture.js', line: 11 })); assert(assert._expr(assert._capt(assert._capt(foo, 'arguments/0/object')[assert._capt(func(assert._capt(key, 'arguments/0/property/arguments/0')), 'arguments/0/property')], 'arguments/0'), { content: 'assert(foo[func(key)])', - filepath: 'fixtures/MemberExpression/fixture.js', + filepath: 'test/fixtures/MemberExpression/fixture.js', line: 13 })); assert(assert._expr(assert._capt(assert._capt(assert._capt(assert._capt(foo, 'arguments/0/object/object/object')[assert._capt(propName, 'arguments/0/object/object/property')], 'arguments/0/object/object')['key'], 'arguments/0/object')[assert._capt(assert._capt(keys(), 'arguments/0/property/object')['name'], 'arguments/0/property')], 'arguments/0'), { content: 'assert(foo[propName][\'key\'][keys()[\'name\']])', - filepath: 'fixtures/MemberExpression/fixture.js', + filepath: 'test/fixtures/MemberExpression/fixture.js', line: 15 })); assert(assert._expr(assert._capt(assert._capt(assert._capt(assert._capt(foo, 'arguments/0/object/object/object')[assert._capt(propName, 'arguments/0/object/object/property')], 'arguments/0/object/object')['key'], 'arguments/0/object')[assert._capt(assert._capt(keys(), 'arguments/0/property/object')['name'], 'arguments/0/property')], 'arguments/0'), { content: 'assert(foo[propName][\'key\'][keys()[\'name\']])', - filepath: 'fixtures/MemberExpression/fixture.js', + filepath: 'test/fixtures/MemberExpression/fixture.js', line: 17 })); assert.equal(assert._expr(assert._capt(assert._capt(ary1, 'arguments/0/object').length, 'arguments/0'), { content: 'assert.equal(ary1.length, ary2.length)', - filepath: 'fixtures/MemberExpression/fixture.js', + filepath: 'test/fixtures/MemberExpression/fixture.js', line: 19 }), assert._expr(assert._capt(assert._capt(ary2, 'arguments/1/object').length, 'arguments/1'), { content: 'assert.equal(ary1.length, ary2.length)', - filepath: 'fixtures/MemberExpression/fixture.js', + filepath: 'test/fixtures/MemberExpression/fixture.js', line: 19 })); assert.deepEqual(assert._expr(assert._capt(assert._capt(foo, 'arguments/0/object').propName, 'arguments/0'), { content: 'assert.deepEqual(foo.propName, foo[key])', - filepath: 'fixtures/MemberExpression/fixture.js', + filepath: 'test/fixtures/MemberExpression/fixture.js', line: 21 }), assert._expr(assert._capt(assert._capt(foo, 'arguments/1/object')[assert._capt(key, 'arguments/1/property')], 'arguments/1'), { content: 'assert.deepEqual(foo.propName, foo[key])', - filepath: 'fixtures/MemberExpression/fixture.js', + filepath: 'test/fixtures/MemberExpression/fixture.js', line: 21 })); diff --git a/test/fixtures/NewExpression/expected.js b/test/fixtures/NewExpression/expected.js index ca47345..5d84c35 100644 --- a/test/fixtures/NewExpression/expected.js +++ b/test/fixtures/NewExpression/expected.js @@ -2,28 +2,28 @@ assert(assert._expr(assert._capt(new Date(), 'arguments/0'), { content: 'assert(new Date())', - filepath: 'fixtures/NewExpression/fixture.js', + filepath: 'test/fixtures/NewExpression/fixture.js', line: 3 })); assert(assert._expr(assert._capt(new (assert._capt(assert._capt(foo, 'arguments/0/callee/object/object').bar, 'arguments/0/callee/object').Baz)(), 'arguments/0'), { content: 'assert(new foo.bar.Baz())', - filepath: 'fixtures/NewExpression/fixture.js', + filepath: 'test/fixtures/NewExpression/fixture.js', line: 5 })); assert(assert._expr(assert._capt(!assert._capt(new Array(assert._capt(foo, 'arguments/0/argument/arguments/0'), assert._capt(bar, 'arguments/0/argument/arguments/1'), assert._capt(baz, 'arguments/0/argument/arguments/2')), 'arguments/0/argument'), 'arguments/0'), { content: 'assert(!new Array(foo, bar, baz))', - filepath: 'fixtures/NewExpression/fixture.js', + filepath: 'test/fixtures/NewExpression/fixture.js', line: 7 })); assert.notEqual(assert._expr(assert._capt(new Date(), 'arguments/0'), { content: 'assert.notEqual(new Date(), new Date(\'2013-01-12\'))', - filepath: 'fixtures/NewExpression/fixture.js', + filepath: 'test/fixtures/NewExpression/fixture.js', line: 9 }), assert._expr(assert._capt(new Date('2013-01-12'), 'arguments/1'), { content: 'assert.notEqual(new Date(), new Date(\'2013-01-12\'))', - filepath: 'fixtures/NewExpression/fixture.js', + filepath: 'test/fixtures/NewExpression/fixture.js', line: 9 })); diff --git a/test/fixtures/ObjectExpression/expected.js b/test/fixtures/ObjectExpression/expected.js index 49a0942..62fc3fd 100644 --- a/test/fixtures/ObjectExpression/expected.js +++ b/test/fixtures/ObjectExpression/expected.js @@ -2,22 +2,22 @@ assert(assert._expr(assert._capt({ foo: assert._capt(bar, 'arguments/0/properties/0/value'), hoge: assert._capt(fuga, 'arguments/0/properties/1/value') }, 'arguments/0'), { content: 'assert({foo: bar,hoge: fuga})', - filepath: 'fixtures/ObjectExpression/fixture.js', + filepath: 'test/fixtures/ObjectExpression/fixture.js', line: 3 })); assert(assert._expr(assert._capt(!assert._capt({ foo: assert._capt(assert._capt(bar, 'arguments/0/argument/properties/0/value/object').baz, 'arguments/0/argument/properties/0/value'), name: assert._capt(nameOf(assert._capt({ firstName: assert._capt(first, 'arguments/0/argument/properties/1/value/arguments/0/properties/0/value'), lastName: assert._capt(last, 'arguments/0/argument/properties/1/value/arguments/0/properties/1/value') }, 'arguments/0/argument/properties/1/value/arguments/0')), 'arguments/0/argument/properties/1/value') }, 'arguments/0/argument'), 'arguments/0'), { content: 'assert(!{foo: bar.baz,name: nameOf({firstName: first,lastName: last})})', - filepath: 'fixtures/ObjectExpression/fixture.js', + filepath: 'test/fixtures/ObjectExpression/fixture.js', line: 5 })); assert.deepEqual(assert._expr(assert._capt({ foo: assert._capt(bar, 'arguments/0/properties/0/value'), hoge: assert._capt(fuga, 'arguments/0/properties/1/value') }, 'arguments/0'), { content: 'assert.deepEqual({foo: bar,hoge: fuga}, {hoge: fuga,foo: bar})', - filepath: 'fixtures/ObjectExpression/fixture.js', + filepath: 'test/fixtures/ObjectExpression/fixture.js', line: 7 }), assert._expr(assert._capt({ hoge: assert._capt(fuga, 'arguments/1/properties/0/value'), foo: assert._capt(bar, 'arguments/1/properties/1/value') }, 'arguments/1'), { content: 'assert.deepEqual({foo: bar,hoge: fuga}, {hoge: fuga,foo: bar})', - filepath: 'fixtures/ObjectExpression/fixture.js', + filepath: 'test/fixtures/ObjectExpression/fixture.js', line: 7 })); diff --git a/test/fixtures/Property/expected.js b/test/fixtures/Property/expected.js index 20d679b..5bed7a6 100644 --- a/test/fixtures/Property/expected.js +++ b/test/fixtures/Property/expected.js @@ -4,7 +4,7 @@ function _defineProperty(obj, key, value) { return Object.defineProperty(obj, ke assert(assert._expr(assert._capt(_defineProperty({}, assert._capt(num, 'arguments/0/properties/0/key'), assert._capt(foo, 'arguments/0/properties/0/value')), 'arguments/0'), { content: 'assert({ [num]: foo })', - filepath: 'fixtures/Property/fixture.js', + filepath: 'test/fixtures/Property/fixture.js', line: 3 })); @@ -12,24 +12,24 @@ assert(assert._expr(assert._capt(_defineProperty({}, assert._capt('prop_' + asse return bar(); })(), 'arguments/0/properties/0/key/right'), 'arguments/0/properties/0/key'), 42), 'arguments/0'), { content: 'assert({ [\'prop_\' + (() => bar())()]: 42 })', - filepath: 'fixtures/Property/fixture.js', + filepath: 'test/fixtures/Property/fixture.js', line: 5 })); assert(assert._expr(assert._capt(_defineProperty({}, assert._capt('prop_' + assert._capt(generate(assert._capt(seed, 'arguments/0/properties/0/key/expressions/0/arguments/0')), 'arguments/0/properties/0/key/expressions/0'), 'arguments/0/properties/0/key'), assert._capt(foo, 'arguments/0/properties/0/value')), 'arguments/0'), { content: 'assert({ [`prop_${ generate(seed) }`]: foo })', - filepath: 'fixtures/Property/fixture.js', + filepath: 'test/fixtures/Property/fixture.js', line: 7 })); assert(assert._expr(assert._capt({ foo: foo }, 'arguments/0'), { content: 'assert({ foo })', - filepath: 'fixtures/Property/fixture.js', + filepath: 'test/fixtures/Property/fixture.js', line: 9 })); assert(assert._expr(assert._capt({ foo: foo, bar: assert._capt(baz, 'arguments/0/properties/1/value') }, 'arguments/0'), { content: 'assert({foo,bar: baz})', - filepath: 'fixtures/Property/fixture.js', + filepath: 'test/fixtures/Property/fixture.js', line: 11 })); diff --git a/test/fixtures/SpreadElement/expected.js b/test/fixtures/SpreadElement/expected.js index 5f93624..d4fab5f 100644 --- a/test/fixtures/SpreadElement/expected.js +++ b/test/fixtures/SpreadElement/expected.js @@ -4,18 +4,18 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr assert(assert._expr(assert._capt(hello.apply(undefined, _toConsumableArray(assert._capt(names, 'arguments/0/arguments/0/argument'))), 'arguments/0'), { content: 'assert(hello(...names))', - filepath: 'fixtures/SpreadElement/fixture.js', + filepath: 'test/fixtures/SpreadElement/fixture.js', line: 3 })); assert(assert._expr(assert._capt(assert._capt([assert._capt(head, 'arguments/0/object/elements/0')].concat(_toConsumableArray(assert._capt(tail, 'arguments/0/object/elements/1/argument'))), 'arguments/0/object').length, 'arguments/0'), { content: 'assert([head,...tail].length)', - filepath: 'fixtures/SpreadElement/fixture.js', + filepath: 'test/fixtures/SpreadElement/fixture.js', line: 5 })); assert(assert._expr(assert._capt(f.apply(undefined, [assert._capt(head, 'arguments/0/arguments/0')].concat(_toConsumableArray(assert._capt(iter(), 'arguments/0/arguments/1/argument')), _toConsumableArray(assert._capt([assert._capt(foo, 'arguments/0/arguments/2/argument/elements/0'), assert._capt(bar, 'arguments/0/arguments/2/argument/elements/1')], 'arguments/0/arguments/2/argument')))), 'arguments/0'), { content: 'assert(f(head, ...iter(), ...[foo,bar]))', - filepath: 'fixtures/SpreadElement/fixture.js', + filepath: 'test/fixtures/SpreadElement/fixture.js', line: 7 })); diff --git a/test/fixtures/TaggedTemplateExpression/expected.js b/test/fixtures/TaggedTemplateExpression/expected.js index 07a79dc..cdc2c25 100644 --- a/test/fixtures/TaggedTemplateExpression/expected.js +++ b/test/fixtures/TaggedTemplateExpression/expected.js @@ -4,18 +4,18 @@ function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defi assert(assert._expr(assert._capt(fn(_taggedTemplateLiteral(['a', ''], ['a', '']), 1), 'arguments/0'), { content: 'assert(fn`a${ 1 }`)', - filepath: 'fixtures/TaggedTemplateExpression/fixture.js', + filepath: 'test/fixtures/TaggedTemplateExpression/fixture.js', line: 3 })); assert(assert._expr(assert._capt(fn(_taggedTemplateLiteral(['a', 'b', 'c', ''], ['a', 'b', 'c', '']), assert._capt(foo, 'arguments/0/quasi/expressions/0'), assert._capt(bar, 'arguments/0/quasi/expressions/1'), assert._capt(baz, 'arguments/0/quasi/expressions/2')), 'arguments/0'), { content: 'assert(fn`a${ foo }b${ bar }c${ baz }`)', - filepath: 'fixtures/TaggedTemplateExpression/fixture.js', + filepath: 'test/fixtures/TaggedTemplateExpression/fixture.js', line: 5 })); assert(assert._expr(assert._capt(fn(_taggedTemplateLiteral(['driver ', ', navigator ', ''], ['driver ', ', navigator ', '']), assert._capt(assert._capt(bob, 'arguments/0/quasi/expressions/0/object').name, 'arguments/0/quasi/expressions/0'), assert._capt(assert._capt(alice, 'arguments/0/quasi/expressions/1/callee/object').getName(), 'arguments/0/quasi/expressions/1')), 'arguments/0'), { content: 'assert(fn`driver ${ bob.name }, navigator ${ alice.getName() }`)', - filepath: 'fixtures/TaggedTemplateExpression/fixture.js', + filepath: 'test/fixtures/TaggedTemplateExpression/fixture.js', line: 7 })); diff --git a/test/fixtures/TemplateLiteral/expected.js b/test/fixtures/TemplateLiteral/expected.js index 7aa9775..689b757 100644 --- a/test/fixtures/TemplateLiteral/expected.js +++ b/test/fixtures/TemplateLiteral/expected.js @@ -2,18 +2,18 @@ assert(assert._expr(assert._capt('Hello', 'arguments/0'), { content: 'assert(`Hello`)', - filepath: 'fixtures/TemplateLiteral/fixture.js', + filepath: 'test/fixtures/TemplateLiteral/fixture.js', line: 3 })); assert(assert._expr(assert._capt('Hello, ' + assert._capt(nickname, 'arguments/0/expressions/0'), 'arguments/0'), { content: 'assert(`Hello, ${ nickname }`)', - filepath: 'fixtures/TemplateLiteral/fixture.js', + filepath: 'test/fixtures/TemplateLiteral/fixture.js', line: 5 })); assert(assert._expr(assert._capt('Hello, ' + assert._capt(assert._capt(user, 'arguments/0/expressions/0/object').nickname, 'arguments/0/expressions/0'), 'arguments/0'), { content: 'assert(`Hello, ${ user.nickname }`)', - filepath: 'fixtures/TemplateLiteral/fixture.js', + filepath: 'test/fixtures/TemplateLiteral/fixture.js', line: 7 })); diff --git a/test/fixtures/UnaryExpression/expected.js b/test/fixtures/UnaryExpression/expected.js index c88fd79..3cb1609 100644 --- a/test/fixtures/UnaryExpression/expected.js +++ b/test/fixtures/UnaryExpression/expected.js @@ -2,46 +2,46 @@ assert(assert._expr(assert._capt(!assert._capt(truth, 'arguments/0/argument'), 'arguments/0'), { content: 'assert(!truth)', - filepath: 'fixtures/UnaryExpression/fixture.js', + filepath: 'test/fixtures/UnaryExpression/fixture.js', line: 3 })); assert(assert._expr(assert._capt(!assert._capt(!assert._capt(some, 'arguments/0/argument/argument'), 'arguments/0/argument'), 'arguments/0'), { content: 'assert(!!some)', - filepath: 'fixtures/UnaryExpression/fixture.js', + filepath: 'test/fixtures/UnaryExpression/fixture.js', line: 5 })); assert(assert._expr(assert._capt(!assert._capt(!assert._capt(assert._capt(foo, 'arguments/0/argument/argument/object').bar, 'arguments/0/argument/argument'), 'arguments/0/argument'), 'arguments/0'), { content: 'assert(!!foo.bar)', - filepath: 'fixtures/UnaryExpression/fixture.js', + filepath: 'test/fixtures/UnaryExpression/fixture.js', line: 7 })); assert(assert._expr(assert._capt(delete assert._capt(assert._capt(foo, 'arguments/0/argument/object').bar, 'arguments/0/argument'), 'arguments/0'), { content: 'assert(delete foo.bar)', - filepath: 'fixtures/UnaryExpression/fixture.js', + filepath: 'test/fixtures/UnaryExpression/fixture.js', line: 9 })); assert(assert._expr(assert._capt(assert._capt(typeof foo, 'arguments/0/left') !== 'undefined', 'arguments/0'), { content: 'assert(typeof foo !== \'undefined\')', - filepath: 'fixtures/UnaryExpression/fixture.js', + filepath: 'test/fixtures/UnaryExpression/fixture.js', line: 11 })); assert(assert._expr(assert._capt(assert._capt(typeof assert._capt(assert._capt(foo, 'arguments/0/left/argument/object').bar, 'arguments/0/left/argument'), 'arguments/0/left') !== 'undefined', 'arguments/0'), { content: 'assert(typeof foo.bar !== \'undefined\')', - filepath: 'fixtures/UnaryExpression/fixture.js', + filepath: 'test/fixtures/UnaryExpression/fixture.js', line: 13 })); assert.strictEqual(assert._expr(assert._capt(typeof foo, 'arguments/0'), { content: 'assert.strictEqual(typeof foo, typeof bar)', - filepath: 'fixtures/UnaryExpression/fixture.js', + filepath: 'test/fixtures/UnaryExpression/fixture.js', line: 15 }), assert._expr(assert._capt(typeof bar, 'arguments/1'), { content: 'assert.strictEqual(typeof foo, typeof bar)', - filepath: 'fixtures/UnaryExpression/fixture.js', + filepath: 'test/fixtures/UnaryExpression/fixture.js', line: 15 })); diff --git a/test/fixtures/UpdateExpression/expected.js b/test/fixtures/UpdateExpression/expected.js index f48dec8..852c5e6 100644 --- a/test/fixtures/UpdateExpression/expected.js +++ b/test/fixtures/UpdateExpression/expected.js @@ -2,22 +2,22 @@ assert(assert._expr(assert._capt(++foo, 'arguments/0'), { content: 'assert(++foo)', - filepath: 'fixtures/UpdateExpression/fixture.js', + filepath: 'test/fixtures/UpdateExpression/fixture.js', line: 3 })); assert(assert._expr(assert._capt(bar--, 'arguments/0'), { content: 'assert(bar--)', - filepath: 'fixtures/UpdateExpression/fixture.js', + filepath: 'test/fixtures/UpdateExpression/fixture.js', line: 5 })); assert.strictEqual(assert._expr(assert._capt(++foo, 'arguments/0'), { content: 'assert.strictEqual(++foo, bar--)', - filepath: 'fixtures/UpdateExpression/fixture.js', + filepath: 'test/fixtures/UpdateExpression/fixture.js', line: 7 }), assert._expr(assert._capt(bar--, 'arguments/1'), { content: 'assert.strictEqual(++foo, bar--)', - filepath: 'fixtures/UpdateExpression/fixture.js', + filepath: 'test/fixtures/UpdateExpression/fixture.js', line: 7 })); diff --git a/test/fixtures/customPatterns/expected.js b/test/fixtures/customPatterns/expected.js index b676307..32dcfe5 100644 --- a/test/fixtures/customPatterns/expected.js +++ b/test/fixtures/customPatterns/expected.js @@ -2,33 +2,33 @@ assert.isNull(assert._expr(assert._capt(falsy, 'arguments/0'), { content: 'assert.isNull(falsy)', - filepath: 'fixtures/customPatterns/fixture.js', + filepath: 'test/fixtures/customPatterns/fixture.js', line: 3 })); assert.isNull(assert._expr(assert._capt(falsy, 'arguments/0'), { content: 'assert.isNull(falsy, message)', - filepath: 'fixtures/customPatterns/fixture.js', + filepath: 'test/fixtures/customPatterns/fixture.js', line: 5 }), message); assert.same(assert._expr(assert._capt(foo, 'arguments/0'), { content: 'assert.same(foo, bar)', - filepath: 'fixtures/customPatterns/fixture.js', + filepath: 'test/fixtures/customPatterns/fixture.js', line: 7 }), assert._expr(assert._capt(bar, 'arguments/1'), { content: 'assert.same(foo, bar)', - filepath: 'fixtures/customPatterns/fixture.js', + filepath: 'test/fixtures/customPatterns/fixture.js', line: 7 })); assert.same(assert._expr(assert._capt(foo, 'arguments/0'), { content: 'assert.same(foo, bar, message)', - filepath: 'fixtures/customPatterns/fixture.js', + filepath: 'test/fixtures/customPatterns/fixture.js', line: 9 }), assert._expr(assert._capt(bar, 'arguments/1'), { content: 'assert.same(foo, bar, message)', - filepath: 'fixtures/customPatterns/fixture.js', + filepath: 'test/fixtures/customPatterns/fixture.js', line: 9 }), message); @@ -36,28 +36,28 @@ assert.near(actualVal, expectedVal); assert.near(assert._expr(assert._capt(actualVal, 'arguments/0'), { content: 'assert.near(actualVal, expectedVal, delta)', - filepath: 'fixtures/customPatterns/fixture.js', + filepath: 'test/fixtures/customPatterns/fixture.js', line: 13 }), assert._expr(assert._capt(expectedVal, 'arguments/1'), { content: 'assert.near(actualVal, expectedVal, delta)', - filepath: 'fixtures/customPatterns/fixture.js', + filepath: 'test/fixtures/customPatterns/fixture.js', line: 13 }), assert._expr(assert._capt(delta, 'arguments/2'), { content: 'assert.near(actualVal, expectedVal, delta)', - filepath: 'fixtures/customPatterns/fixture.js', + filepath: 'test/fixtures/customPatterns/fixture.js', line: 13 })); assert.near(assert._expr(assert._capt(actualVal, 'arguments/0'), { content: 'assert.near(actualVal, expectedVal, delta, message)', - filepath: 'fixtures/customPatterns/fixture.js', + filepath: 'test/fixtures/customPatterns/fixture.js', line: 15 }), assert._expr(assert._capt(expectedVal, 'arguments/1'), { content: 'assert.near(actualVal, expectedVal, delta, message)', - filepath: 'fixtures/customPatterns/fixture.js', + filepath: 'test/fixtures/customPatterns/fixture.js', line: 15 }), assert._expr(assert._capt(delta, 'arguments/2'), { content: 'assert.near(actualVal, expectedVal, delta, message)', - filepath: 'fixtures/customPatterns/fixture.js', + filepath: 'test/fixtures/customPatterns/fixture.js', line: 15 }), message); diff --git a/test/fixtures/inputSourceMap/expected.js b/test/fixtures/inputSourceMap/expected.js index 471a8e7..2524223 100644 --- a/test/fixtures/inputSourceMap/expected.js +++ b/test/fixtures/inputSourceMap/expected.js @@ -25,7 +25,7 @@ describe("various types", function () { bob = new Person("bob", 5); return assert(assert._expr(assert._capt(assert._capt(assert._capt(assert._capt(this.types, "arguments/0/left/object/object")[assert._capt(index, "arguments/0/left/object/property")], "arguments/0/left/object").name, "arguments/0/left") === assert._capt(assert._capt(bob, "arguments/0/right/object").name, "arguments/0/right"), "arguments/0"), { content: "assert(this.types[index].name === bob.name)", - filepath: "/absolute/path/to/coffee_script_test.coffee", + filepath: "path/to/coffee_script_test.coffee", line: 33 })); }); diff --git a/test/test.js b/test/test.js index 95cb3bd..ca4d1c2 100644 --- a/test/test.js +++ b/test/test.js @@ -9,8 +9,7 @@ function testTransform (fixtureName, extraOptions) { it(fixtureName, function () { var fixtureFilepath = path.resolve(__dirname, 'fixtures', fixtureName, 'fixture.js'); var expectedFilepath = path.resolve(__dirname, 'fixtures', fixtureName, 'expected.js'); - var result = babel.transform(fs.readFileSync(fixtureFilepath), extend({}, { - filename: path.relative(__dirname, fixtureFilepath), + var result = babel.transformFileSync(fixtureFilepath, extend({ plugins: ['../index'] }, extraOptions)); var actual = result.code; @@ -41,7 +40,13 @@ describe('babel-plugin-espower', function () { testTransform('ClassExpression'); testTransform('SpreadElement'); testTransform('Property'); - testTransform('inputSourceMap'); + testTransform('inputSourceMap', { + plugins: [ + createEspowerPlugin(babel, { + sourceRoot: "/absolute/" + }) + ] + }); testTransform('customPatterns', { plugins: [ createEspowerPlugin(babel, {