Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion README.md
Copy link
Member

Choose a reason for hiding this comment

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

I do not know why you are modifying this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review! I added these cases because of the inline TODO in internal/jsnum/pseudobigint_test.go (“tests for other bases”). The TODO I was responding to is in internal/jsnum/pseudobigint_test.go near the “strip base-10 strings” section (just above the “can parse large literals” test).
The file already covers one large literal per base, but didn’t have small/underscore/uppercase-prefix cases, so I added those to complement the existing “large literals” tests.
If you’d prefer these live in a different package/file, or you don’t want to expand this test, I’m happy to move them (or close). Where would you like these cases to go?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know what you're talking about, I'm commenting on the readme

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review. The README change slipped in by mistake on this branch.
I opened a clean PR with only the tests: #1678.
Closing this one to keep the diff focused.

Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,26 @@ To use this, set this in your VS Code settings:

```json
{
"typescript.experimental.useTsgo": true
"typescript.experimental.useTsgo": true
}
```

## Quick Start

### Prerequisites

To use `tsgo`, make sure you have the following installed:

- **Node.js** v20.17.x (LTS) or v22.9.x+
- **npm** v11.5.2
- **Go** v1.25+
- **Rust** (latest stable, with `cargo` available in PATH)

### Installation

```bash
npm install @typescript/native-preview

## What Works So Far?

This is still a work in progress and is not yet at full feature parity with TypeScript. Bugs may exist. Please check this list carefully before logging a new issue or assuming an intentional change.
Expand Down Expand Up @@ -77,3 +93,4 @@ trademarks or logos is subject to and must follow
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/legal/intellectualproperty/trademarks/usage/general).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.
```
37 changes: 37 additions & 0 deletions internal/jsnum/pseudobigint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,42 @@ func TestParsePseudoBigInt(t *testing.T) {

// TODO(jakebailey): tests for other bases

t.Run("parse non-decimal bases (small numbers)", func(t *testing.T) {
t.Parallel()

type tc struct {
lit string
out string
}
cases := []tc{
// binary
{lit: "0b0n", out: "0"},
{lit: "0b1n", out: "1"},
{lit: "0b1010n", out: "10"},
{lit: "0b1010_0101n", out: "165"},
{lit: "0B1101n", out: "13"}, // uppercase prefix

// octal
{lit: "0o0n", out: "0"},
{lit: "0o7n", out: "7"},
{lit: "0o755n", out: "493"},
{lit: "0o7_5_5n", out: "493"},
{lit: "0O12n", out: "10"}, // uppercase prefix

// hex
{lit: "0x0n", out: "0"},
{lit: "0xFn", out: "15"},
{lit: "0xFFn", out: "255"},
{lit: "0xF_Fn", out: "255"},
{lit: "0X1Fn", out: "31"}, // uppercase prefix
}

for _, c := range cases {
got := ParsePseudoBigInt(c.lit)
assert.Equal(t, got, c.out, "literal: %q", c.lit)
}
})

t.Run("can parse large literals", func(t *testing.T) {
t.Parallel()
assert.Equal(t, ParsePseudoBigInt("123456789012345678901234567890n"), "123456789012345678901234567890")
Expand All @@ -41,3 +77,4 @@ func TestParsePseudoBigInt(t *testing.T) {
assert.Equal(t, ParsePseudoBigInt("0x18ee90ff6c373e0ee4e3f0ad2n"), "123456789012345678901234567890")
})
}

Loading