From 64d4b383bfe8da54a493dfe7a7e5b8e080f961c5 Mon Sep 17 00:00:00 2001 From: Chunpeng Huo Date: Tue, 10 Apr 2018 10:25:13 +1000 Subject: [PATCH] fix: ignore raw, in order to match "foo" with 'foo'. --- index.js | 4 ++-- spec/with-parser.js | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0394055..18d12de 100644 --- a/index.js +++ b/index.js @@ -2,8 +2,8 @@ const STOP = false; const SKIP_BRANCH = 1; -// ignore position info -const IGNORED_KEYS = ['start', 'end', 'loc', 'location', 'locations', 'line', 'column', 'range', 'ranges']; +// ignore position info, and raw +const IGNORED_KEYS = ['start', 'end', 'loc', 'location', 'locations', 'line', 'column', 'range', 'ranges', 'raw']; let parser = function() { throw new Error('No parser set, you need to set parser before use astMatcher. For instance, astMatcher.setParser(esprima.parse)'); diff --git a/spec/with-parser.js b/spec/with-parser.js index 1bcdc9e..b246ba7 100644 --- a/spec/with-parser.js +++ b/spec/with-parser.js @@ -198,6 +198,11 @@ module.exports = function (parserName, parser) { t.end(); }); + testP('extact matches string literal without testing raw', t => { + t.deepEqual(extractTest('a("foo")', "a('foo')"), {}); + t.end(); + }); + testP('astMatcher builds matcher', t => { t.equal(typeof astMatcher('a(__str_a)'), 'function'); t.end();