es3-safe-recast
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -54,3 +54,7 @@ var recast = require('recast'); | ||
var TEST_REGEX = module.exports.TEST_REGEX = /catch|finally/i; | ||
var TEST_REGEX = module.exports.TEST_REGEX = buildTestRegex(); | ||
function buildTestRegex() { | ||
var regexString = Object.keys(identifierToLiteral).join('|'); | ||
return new RegExp(regexString, 'i'); | ||
} | ||
@@ -57,0 +61,0 @@ module.exports.visit = function(ast) { |
{ | ||
"name": "es3-safe-recast", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "esprima/recast es3 safe compile step", | ||
@@ -21,3 +21,2 @@ "main": "index.js", | ||
"recast": "~0.5.20", | ||
"es6-computed-property-keys": "~0.1.1", | ||
"es-simpler-traverser": "0.0.1", | ||
@@ -24,0 +23,0 @@ "esprima": "~1.2.2" |
@@ -26,1 +26,113 @@ var assert = require('better-assert'); | ||
}); | ||
describe('catch', function() { | ||
it('works with literal syntax', function() { | ||
var actual = compiler.compile('var object = {\ncatch: null,\n};'); | ||
var expected = 'var object = {\n"catch": null,\n};' | ||
astEqual(actual, expected, 'expected input.js and output.js to match'); | ||
}); | ||
it('works with member syntax', function() { | ||
var actual = compiler.compile('object.catch(function(){\n\n});'); | ||
var expected = 'object["catch"](function(){\n\n});'; | ||
astEqual(actual, expected, 'expected input.js and output.js to match'); | ||
}); | ||
}); | ||
describe('finally', function() { | ||
it('works with literal syntax', function() { | ||
var actual = compiler.compile('var object = {\nfinally: null,\n};'); | ||
var expected = 'var object = {\n"finally": null,\n};' | ||
astEqual(actual, expected, 'expected input.js and output.js to match'); | ||
}); | ||
it('works with member syntax', function() { | ||
var actual = compiler.compile('object.finally(function(){\n\n});'); | ||
var expected = 'object["finally"](function(){\n\n});'; | ||
astEqual(actual, expected, 'expected input.js and output.js to match'); | ||
}); | ||
}); | ||
describe('default', function() { | ||
it('works with literal syntax', function() { | ||
var actual = compiler.compile('var object = {\ndefault: null,\n};'); | ||
var expected = 'var object = {\n"default": null,\n};' | ||
astEqual(actual, expected, 'expected input.js and output.js to match'); | ||
}); | ||
it('works with member syntax', function() { | ||
var actual = compiler.compile('object.default(function(){\n\n});'); | ||
var expected = 'object["default"](function(){\n\n});'; | ||
astEqual(actual, expected, 'expected input.js and output.js to match'); | ||
}); | ||
}); | ||
describe('new', function() { | ||
it('works with literal syntax', function() { | ||
var actual = compiler.compile('var object = {\nnew: null,\n};'); | ||
var expected = 'var object = {\n"new": null,\n};' | ||
astEqual(actual, expected, 'expected input.js and output.js to match'); | ||
}); | ||
it('works with member syntax', function() { | ||
var actual = compiler.compile('object.new(function(){\n\n});'); | ||
var expected = 'object["new"](function(){\n\n});'; | ||
astEqual(actual, expected, 'expected input.js and output.js to match'); | ||
}); | ||
}); | ||
describe('throw', function() { | ||
it('works with literal syntax', function() { | ||
var actual = compiler.compile('var object = {\nthrow: null,\n};'); | ||
var expected = 'var object = {\n"throw": null,\n};' | ||
astEqual(actual, expected, 'expected input.js and output.js to match'); | ||
}); | ||
it('works with member syntax', function() { | ||
var actual = compiler.compile('object.throw(function(){\n\n});'); | ||
var expected = 'object["throw"](function(){\n\n});'; | ||
astEqual(actual, expected, 'expected input.js and output.js to match'); | ||
}); | ||
}); | ||
describe('return', function() { | ||
it('works with literal syntax', function() { | ||
var actual = compiler.compile('var object = {\nreturn: null,\n};'); | ||
var expected = 'var object = {\n"return": null,\n};' | ||
astEqual(actual, expected, 'expected input.js and output.js to match'); | ||
}); | ||
it('works with member syntax', function() { | ||
var actual = compiler.compile('object.return(function(){\n\n});'); | ||
var expected = 'object["return"](function(){\n\n});'; | ||
astEqual(actual, expected, 'expected input.js and output.js to match'); | ||
}); | ||
}); | ||
describe('import', function() { | ||
it('works with literal syntax', function() { | ||
var actual = compiler.compile('var object = {\nimport: null,\n};'); | ||
var expected = 'var object = {\n"import": null,\n};' | ||
astEqual(actual, expected, 'expected input.js and output.js to match'); | ||
}); | ||
it('works with member syntax', function() { | ||
var actual = compiler.compile('object.import(function(){\n\n});'); | ||
var expected = 'object["import"](function(){\n\n});'; | ||
astEqual(actual, expected, 'expected input.js and output.js to match'); | ||
}); | ||
}); |
8023
3
193
- Removedes6-computed-property-keys@~0.1.1
- Removedast-types@0.4.13(transitive)
- Removeddepd@1.0.1(transitive)
- Removedes6-computed-property-keys@0.1.2(transitive)
- Removedesprima-fb@6001.1001.0-dev-harmony-fb(transitive)
- Removedrecast@0.7.5(transitive)
- Removedthrough@2.3.8(transitive)