Skip to content

Implement Number.prototype.toString(radix)#752

Merged
Perryvw merged 4 commits into
TypeScriptToLua:masterfrom
ark120202:number-to-string-radix
Nov 26, 2019
Merged

Implement Number.prototype.toString(radix)#752
Perryvw merged 4 commits into
TypeScriptToLua:masterfrom
ark120202:number-to-string-radix

Conversation

@ark120202

Copy link
Copy Markdown
Contributor

Resolves #723.

@ark120202 ark120202 force-pushed the number-to-string-radix branch from 321aaf0 to 32192c4 Compare November 25, 2019 21:18
Comment thread test/unit/builtins/numbers.spec.ts Outdated
const toStringRadixes = [undefined, 10, 2, 8, 9, 16, 17, 36, 36.9];
const toStringValues = [...numberCases, 1024, 1.2, NaN];
// TODO: flatMap
const toStringPairs = toStringValues.reduce<Array<readonly [number, number | undefined]>>(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is very hard to read, maybe we could make some helper function combinations or testCombinations. Also do we really need to check NaN for every radix value? Might be nicer as a separate test.

return this.toString();
}

radix = Math.floor(radix);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you use some kind of reference for this implementation? If so, could you add a comment with a link.

@ark120202 ark120202 closed this Nov 26, 2019
@ark120202 ark120202 deleted the number-to-string-radix branch November 26, 2019 08:19
@ark120202 ark120202 restored the number-to-string-radix branch November 26, 2019 08:19
@ark120202 ark120202 reopened this Nov 26, 2019
@Perryvw Perryvw merged commit c7b3810 into TypeScriptToLua:master Nov 26, 2019
@ark120202 ark120202 deleted the number-to-string-radix branch November 27, 2019 06:53
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.

Number.toString() doesn't support radix

2 participants