-
-
Notifications
You must be signed in to change notification settings - Fork 186
implemented more math function and value conversions #450
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,11 @@ export class MathTests { | |
| @TestCase("Math.cos()", "math.cos();") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing test for constants (probably would be nice to actually
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are tests for Also, I'm not sure we should do execute tests since there could be inconsistencies with precision. |
||
| @TestCase("Math.sin()", "math.sin();") | ||
| @TestCase("Math.min()", "math.min();") | ||
| @TestCase("Math.atan2(2, 3)", "math.atan(2 / 3);") | ||
| @TestCase("Math.log2(3)", `(math.log(3) / ${Math.LN2});`) | ||
| @TestCase("Math.log10(3)", `(math.log(3) / ${Math.LN10});`) | ||
| @TestCase("Math.log1p(3)", "math.log(1 + 3);") | ||
| @TestCase("Math.round(3.3)", "math.floor(3.3 + 0.5);") | ||
| @TestCase("Math.PI", "math.pi;") | ||
| @Test("Math") | ||
| public math(inp: string, expected: string): void { | ||
|
|
@@ -18,6 +23,20 @@ export class MathTests { | |
| Expect(lua).toBe(expected); | ||
| } | ||
|
|
||
| @TestCase("E") | ||
| @TestCase("LN10") | ||
| @TestCase("LN2") | ||
| @TestCase("LOG10E") | ||
| @TestCase("LOG2E") | ||
| @TestCase("SQRT1_2") | ||
| @TestCase("SQRT2") | ||
| @Test("Math constant") | ||
| public mathConstant(constant: string): void { | ||
| const epsilon = 0.000001; | ||
| const code = `return Math.abs(Math.${constant} - ${Math[constant]}) <= ${epsilon}`; | ||
| Expect(util.transpileAndExecute(code)).toBe(true); | ||
| } | ||
|
|
||
| @TestCase("++x", "x=4;y=6") | ||
| @TestCase("x++", "x=4;y=6") | ||
| @TestCase("--x", "x=2;y=6") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.