From c7669f44c108af9f91f5f3ee852b62c7ca66aa4b Mon Sep 17 00:00:00 2001 From: Arthur Verschaeve Date: Tue, 16 Jun 2015 20:18:33 +0200 Subject: [PATCH 1/3] Add tests for util.booleanify --- test/core/util.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/core/util.js b/test/core/util.js index 4588f728fe..b4925d4fb6 100644 --- a/test/core/util.js +++ b/test/core/util.js @@ -95,6 +95,12 @@ suite("util", function () { }, /illegal type for regexify/); }); + test("booleanify", function () { + assert.strictEqual(util.booleanify("true"), true); + assert.strictEqual(util.booleanify("false"), false); + assert.strictEqual(util.booleanify("inline"), "inline"); + }); + test("toIdentifier", function () { assert.equal(t.toIdentifier(t.identifier("swag")), "swag"); assert.equal(t.toIdentifier("swag-lord"), "swagLord"); From 59820b9a84426c94d0ef573795307bf1ca074d5c Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Tue, 16 Jun 2015 22:48:50 -0400 Subject: [PATCH 2/3] matchesPattern recognizes "this" --- src/babel/traversal/path/introspection.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/babel/traversal/path/introspection.js b/src/babel/traversal/path/introspection.js index 33875b1013..9588018900 100644 --- a/src/babel/traversal/path/introspection.js +++ b/src/babel/traversal/path/introspection.js @@ -10,11 +10,10 @@ import * as t from "../../types"; */ export function matchesPattern(pattern: string, allowPartial?: boolean): boolean { - var parts = pattern.split("."); - // not a member expression if (!this.isMemberExpression()) return false; + var parts = pattern.split("."); var search = [this.node]; var i = 0; @@ -45,6 +44,8 @@ export function matchesPattern(pattern: string, allowPartial?: boolean): boolean search.push(node.property); continue; } + } else if (t.isThisExpression(node)) { + if (!matches("this")) return false; } else { // we can't deal with this return false; From 80d362c534b8e72141d48fcee1b9718b8933272d Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Tue, 16 Jun 2015 23:37:32 -0400 Subject: [PATCH 3/3] fix matchesPattern with deep member expressions --- src/babel/traversal/path/introspection.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/babel/traversal/path/introspection.js b/src/babel/traversal/path/introspection.js index 9588018900..4495520e06 100644 --- a/src/babel/traversal/path/introspection.js +++ b/src/babel/traversal/path/introspection.js @@ -40,8 +40,8 @@ export function matchesPattern(pattern: string, allowPartial?: boolean): boolean // we can't deal with this return false; } else { - search.push(node.object); - search.push(node.property); + search.unshift(node.property); + search.unshift(node.object); continue; } } else if (t.isThisExpression(node)) { @@ -57,7 +57,7 @@ export function matchesPattern(pattern: string, allowPartial?: boolean): boolean } } - return true; + return i === parts.length; } /**