-
Notifications
You must be signed in to change notification settings - Fork 77
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
BaseNode.equals support, and other ast goodness from python-fluent #172
Conversation
94a22c4
to
387bc7e
Compare
stas, I think this is ready for review. I gave all those things from python-fluent a go (w/out traverse). Tests are heavily inspired by the python tests, too. Questions I know of: |
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.
Nice work! I'll finish the review tomorrow. For now, I'm leaving a few comments for your consideration.
assert.strictEqual(thisNode.value.equals(otherNode.value), true); | ||
assert.strictEqual(thisNode.value.equals(otherNode.value, []), false); | ||
assert.strictEqual(thisRes.equals(thisRes.clone(), []), true); | ||
assert.notStrictEqual(thisRes, thisRes.clone()); |
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.
Let's add a test which verifies that the original nodes have their variants in unchanged order after these tests run, please.
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'm dropping the ordering completely, per comment above, and update the tests accordingly. Let me know if there's more to do here.
This is different to python-fluent, as .equals doesn't ignore ordering of Attributes and Variants anymore. Issue on python-fluent is filed. Added an explicit test to ensure that SomeNode.clone creates the same class.
There's still an open question I have on |
Thanks for addressing my comments, @Pike! This looks good to land. Regarding the question about I'm a bit concerned that having this field is mixing concerns. The use-cases present in Pontoon should really just use |
I've taking your comments and mulled over them, and then ended up removing the |
This is basically a port of
https://github.com/projectfluent/python-fluent/blob/90301381e9b4d56b317bd6f15adf38936569f023/fluent/syntax/ast.py#L76-L120
Creating a PR early on to ensure that node 6 and 8 pass on the js features. For example, the use of
Object.keys
, which is rumored to be OK per http://node.green/#ES2015-misc-Object-static-methods-accept-primitives-Object-keys.