Comparing version 0.1.0 to 0.1.1
@@ -48,3 +48,3 @@ /** | ||
* Instrument power assert feature into code. Mozilla JS AST in, Mozilla JS AST out. | ||
* @param JavaScript Mozilla JS AST to instrument (directly modified if destructive option is truthy) | ||
* @param ast JavaScript Mozilla JS AST to instrument (directly modified if destructive option is truthy) | ||
* @param options | ||
@@ -138,4 +138,8 @@ * @return instrumented AST | ||
case 'MemberExpression': // ex: foo.bar.baz | ||
var propLocation = that.propertyLocationOf(node); | ||
node.object = that.captureRecursively(node.object); | ||
return that.captureIdent(node, that.propertyLocationOf(node)); | ||
if (node.computed) { | ||
node.property = that.captureRecursively(node.property); | ||
} | ||
return that.captureIdent(node, propLocation); | ||
case 'CallExpression': | ||
@@ -176,7 +180,13 @@ node.arguments = node.arguments.map(function (arg) { | ||
newLocation, | ||
computed = memberExpression.computed, | ||
prop = memberExpression.property, | ||
propertyIndex; | ||
if (typeof prop.loc !== 'undefined') { // esprima | ||
return that.locationOf(prop); | ||
} else if (typeof memberExpression.loc !== 'undefined') { // CoffeeScriptRedux | ||
if (typeof prop.loc !== 'undefined') { | ||
var propLocation = that.locationOf(prop); | ||
if (computed) { | ||
var columnObjectLiteralNode = propLocation.properties[0].value.properties[1].value; | ||
columnObjectLiteralNode.value -= 1; | ||
} | ||
return propLocation; | ||
} else if (typeof memberExpression.loc !== 'undefined') { // non-computed MemberExpression under CoffeeScriptRedux | ||
propertyIndex = that.line.indexOf(prop.name, memberExpression.loc.start.column); | ||
@@ -183,0 +193,0 @@ if (propertyIndex === -1) { |
{ | ||
"name": "espower", | ||
"description": "Power Assert feature instrumentor based on the Mozilla JavaScript AST", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "test", |
espower | ||
================================ | ||
[![Build Status](https://travis-ci.org/twada/espower.png?branch=master)](https://travis-ci.org/twada/espower) | ||
Power Assert feature instrumentor based on the Mozilla JavaScript AST. | ||
@@ -25,2 +27,2 @@ | ||
--------------------------------------- | ||
Licensed under the [MIT](https://raw.github.com/twada/empower/master/MIT-LICENSE.txt) license. | ||
Licensed under the [MIT](https://raw.github.com/twada/espower/master/MIT-LICENSE.txt) license. |
@@ -78,2 +78,17 @@ var espower = require('../lib/espower'), | ||
inst("assert(foo.bar);", | ||
"assert(assert._expr(assert._capt(assert._capt(foo,'ident',{start:{line:1,column:7}}).bar,'ident',{start:{line:1,column:11}}),{start:{line:1,column:7}}));"); | ||
inst("assert(foo['bar']);", | ||
"assert(assert._expr(assert._capt(assert._capt(foo,'ident',{start:{line:1,column:7}})['bar'],'ident',{start:{line:1,column:10}}),{start:{line:1,column:7}}));"); | ||
inst("assert(foo[propName]);", | ||
"assert(assert._expr(assert._capt(assert._capt(foo,'ident',{start:{line:1,column:7}})[assert._capt(propName,'ident',{start:{line:1,column:11}})],'ident',{start:{line:1,column:10}}),{start:{line:1,column:7}}));"); | ||
inst("assert(foo[func(key)]);", | ||
"assert(assert._expr(assert._capt(assert._capt(foo,'ident',{start:{line:1,column:7}})[assert._capt(func(assert._capt(key,'ident',{start:{line:1,column:16}})),'funcall',{start:{line:1,column:11}})],'ident',{start:{line:1,column:10}}),{start:{line:1,column:7}}));"); | ||
inst("assert(foo[propName]['key'][keys()['name']]);", | ||
"assert(assert._expr(assert._capt(assert._capt(assert._capt(assert._capt(foo,'ident',{start:{line:1,column:7}})[assert._capt(propName,'ident',{start:{line:1,column:11}})],'ident',{start:{line:1,column:10}})['key'],'ident',{start:{line:1,column:20}})[assert._capt(assert._capt(keys(),'funcall',{start:{line:1,column:28}})['name'],'ident',{start:{line:1,column:34}})],'ident',{start:{line:1,column:27}}),{start:{line:1,column:7}}));"); | ||
inst("assert(func());", | ||
@@ -80,0 +95,0 @@ "assert(assert._expr(assert._capt(func(),'funcall',{start:{line:1,column:7}}),{start:{line:1,column:7}}));"); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37093
702
28