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

feat(): fix unary, math, and conditional operatiors + test updates #277

Merged
merged 6 commits into from
Oct 5, 2024

Conversation

TroyAlford
Copy link
Owner

  • fully working evaluation of unary/binary/math operators
  • clean up a bunch of tests

}
return undefined
return handleNaN(binaryResult)
Copy link
Owner Author

Choose a reason for hiding this comment

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

this helper ensures that we actually treat NaN as a real value and output its string version when appropriate.

Comment on lines +143 to +145
if (expression.name === 'Infinity') return Infinity
if (expression.name === '-Infinity') return -Infinity
if (expression.name === 'NaN') return NaN
Copy link
Owner Author

Choose a reason for hiding this comment

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

Infinity, -Infinity, and NaN are valid JS values — but we were throwing them away and incorrectly using them prior.

Comment on lines +180 to +183
const unaryValue = this.#parseExpression(
expression.argument as AcornJSX.Expression,
scope,
)
Copy link
Owner Author

Choose a reason for hiding this comment

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

this is needed in order to handle -Infinity correctly. This value actually comes through as a unary operator - along with the Literal Infinity — but by parsing it, we can get it back as -Infinity correctly.

@TroyAlford TroyAlford merged commit 3a2c41f into develop Oct 5, 2024
1 check passed
@TroyAlford TroyAlford deleted the task/cleanup-lint-and-tests branch October 5, 2024 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants