[sprout] Port alias-capture-in-method-receiver-and-mutate test

This commit is contained in:
Sathya Gunasekaran
2023-08-23 17:44:26 +01:00
parent aceacce5e2
commit 56b0f971d0
3 changed files with 27 additions and 4 deletions
@@ -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,
};
```
@@ -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",