New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test for reference paths #5296
Conversation
@jasonLaster, thanks for your PR! By analyzing the history of the files in this pull request, we identified @DrewML, @loganfsmyth and @hzoo to be potential reviewers. |
923087f
to
aebf24a
Compare
Hey @jasonLaster! It looks like one or more of your builds have failed. I've copied the relevant info below to save you some time. |
traverse(ast, { | ||
Identifier: function(path) { | ||
nodePath = path; | ||
_path.stop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should _path
be path
?
aebf24a
to
1810d9d
Compare
Hey @jasonLaster! It looks like one or more of your builds have failed. I've copied the relevant info below to save you some time. |
Hey @jasonLaster! It looks like one or more of your builds have failed. I've copied the relevant info below to save you some time. |
1810d9d
to
148067d
Compare
Codecov Report
@@ Coverage Diff @@
## master #5296 +/- ##
======================================
Coverage 89.4% 89.4%
======================================
Files 204 204
Lines 9916 9916
Branches 2670 2670
======================================
Hits 8865 8865
Misses 1051 1051 Continue to review full report at Codecov.
|
@@ -60,5 +73,13 @@ describe("scope", function () { | |||
_foo2: { } | |||
`).scope.generateUid("foo"), "_foo3"); | |||
}); | |||
|
|||
it("reference paths", function() { | |||
const node = getIdentifierPath("function square(n) { return n * n}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since you are returning a path, should this just be named path?
|
||
it("reference paths", function() { | ||
const node = getIdentifierPath("function square(n) { return n * n}"); | ||
const referencePaths = node.context.scope.bindings.n.referencePaths; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually wondering to myself what the difference betwee straight up path.scope vs path.context.scope then
Hmm. I'll check tomorrow. Perhaps scope is just an accessor for context
scope.
…On Sat, Feb 11, 2017 at 12:23 AM Henry Zhu ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In packages/babel-traverse/test/scope.js
<#5296 (review)>:
> @@ -60,5 +73,13 @@ describe("scope", function () {
_foo2: { }
`).scope.generateUid("foo"), "_foo3");
});
+
+ it("reference paths", function() {
+ const node = getIdentifierPath("function square(n) { return n * n}");
+ const referencePaths = node.context.scope.bindings.n.referencePaths;
I actually wondering to myself what the difference betwee straight up
path.scope vs path.context.scope then
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5296 (review)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAPiYh_yBjhudoETtLCklV-sdFrvwOlVks5rbUXLgaJpZM4L99tF>
.
|
148067d
to
90bf1c4
Compare
|
||
it("reference paths", function() { | ||
const path = getIdentifierPath("function square(n) { return n * n}"); | ||
const referencePaths = path.context.scope.bindings.n.referencePaths; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated: I guess we should have some tests for scope.bindings
(check that only n is defined as a binding)
const path = getIdentifierPath("function square(n) { return n * n}"); | ||
const referencePaths = path.context.scope.bindings.n.referencePaths; | ||
assert.equal(referencePaths.length, 2); | ||
assert.deepEqual(referencePaths[0].node.loc.start, { line: 1, column:28 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought we'd have a rule for column:28
spacing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, 🎉 |
Added a test for
referencePath