[tests] bug repros

This commit is contained in:
Mofei Zhang
2023-08-26 14:00:43 -07:00
parent bcbcd37eb0
commit 6dbc48075b
5 changed files with 93 additions and 0 deletions
@@ -0,0 +1,28 @@
## Input
```javascript
import { invoke } from "shared-runtime";
function useFoo() {
const x = {};
const result = invoke(() => x);
console.log(result);
}
export const FIXTURE_ENTRYPOINT = {
fn: useFoo,
params: [],
isComponent: false,
};
```
## Error
```
[ReactForget] Invariant: Expected value for identifier `16` to be initialized. (5:5)
```
@@ -0,0 +1,13 @@
import { invoke } from "shared-runtime";
function useFoo() {
const x = {};
const result = invoke(() => x);
console.log(result);
}
export const FIXTURE_ENTRYPOINT = {
fn: useFoo,
params: [],
isComponent: false,
};
@@ -0,0 +1,36 @@
## Input
```javascript
function Foo() {
return {
"a.b": 1,
"a\b": 2,
"a/b": 3,
"a+b": 4,
"a b": 5,
};
}
export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [],
isComponent: false,
};
```
## Error
```
Unexpected token, expected "," (2:13)
1 | import { unstable_useMemoCache as useMemoCache } from "react";function Foo() {const $ = useMemoCache(1);let t0;if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
> 2 | t0 = { a.b: 1, a: 2, a/b: 3, a+b: 4, a b: 5 };$[0] = t0;} else {t0 = $[0];}return t0;}
| ^
3 |
4 |
5 |
```
@@ -0,0 +1,15 @@
function Foo() {
return {
"a.b": 1,
"a\b": 2,
"a/b": 3,
"a+b": 4,
"a b": 5,
};
}
export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [],
isComponent: false,
};
@@ -88,6 +88,7 @@ export async function compile(
runReactForgetBabelPlugin
).code;
} catch (e) {
e.message = e.message.replace(/\u001b[^m]*m/g, '');
error = e;
}