mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[sprout] Port alias-capture-in-method-receiver-and-mutate test
This commit is contained in:
+18
-2
@@ -2,10 +2,12 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
import { makeObject_Primitives, mutate } from "shared-runtime";
|
||||
|
||||
function Component() {
|
||||
// a's mutable range should be the same as x's mutable range,
|
||||
// since a is captured into x (which gets mutated later)
|
||||
let a = someObj();
|
||||
let a = makeObject_Primitives();
|
||||
|
||||
let x = [];
|
||||
x.push(a);
|
||||
@@ -14,18 +16,26 @@ function Component() {
|
||||
return [x, a];
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [],
|
||||
isComponent: false,
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
import { makeObject_Primitives, mutate } from "shared-runtime";
|
||||
|
||||
function Component() {
|
||||
const $ = useMemoCache(3);
|
||||
let x;
|
||||
let a;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
a = someObj();
|
||||
a = makeObject_Primitives();
|
||||
|
||||
x = [];
|
||||
x.push(a);
|
||||
@@ -47,5 +57,11 @@ function Component() {
|
||||
return t0;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [],
|
||||
isComponent: false,
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
+9
-1
@@ -1,7 +1,9 @@
|
||||
import { makeObject_Primitives, mutate } from "shared-runtime";
|
||||
|
||||
function Component() {
|
||||
// a's mutable range should be the same as x's mutable range,
|
||||
// since a is captured into x (which gets mutated later)
|
||||
let a = someObj();
|
||||
let a = makeObject_Primitives();
|
||||
|
||||
let x = [];
|
||||
x.push(a);
|
||||
@@ -9,3 +11,9 @@ function Component() {
|
||||
mutate(x);
|
||||
return [x, a];
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [],
|
||||
isComponent: false,
|
||||
};
|
||||
|
||||
@@ -181,7 +181,6 @@ const skipFilter = new Set([
|
||||
* Category C:
|
||||
* Tests with at 0 params and at least one ref to external values
|
||||
*/
|
||||
"alias-capture-in-method-receiver-and-mutate",
|
||||
"alias-capture-in-method-receiver",
|
||||
"alias-nested-member-path-mutate",
|
||||
"chained-assignment-context-variable",
|
||||
|
||||
Reference in New Issue
Block a user