Skip to content
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

Fix template literals with numbers #90

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

uurien
Copy link
Collaborator

@uurien uurien commented Aug 7, 2024

What does this PR do?

Fixes some corner cases when template literals are used with numbers

Motivation

Fix the bugs

Additional Notes

Describe how to test your changes

Checklist

  • The CHANGELOG.md has been updated
  • Unit tests have been updated and pass
  • If known, an appropriate milestone has been selected

@uurien uurien marked this pull request as ready for review August 7, 2024 12:11
@uurien uurien requested a review from a team as a code owner August 7, 2024 12:11
@@ -4,36 +4,37 @@
**/
/* eslint-disable no-template-curly-in-string */
/* eslint-disable no-multi-str */
const { rewriteAndExpectNoTransformation, rewriteAndExpect } = require('./util')
const { rewriteAst, rewriteAndExpectNoTransformation, rewriteAndExpect } = require('./util')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the changes in this file are only tabs, I'll add comments in changed points

const js = 'const result = `Hello World!${a}`;'
rewriteAndExpect(js, '{\nconst result = _ddiast.plusOperator("Hello World!" + a, "Hello World!", a);\n}')
})
it('Only vars', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New test here

Comment on lines +165 to +166
__datadog_test_1 = (__datadog_test_0 = _ddiast.plusOperator(\'bye \' + d, \'bye \', d), _ddiast.plusOperator(\
__datadog_test_0 + "", __datadog_test_0, "")), _ddiast.plusOperator(\'how are u \' + __datadog_test_1, \'how are u \', \
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change in these lines, but nothing important, only the order from "" + __datadog_test_0 to __datadog_test_0 + ""

})
})

describe('Execution tests', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the tests in this describe are new

@uurien uurien merged commit 9b3a654 into main Aug 7, 2024
20 checks passed
@uurien uurien deleted the ugaitz/fix-template-literals-with-numbers branch August 7, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants