[compiler][be] Clean up bug test fixtures; evaluate more fixtures

Test fixtures testing different compiler features (e.g. non-auto memoization) should live in separate directories.

Remove bug-prefixed fixtures that have since been fixed

Add test evaluator export to more fixtures
This commit is contained in:
Mofei Zhang
2025-02-18 12:02:18 -07:00
parent a9575dcf62
commit b8afb3d9ac
43 changed files with 673 additions and 148 deletions
@@ -2,22 +2,31 @@
## Input
```javascript
import {makeArray} from 'shared-runtime';
function Component(props) {
const x = foo(...props.a, null, ...props.b);
const x = makeArray(...props.a, null, ...props.b);
return x;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: [1, 2], b: [2, 3, 4]}],
};
```
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { makeArray } from "shared-runtime";
function Component(props) {
const $ = _c(3);
let t0;
if ($[0] !== props.a || $[1] !== props.b) {
t0 = foo(...props.a, null, ...props.b);
t0 = makeArray(...props.a, null, ...props.b);
$[0] = props.a;
$[1] = props.b;
$[2] = t0;
@@ -28,5 +37,12 @@ function Component(props) {
return x;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ a: [1, 2], b: [2, 3, 4] }],
};
```
### Eval output
(kind: ok) [1,2,null,2,3,4]
@@ -1,4 +1,11 @@
import {makeArray} from 'shared-runtime';
function Component(props) {
const x = foo(...props.a, null, ...props.b);
const x = makeArray(...props.a, null, ...props.b);
return x;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: [1, 2], b: [2, 3, 4]}],
};
@@ -2,7 +2,9 @@
## Input
```javascript
function component(foo, bar) {
import {mutate} from 'shared-runtime';
function Component({foo, bar}) {
let x = {foo};
let y = {bar};
const f0 = function () {
@@ -15,14 +17,28 @@ function component(foo, bar) {
return x;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{foo: 2, bar: 3}],
sequentialRenders: [
{foo: 2, bar: 3},
{foo: 2, bar: 3},
{foo: 2, bar: 4},
{foo: 3, bar: 4},
],
};
```
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
function component(foo, bar) {
import { mutate } from "shared-runtime";
function Component(t0) {
const $ = _c(3);
const { foo, bar } = t0;
let x;
if ($[0] !== bar || $[1] !== foo) {
x = { foo };
@@ -44,5 +60,21 @@ function component(foo, bar) {
return x;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ foo: 2, bar: 3 }],
sequentialRenders: [
{ foo: 2, bar: 3 },
{ foo: 2, bar: 3 },
{ foo: 2, bar: 4 },
{ foo: 3, bar: 4 },
],
};
```
### Eval output
(kind: ok) {"foo":2}
{"foo":2}
{"foo":2}
{"foo":3}
@@ -1,4 +1,6 @@
function component(foo, bar) {
import {mutate} from 'shared-runtime';
function Component({foo, bar}) {
let x = {foo};
let y = {bar};
const f0 = function () {
@@ -10,3 +12,14 @@ function component(foo, bar) {
mutate(y);
return x;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{foo: 2, bar: 3}],
sequentialRenders: [
{foo: 2, bar: 3},
{foo: 2, bar: 3},
{foo: 2, bar: 4},
{foo: 3, bar: 4},
],
};
@@ -2,7 +2,9 @@
## Input
```javascript
function component(foo, bar) {
import {mutate} from 'shared-runtime';
function Component({foo, bar}) {
let x = {foo};
let y = {bar};
const f0 = function () {
@@ -15,14 +17,28 @@ function component(foo, bar) {
return x;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{foo: 2, bar: 3}],
sequentialRenders: [
{foo: 2, bar: 3},
{foo: 2, bar: 3},
{foo: 2, bar: 4},
{foo: 3, bar: 4},
],
};
```
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
function component(foo, bar) {
import { mutate } from "shared-runtime";
function Component(t0) {
const $ = _c(3);
const { foo, bar } = t0;
let x;
if ($[0] !== bar || $[1] !== foo) {
x = { foo };
@@ -44,5 +60,21 @@ function component(foo, bar) {
return x;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ foo: 2, bar: 3 }],
sequentialRenders: [
{ foo: 2, bar: 3 },
{ foo: 2, bar: 3 },
{ foo: 2, bar: 4 },
{ foo: 3, bar: 4 },
],
};
```
### Eval output
(kind: ok) {"foo":2}
{"foo":2}
{"foo":2}
{"foo":3}
@@ -1,4 +1,6 @@
function component(foo, bar) {
import {mutate} from 'shared-runtime';
function Component({foo, bar}) {
let x = {foo};
let y = {bar};
const f0 = function () {
@@ -10,3 +12,14 @@ function component(foo, bar) {
mutate(y);
return x;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{foo: 2, bar: 3}],
sequentialRenders: [
{foo: 2, bar: 3},
{foo: 2, bar: 3},
{foo: 2, bar: 4},
{foo: 3, bar: 4},
],
};
@@ -2,7 +2,8 @@
## Input
```javascript
function component(foo, bar) {
import {mutate} from 'shared-runtime';
function Component({foo, bar}) {
let x = {foo};
let y = {bar};
const f0 = function () {
@@ -15,14 +16,27 @@ function component(foo, bar) {
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{foo: 2, bar: 3}],
sequentialRenders: [
{foo: 2, bar: 3},
{foo: 2, bar: 3},
{foo: 2, bar: 4},
{foo: 3, bar: 4},
],
};
```
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
function component(foo, bar) {
import { mutate } from "shared-runtime";
function Component(t0) {
const $ = _c(3);
const { foo, bar } = t0;
let y;
if ($[0] !== bar || $[1] !== foo) {
const x = { foo };
@@ -44,5 +58,21 @@ function component(foo, bar) {
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ foo: 2, bar: 3 }],
sequentialRenders: [
{ foo: 2, bar: 3 },
{ foo: 2, bar: 3 },
{ foo: 2, bar: 4 },
{ foo: 3, bar: 4 },
],
};
```
### Eval output
(kind: ok) {"bar":3,"wat0":"joe"}
{"bar":3,"wat0":"joe"}
{"bar":4,"wat0":"joe"}
{"bar":4,"wat0":"joe"}
@@ -1,4 +1,5 @@
function component(foo, bar) {
import {mutate} from 'shared-runtime';
function Component({foo, bar}) {
let x = {foo};
let y = {bar};
const f0 = function () {
@@ -10,3 +11,14 @@ function component(foo, bar) {
mutate(y);
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{foo: 2, bar: 3}],
sequentialRenders: [
{foo: 2, bar: 3},
{foo: 2, bar: 3},
{foo: 2, bar: 4},
{foo: 3, bar: 4},
],
};
@@ -2,7 +2,8 @@
## Input
```javascript
function component(a) {
import {mutate} from 'shared-runtime';
function Component({a}) {
let x = {a};
let y = {};
const f0 = function () {
@@ -13,14 +14,22 @@ function component(a) {
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2}],
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
};
```
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
function component(a) {
import { mutate } from "shared-runtime";
function Component(t0) {
const $ = _c(2);
const { a } = t0;
let y;
if ($[0] !== a) {
const x = { a };
@@ -39,5 +48,15 @@ function component(a) {
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ a: 2 }],
sequentialRenders: [{ a: 2 }, { a: 2 }, { a: 3 }],
};
```
### Eval output
(kind: ok) {"x":{"a":2},"wat0":"joe"}
{"x":{"a":2},"wat0":"joe"}
{"x":{"a":3},"wat0":"joe"}
@@ -1,4 +1,5 @@
function component(a) {
import {mutate} from 'shared-runtime';
function Component({a}) {
let x = {a};
let y = {};
const f0 = function () {
@@ -8,3 +9,9 @@ function component(a) {
mutate(y);
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2}],
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
};
@@ -2,7 +2,8 @@
## Input
```javascript
function component(a) {
import {mutate} from 'shared-runtime';
function Component({a}) {
let x = {a};
let y = {};
const f0 = function () {
@@ -13,14 +14,22 @@ function component(a) {
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2}],
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
};
```
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
function component(a) {
import { mutate } from "shared-runtime";
function Component(t0) {
const $ = _c(2);
const { a } = t0;
let y;
if ($[0] !== a) {
const x = { a };
@@ -39,5 +48,15 @@ function component(a) {
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ a: 2 }],
sequentialRenders: [{ a: 2 }, { a: 2 }, { a: 3 }],
};
```
### Eval output
(kind: ok) {"x":{"a":2},"wat0":"joe"}
{"x":{"a":2},"wat0":"joe"}
{"x":{"a":3},"wat0":"joe"}
@@ -1,4 +1,5 @@
function component(a) {
import {mutate} from 'shared-runtime';
function Component({a}) {
let x = {a};
let y = {};
const f0 = function () {
@@ -8,3 +9,9 @@ function component(a) {
mutate(y);
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2}],
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
};
@@ -2,7 +2,9 @@
## Input
```javascript
function component(a) {
import {mutate} from 'shared-runtime';
function Component({a}) {
let x = {a};
let y = {};
const f0 = function () {
@@ -14,14 +16,23 @@ function component(a) {
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2}],
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
};
```
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
function component(a) {
import { mutate } from "shared-runtime";
function Component(t0) {
const $ = _c(2);
const { a } = t0;
let y;
if ($[0] !== a) {
const x = { a };
@@ -41,5 +52,15 @@ function component(a) {
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ a: 2 }],
sequentialRenders: [{ a: 2 }, { a: 2 }, { a: 3 }],
};
```
### Eval output
(kind: ok) {"x":{"a":2},"wat0":"joe"}
{"x":{"a":2},"wat0":"joe"}
{"x":{"a":3},"wat0":"joe"}
@@ -1,4 +1,6 @@
function component(a) {
import {mutate} from 'shared-runtime';
function Component({a}) {
let x = {a};
let y = {};
const f0 = function () {
@@ -9,3 +11,9 @@ function component(a) {
mutate(y);
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2}],
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
};
@@ -2,7 +2,9 @@
## Input
```javascript
function component(a) {
import {mutate} from 'shared-runtime';
function Component({a}) {
let x = {a};
let y = {};
const f0 = function () {
@@ -14,14 +16,23 @@ function component(a) {
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2}],
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
};
```
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
function component(a) {
import { mutate } from "shared-runtime";
function Component(t0) {
const $ = _c(2);
const { a } = t0;
let y;
if ($[0] !== a) {
const x = { a };
@@ -41,5 +52,15 @@ function component(a) {
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ a: 2 }],
sequentialRenders: [{ a: 2 }, { a: 2 }, { a: 3 }],
};
```
### Eval output
(kind: ok) {"x":{"a":2},"wat0":"joe"}
{"x":{"a":2},"wat0":"joe"}
{"x":{"a":3},"wat0":"joe"}
@@ -1,4 +1,6 @@
function component(a) {
import {mutate} from 'shared-runtime';
function Component({a}) {
let x = {a};
let y = {};
const f0 = function () {
@@ -9,3 +11,9 @@ function component(a) {
mutate(y);
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2}],
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
};
@@ -2,7 +2,9 @@
## Input
```javascript
function component(a) {
import {mutate} from 'shared-runtime';
function Component({a}) {
let x = {a};
let y = {};
const f0 = function () {
@@ -13,14 +15,23 @@ function component(a) {
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2}],
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
};
```
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
function component(a) {
import { mutate } from "shared-runtime";
function Component(t0) {
const $ = _c(2);
const { a } = t0;
let y;
if ($[0] !== a) {
const x = { a };
@@ -39,5 +50,15 @@ function component(a) {
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ a: 2 }],
sequentialRenders: [{ a: 2 }, { a: 2 }, { a: 3 }],
};
```
### Eval output
(kind: ok) {"a":2,"wat0":"joe"}
{"a":2,"wat0":"joe"}
{"a":3,"wat0":"joe"}
@@ -1,4 +1,6 @@
function component(a) {
import {mutate} from 'shared-runtime';
function Component({a}) {
let x = {a};
let y = {};
const f0 = function () {
@@ -8,3 +10,9 @@ function component(a) {
mutate(y);
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2}],
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
};
@@ -2,7 +2,9 @@
## Input
```javascript
function component(a, b) {
import {mutate} from 'shared-runtime';
function Component({a, b}) {
let z = {a};
(function () {
mutate(z);
@@ -17,14 +19,28 @@ function component(a, b) {
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2, b: 3}],
sequentialRenders: [
{a: 2, b: 3},
{a: 2, b: 3},
{a: 2, b: 4},
{a: 3, b: 4},
],
};
```
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
function component(a, b) {
import { mutate } from "shared-runtime";
function Component(t0) {
const $ = _c(7);
const { a, b } = t0;
let z;
if ($[0] !== a) {
z = { a };
@@ -37,27 +53,43 @@ function component(a, b) {
}
let y = z;
let t0;
if ($[2] !== b) {
t0 = { b };
$[2] = b;
$[3] = t0;
} else {
t0 = $[3];
}
const z_0 = t0;
let t1;
if ($[2] !== b) {
t1 = { b };
$[2] = b;
$[3] = t1;
} else {
t1 = $[3];
}
const z_0 = t1;
let t2;
if ($[4] !== y || $[5] !== z_0) {
t1 = { y, z: z_0 };
t2 = { y, z: z_0 };
$[4] = y;
$[5] = z_0;
$[6] = t1;
$[6] = t2;
} else {
t1 = $[6];
t2 = $[6];
}
y = t1;
y = t2;
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ a: 2, b: 3 }],
sequentialRenders: [
{ a: 2, b: 3 },
{ a: 2, b: 3 },
{ a: 2, b: 4 },
{ a: 3, b: 4 },
],
};
```
### Eval output
(kind: ok) {"y":{"a":2,"wat0":"joe"},"z":{"b":3}}
{"y":{"a":2,"wat0":"joe"},"z":{"b":3}}
{"y":{"a":2,"wat0":"joe"},"z":{"b":4}}
{"y":{"a":3,"wat0":"joe"},"z":{"b":4}}
@@ -1,4 +1,6 @@
function component(a, b) {
import {mutate} from 'shared-runtime';
function Component({a, b}) {
let z = {a};
(function () {
mutate(z);
@@ -12,3 +14,14 @@ function component(a, b) {
}
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2, b: 3}],
sequentialRenders: [
{a: 2, b: 3},
{a: 2, b: 3},
{a: 2, b: 4},
{a: 3, b: 4},
],
};
@@ -2,8 +2,7 @@
## Input
```javascript
// @debug
function component(a, b) {
function useHook(a, b) {
let z = {a};
let y = b;
let x = function () {
@@ -22,8 +21,8 @@ function component(a, b) {
## Code
```javascript
import { c as _c } from "react/compiler-runtime"; // @debug
function component(a, b) {
import { c as _c } from "react/compiler-runtime";
function useHook(a, b) {
const $ = _c(5);
let t0;
if ($[0] !== a) {
@@ -1,5 +1,4 @@
// @debug
function component(a, b) {
function useHook(a, b) {
let z = {a};
let y = b;
let x = function () {
@@ -2,7 +2,9 @@
## Input
```javascript
function component(a, b) {
import {mutate} from 'shared-runtime';
function useHook({a, b}) {
let z = {a};
{
let z = {b};
@@ -13,23 +15,37 @@ function component(a, b) {
return z;
}
export const FIXTURE_ENTRYPOINT = {
fn: useHook,
params: [{a: 2, b: 3}],
sequentialRenders: [
{a: 2, b: 3},
{a: 2, b: 3},
{a: 2, b: 4},
{a: 3, b: 4},
],
};
```
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
function component(a, b) {
import { mutate } from "shared-runtime";
function useHook(t0) {
const $ = _c(2);
let t0;
const { a, b } = t0;
let t1;
if ($[0] !== a) {
t0 = { a };
t1 = { a };
$[0] = a;
$[1] = t0;
$[1] = t1;
} else {
t0 = $[1];
t1 = $[1];
}
const z = t0;
const z = t1;
const z_0 = { b };
@@ -37,5 +53,21 @@ function component(a, b) {
return z;
}
export const FIXTURE_ENTRYPOINT = {
fn: useHook,
params: [{ a: 2, b: 3 }],
sequentialRenders: [
{ a: 2, b: 3 },
{ a: 2, b: 3 },
{ a: 2, b: 4 },
{ a: 3, b: 4 },
],
};
```
### Eval output
(kind: ok) {"a":2}
{"a":2}
{"a":2}
{"a":3}
@@ -1,4 +1,6 @@
function component(a, b) {
import {mutate} from 'shared-runtime';
function useHook({a, b}) {
let z = {a};
{
let z = {b};
@@ -8,3 +10,14 @@ function component(a, b) {
}
return z;
}
export const FIXTURE_ENTRYPOINT = {
fn: useHook,
params: [{a: 2, b: 3}],
sequentialRenders: [
{a: 2, b: 3},
{a: 2, b: 3},
{a: 2, b: 4},
{a: 3, b: 4},
],
};
@@ -2,11 +2,17 @@
## Input
```javascript
function component(a, b) {
import {Stringify} from 'shared-runtime';
function Component({a, b}) {
let z = {a};
let p = () => <Foo>{z}</Foo>;
let p = () => <Stringify>{z}</Stringify>;
return p();
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 1}],
sequentialRenders: [{a: 1}, {a: 1}, {a: 2}],
};
```
@@ -14,36 +20,48 @@ function component(a, b) {
```javascript
import { c as _c } from "react/compiler-runtime";
function component(a, b) {
import { Stringify } from "shared-runtime";
function Component(t0) {
const $ = _c(6);
let t0;
if ($[0] !== a) {
t0 = { a };
$[0] = a;
$[1] = t0;
} else {
t0 = $[1];
}
const z = t0;
const { a } = t0;
let t1;
if ($[2] !== z) {
t1 = () => <Foo>{z}</Foo>;
$[2] = z;
$[3] = t1;
if ($[0] !== a) {
t1 = { a };
$[0] = a;
$[1] = t1;
} else {
t1 = $[3];
t1 = $[1];
}
const p = t1;
const z = t1;
let t2;
if ($[4] !== p) {
t2 = p();
$[4] = p;
$[5] = t2;
if ($[2] !== z) {
t2 = () => <Stringify>{z}</Stringify>;
$[2] = z;
$[3] = t2;
} else {
t2 = $[5];
t2 = $[3];
}
return t2;
const p = t2;
let t3;
if ($[4] !== p) {
t3 = p();
$[4] = p;
$[5] = t3;
} else {
t3 = $[5];
}
return t3;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ a: 1 }],
sequentialRenders: [{ a: 1 }, { a: 1 }, { a: 2 }],
};
```
### Eval output
(kind: ok) <div>{"children":{"a":1}}</div>
<div>{"children":{"a":1}}</div>
<div>{"children":{"a":2}}</div>
@@ -1,5 +1,11 @@
function component(a, b) {
import {Stringify} from 'shared-runtime';
function Component({a, b}) {
let z = {a};
let p = () => <Foo>{z}</Foo>;
let p = () => <Stringify>{z}</Stringify>;
return p();
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 1}],
sequentialRenders: [{a: 1}, {a: 1}, {a: 2}],
};
@@ -2,28 +2,58 @@
## Input
```javascript
function component(a) {
import {mutate, Stringify} from 'shared-runtime';
function Component({a}) {
let z = {a};
let x = function () {
let z;
mutate(z);
return z;
};
return x;
return <Stringify fn={x} shouldInvokeFns={true} />;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 1}],
sequentialRenders: [{a: 1}, {a: 1}, {a: 2}],
};
```
## Code
```javascript
function component(a) {
import { c as _c } from "react/compiler-runtime";
import { mutate, Stringify } from "shared-runtime";
function Component(t0) {
const $ = _c(1);
const x = _temp;
return x;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = <Stringify fn={x} shouldInvokeFns={true} />;
$[0] = t1;
} else {
t1 = $[0];
}
return t1;
}
function _temp() {
let z_0;
mutate(z_0);
return z_0;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ a: 1 }],
sequentialRenders: [{ a: 1 }, { a: 1 }, { a: 2 }],
};
```
### Eval output
(kind: ok) <div>{"fn":{"kind":"Function"},"shouldInvokeFns":true}</div>
<div>{"fn":{"kind":"Function"},"shouldInvokeFns":true}</div>
<div>{"fn":{"kind":"Function"},"shouldInvokeFns":true}</div>
@@ -1,8 +1,16 @@
function component(a) {
import {mutate, Stringify} from 'shared-runtime';
function Component({a}) {
let z = {a};
let x = function () {
let z;
mutate(z);
return z;
};
return x;
return <Stringify fn={x} shouldInvokeFns={true} />;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 1}],
sequentialRenders: [{a: 1}, {a: 1}, {a: 2}],
};
@@ -2,7 +2,8 @@
## Input
```javascript
function component(a) {
import {mutate} from 'shared-runtime';
function Component({a}) {
let x = {a};
let y = 1;
(function () {
@@ -12,14 +13,22 @@ function component(a) {
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2}],
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
};
```
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
function component(a) {
import { mutate } from "shared-runtime";
function Component(t0) {
const $ = _c(2);
const { a } = t0;
let y;
if ($[0] !== a) {
const x = { a };
@@ -36,5 +45,15 @@ function component(a) {
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ a: 2 }],
sequentialRenders: [{ a: 2 }, { a: 2 }, { a: 3 }],
};
```
### Eval output
(kind: ok) {"a":2,"wat0":"joe"}
{"a":2,"wat0":"joe"}
{"a":3,"wat0":"joe"}
@@ -1,4 +1,5 @@
function component(a) {
import {mutate} from 'shared-runtime';
function Component({a}) {
let x = {a};
let y = 1;
(function () {
@@ -7,3 +8,9 @@ function component(a) {
mutate(y);
return y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2}],
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
};
@@ -2,7 +2,8 @@
## Input
```javascript
function component(a, b) {
import {mutate} from 'shared-runtime';
function useHook({a, b}) {
let y = {a};
let x = {b};
x['y'] = y;
@@ -10,14 +11,26 @@ function component(a, b) {
return x;
}
export const FIXTURE_ENTRYPOINT = {
fn: useHook,
params: [{a: 2, b: 3}],
sequentialRenders: [
{a: 2, b: 3},
{a: 2, b: 3},
{a: 3, b: 3},
],
};
```
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
function component(a, b) {
import { mutate } from "shared-runtime";
function useHook(t0) {
const $ = _c(3);
const { a, b } = t0;
let x;
if ($[0] !== a || $[1] !== b) {
const y = { a };
@@ -33,5 +46,19 @@ function component(a, b) {
return x;
}
export const FIXTURE_ENTRYPOINT = {
fn: useHook,
params: [{ a: 2, b: 3 }],
sequentialRenders: [
{ a: 2, b: 3 },
{ a: 2, b: 3 },
{ a: 3, b: 3 },
],
};
```
### Eval output
(kind: ok) {"b":3,"y":{"a":2},"wat0":"joe"}
{"b":3,"y":{"a":2},"wat0":"joe"}
{"b":3,"y":{"a":3},"wat0":"joe"}
@@ -1,7 +1,18 @@
function component(a, b) {
import {mutate} from 'shared-runtime';
function useHook({a, b}) {
let y = {a};
let x = {b};
x['y'] = y;
mutate(x);
return x;
}
export const FIXTURE_ENTRYPOINT = {
fn: useHook,
params: [{a: 2, b: 3}],
sequentialRenders: [
{a: 2, b: 3},
{a: 2, b: 3},
{a: 3, b: 3},
],
};
@@ -2,27 +2,37 @@
## Input
```javascript
import {Stringify, identity} from 'shared-runtime';
function Component(props) {
const x = 42;
const onEvent = () => {
console.log(x);
return identity(x);
};
return <Foo onEvent={onEvent} />;
return <Stringify onEvent={onEvent} shouldInvokeFns={true} />;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{}],
sequentialRenders: [{}, {}],
};
```
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
import { Stringify, identity } from "shared-runtime";
function Component(props) {
const $ = _c(1);
const onEvent = _temp;
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = <Foo onEvent={onEvent} />;
t0 = <Stringify onEvent={onEvent} shouldInvokeFns={true} />;
$[0] = t0;
} else {
t0 = $[0];
@@ -30,8 +40,17 @@ function Component(props) {
return t0;
}
function _temp() {
console.log(42);
return identity(42);
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{}],
sequentialRenders: [{}, {}],
};
```
### Eval output
(kind: ok) <div>{"onEvent":{"kind":"Function","result":42},"shouldInvokeFns":true}</div>
<div>{"onEvent":{"kind":"Function","result":42},"shouldInvokeFns":true}</div>
@@ -1,7 +1,15 @@
import {Stringify, identity} from 'shared-runtime';
function Component(props) {
const x = 42;
const onEvent = () => {
console.log(x);
return identity(x);
};
return <Foo onEvent={onEvent} />;
return <Stringify onEvent={onEvent} shouldInvokeFns={true} />;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{}],
sequentialRenders: [{}, {}],
};
@@ -90,4 +90,6 @@ export const FIXTURE_ENTRYPOINT = {
};
```
### Eval output
(kind: ok) <div>{"shouldInvokeFns":true,"callback":{"kind":"Function","result":null}}</div>
@@ -85,4 +85,7 @@ export const FIXTURE_ENTRYPOINT = {
};
```
### Eval output
(kind: ok) {}
[[ (exception in render) TypeError: Cannot read properties of null (reading 'title_text') ]]
@@ -70,4 +70,8 @@ export const FIXTURE_ENTRYPOINT = {
};
```
### Eval output
(kind: ok) [[ (exception in render) TypeError: Cannot read properties of null (reading 'b') ]]
<div>{"fn":{"kind":"Function","result":null},"shouldInvokeFns":true}</div>
<div>{"fn":{"kind":"Function","result":4},"shouldInvokeFns":true}</div>
+3 -27
View File
@@ -229,31 +229,15 @@ const skipFilter = new Set([
'builtin-jsx-tag-lowered-between-mutations',
'call-args-assignment',
'call-args-destructuring-assignment',
'call-spread',
'call-with-independently-memoizable-arg',
'capture-param-mutate',
'capturing-fun-alias-captured-mutate-2',
'capturing-fun-alias-captured-mutate-arr-2',
'capturing-func-alias-captured-mutate-arr',
'capturing-func-alias-computed-mutate',
'capturing-func-alias-mutate',
'capturing-func-alias-receiver-computed-mutate',
'capturing-func-alias-receiver-mutate',
'capturing-func-simple-alias',
'capturing-function-capture-ref-before-rename',
'capturing-function-conditional-capture-mutate',
'capturing-function-member-expr-arguments',
'capturing-function-member-expr-call',
'capturing-function-renamed-ref',
'capturing-function-runs-inference',
'capturing-function-shadow-captured',
'capturing-reference-changes-type',
'codegen-emit-imports-same-source',
'codegen-emit-make-read-only',
'computed-call-spread',
'computed-load-primitive-as-dependency',
'computed-store-alias',
'constant-propagation-into-function-expressions',
'destructuring-mixed-scope-declarations-and-locals',
'destructuring-property-inference',
'do-while-conditional-break',
@@ -477,23 +461,15 @@ const skipFilter = new Set([
'invalid-jsx-lowercase-localvar',
// bugs
'fbt/bug-fbt-plural-multiple-function-calls',
'fbt/bug-fbt-plural-multiple-mixed-call-tag',
`bug-capturing-func-maybealias-captured-mutate`,
'bug-object-expression-computed-key-modified-during-after-construction-hoisted-sequence-expr',
'bug-invalid-hoisting-functionexpr',
`bug-capturing-func-maybealias-captured-mutate`,
'bug-aliased-capture-aliased-mutate',
'bug-aliased-capture-mutate',
'bug-functiondecl-hoisting',
'bug-try-catch-maybe-null-dependency',
'bug-invalid-mixedreadonly-map-shape',
'bug-type-inference-control-flow',
'reduce-reactive-deps/bug-infer-function-cond-access-not-hoisted',
'fbt/bug-fbt-plural-multiple-function-calls',
'fbt/bug-fbt-plural-multiple-mixed-call-tag',
'bug-invalid-phi-as-dependency',
'reduce-reactive-deps/bug-merge-uncond-optional-chain-and-cond',
'original-reactive-scopes-fork/bug-nonmutating-capture-in-unsplittable-memo-block',
'original-reactive-scopes-fork/bug-hoisted-declaration-with-scope',
'bug-codegen-inline-iife',
// 'react-compiler-runtime' not yet supported
'flag-enable-emit-hook-guards',