Skip to content

Commit 86b1913

Browse files
authored
[compiler][be] Clean up bug test fixtures; evaluate more fixtures (#31812)
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
1 parent a9575dc commit 86b1913

File tree

43 files changed

+664
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+664
-139
lines changed

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/call-spread.expect.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,31 @@
22
## Input
33

44
```javascript
5+
import {makeArray} from 'shared-runtime';
6+
57
function Component(props) {
6-
const x = foo(...props.a, null, ...props.b);
8+
const x = makeArray(...props.a, null, ...props.b);
79
return x;
810
}
911

12+
export const FIXTURE_ENTRYPOINT = {
13+
fn: Component,
14+
params: [{a: [1, 2], b: [2, 3, 4]}],
15+
};
16+
1017
```
1118

1219
## Code
1320

1421
```javascript
1522
import { c as _c } from "react/compiler-runtime";
23+
import { makeArray } from "shared-runtime";
24+
1625
function Component(props) {
1726
const $ = _c(3);
1827
let t0;
1928
if ($[0] !== props.a || $[1] !== props.b) {
20-
t0 = foo(...props.a, null, ...props.b);
29+
t0 = makeArray(...props.a, null, ...props.b);
2130
$[0] = props.a;
2231
$[1] = props.b;
2332
$[2] = t0;
@@ -28,5 +37,12 @@ function Component(props) {
2837
return x;
2938
}
3039

40+
export const FIXTURE_ENTRYPOINT = {
41+
fn: Component,
42+
params: [{ a: [1, 2], b: [2, 3, 4] }],
43+
};
44+
3145
```
32-
46+
47+
### Eval output
48+
(kind: ok) [1,2,null,2,3,4]
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
import {makeArray} from 'shared-runtime';
2+
13
function Component(props) {
2-
const x = foo(...props.a, null, ...props.b);
4+
const x = makeArray(...props.a, null, ...props.b);
35
return x;
46
}
7+
8+
export const FIXTURE_ENTRYPOINT = {
9+
fn: Component,
10+
params: [{a: [1, 2], b: [2, 3, 4]}],
11+
};

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.expect.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
## Input
33

44
```javascript
5-
function component(foo, bar) {
5+
import {mutate} from 'shared-runtime';
6+
7+
function Component({foo, bar}) {
68
let x = {foo};
79
let y = {bar};
810
const f0 = function () {
@@ -15,14 +17,28 @@ function component(foo, bar) {
1517
return x;
1618
}
1719

20+
export const FIXTURE_ENTRYPOINT = {
21+
fn: Component,
22+
params: [{foo: 2, bar: 3}],
23+
sequentialRenders: [
24+
{foo: 2, bar: 3},
25+
{foo: 2, bar: 3},
26+
{foo: 2, bar: 4},
27+
{foo: 3, bar: 4},
28+
],
29+
};
30+
1831
```
1932

2033
## Code
2134

2235
```javascript
2336
import { c as _c } from "react/compiler-runtime";
24-
function component(foo, bar) {
37+
import { mutate } from "shared-runtime";
38+
39+
function Component(t0) {
2540
const $ = _c(3);
41+
const { foo, bar } = t0;
2642
let x;
2743
if ($[0] !== bar || $[1] !== foo) {
2844
x = { foo };
@@ -44,5 +60,21 @@ function component(foo, bar) {
4460
return x;
4561
}
4662

63+
export const FIXTURE_ENTRYPOINT = {
64+
fn: Component,
65+
params: [{ foo: 2, bar: 3 }],
66+
sequentialRenders: [
67+
{ foo: 2, bar: 3 },
68+
{ foo: 2, bar: 3 },
69+
{ foo: 2, bar: 4 },
70+
{ foo: 3, bar: 4 },
71+
],
72+
};
73+
4774
```
48-
75+
76+
### Eval output
77+
(kind: ok) {"foo":2}
78+
{"foo":2}
79+
{"foo":2}
80+
{"foo":3}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
function component(foo, bar) {
1+
import {mutate} from 'shared-runtime';
2+
3+
function Component({foo, bar}) {
24
let x = {foo};
35
let y = {bar};
46
const f0 = function () {
@@ -10,3 +12,14 @@ function component(foo, bar) {
1012
mutate(y);
1113
return x;
1214
}
15+
16+
export const FIXTURE_ENTRYPOINT = {
17+
fn: Component,
18+
params: [{foo: 2, bar: 3}],
19+
sequentialRenders: [
20+
{foo: 2, bar: 3},
21+
{foo: 2, bar: 3},
22+
{foo: 2, bar: 4},
23+
{foo: 3, bar: 4},
24+
],
25+
};

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.expect.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
## Input
33

44
```javascript
5-
function component(foo, bar) {
5+
import {mutate} from 'shared-runtime';
6+
7+
function Component({foo, bar}) {
68
let x = {foo};
79
let y = {bar};
810
const f0 = function () {
@@ -15,14 +17,28 @@ function component(foo, bar) {
1517
return x;
1618
}
1719

20+
export const FIXTURE_ENTRYPOINT = {
21+
fn: Component,
22+
params: [{foo: 2, bar: 3}],
23+
sequentialRenders: [
24+
{foo: 2, bar: 3},
25+
{foo: 2, bar: 3},
26+
{foo: 2, bar: 4},
27+
{foo: 3, bar: 4},
28+
],
29+
};
30+
1831
```
1932

2033
## Code
2134

2235
```javascript
2336
import { c as _c } from "react/compiler-runtime";
24-
function component(foo, bar) {
37+
import { mutate } from "shared-runtime";
38+
39+
function Component(t0) {
2540
const $ = _c(3);
41+
const { foo, bar } = t0;
2642
let x;
2743
if ($[0] !== bar || $[1] !== foo) {
2844
x = { foo };
@@ -44,5 +60,21 @@ function component(foo, bar) {
4460
return x;
4561
}
4662

63+
export const FIXTURE_ENTRYPOINT = {
64+
fn: Component,
65+
params: [{ foo: 2, bar: 3 }],
66+
sequentialRenders: [
67+
{ foo: 2, bar: 3 },
68+
{ foo: 2, bar: 3 },
69+
{ foo: 2, bar: 4 },
70+
{ foo: 3, bar: 4 },
71+
],
72+
};
73+
4774
```
48-
75+
76+
### Eval output
77+
(kind: ok) {"foo":2}
78+
{"foo":2}
79+
{"foo":2}
80+
{"foo":3}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
function component(foo, bar) {
1+
import {mutate} from 'shared-runtime';
2+
3+
function Component({foo, bar}) {
24
let x = {foo};
35
let y = {bar};
46
const f0 = function () {
@@ -10,3 +12,14 @@ function component(foo, bar) {
1012
mutate(y);
1113
return x;
1214
}
15+
16+
export const FIXTURE_ENTRYPOINT = {
17+
fn: Component,
18+
params: [{foo: 2, bar: 3}],
19+
sequentialRenders: [
20+
{foo: 2, bar: 3},
21+
{foo: 2, bar: 3},
22+
{foo: 2, bar: 4},
23+
{foo: 3, bar: 4},
24+
],
25+
};

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.expect.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
## Input
33

44
```javascript
5-
function component(foo, bar) {
5+
import {mutate} from 'shared-runtime';
6+
function Component({foo, bar}) {
67
let x = {foo};
78
let y = {bar};
89
const f0 = function () {
@@ -15,14 +16,27 @@ function component(foo, bar) {
1516
return y;
1617
}
1718

19+
export const FIXTURE_ENTRYPOINT = {
20+
fn: Component,
21+
params: [{foo: 2, bar: 3}],
22+
sequentialRenders: [
23+
{foo: 2, bar: 3},
24+
{foo: 2, bar: 3},
25+
{foo: 2, bar: 4},
26+
{foo: 3, bar: 4},
27+
],
28+
};
29+
1830
```
1931

2032
## Code
2133

2234
```javascript
2335
import { c as _c } from "react/compiler-runtime";
24-
function component(foo, bar) {
36+
import { mutate } from "shared-runtime";
37+
function Component(t0) {
2538
const $ = _c(3);
39+
const { foo, bar } = t0;
2640
let y;
2741
if ($[0] !== bar || $[1] !== foo) {
2842
const x = { foo };
@@ -44,5 +58,21 @@ function component(foo, bar) {
4458
return y;
4559
}
4660

61+
export const FIXTURE_ENTRYPOINT = {
62+
fn: Component,
63+
params: [{ foo: 2, bar: 3 }],
64+
sequentialRenders: [
65+
{ foo: 2, bar: 3 },
66+
{ foo: 2, bar: 3 },
67+
{ foo: 2, bar: 4 },
68+
{ foo: 3, bar: 4 },
69+
],
70+
};
71+
4772
```
48-
73+
74+
### Eval output
75+
(kind: ok) {"bar":3,"wat0":"joe"}
76+
{"bar":3,"wat0":"joe"}
77+
{"bar":4,"wat0":"joe"}
78+
{"bar":4,"wat0":"joe"}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
function component(foo, bar) {
1+
import {mutate} from 'shared-runtime';
2+
function Component({foo, bar}) {
23
let x = {foo};
34
let y = {bar};
45
const f0 = function () {
@@ -10,3 +11,14 @@ function component(foo, bar) {
1011
mutate(y);
1112
return y;
1213
}
14+
15+
export const FIXTURE_ENTRYPOINT = {
16+
fn: Component,
17+
params: [{foo: 2, bar: 3}],
18+
sequentialRenders: [
19+
{foo: 2, bar: 3},
20+
{foo: 2, bar: 3},
21+
{foo: 2, bar: 4},
22+
{foo: 3, bar: 4},
23+
],
24+
};

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.expect.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
## Input
33

44
```javascript
5-
function component(a) {
5+
import {mutate} from 'shared-runtime';
6+
function Component({a}) {
67
let x = {a};
78
let y = {};
89
const f0 = function () {
@@ -13,14 +14,22 @@ function component(a) {
1314
return y;
1415
}
1516

17+
export const FIXTURE_ENTRYPOINT = {
18+
fn: Component,
19+
params: [{a: 2}],
20+
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
21+
};
22+
1623
```
1724

1825
## Code
1926

2027
```javascript
2128
import { c as _c } from "react/compiler-runtime";
22-
function component(a) {
29+
import { mutate } from "shared-runtime";
30+
function Component(t0) {
2331
const $ = _c(2);
32+
const { a } = t0;
2433
let y;
2534
if ($[0] !== a) {
2635
const x = { a };
@@ -39,5 +48,15 @@ function component(a) {
3948
return y;
4049
}
4150

51+
export const FIXTURE_ENTRYPOINT = {
52+
fn: Component,
53+
params: [{ a: 2 }],
54+
sequentialRenders: [{ a: 2 }, { a: 2 }, { a: 3 }],
55+
};
56+
4257
```
43-
58+
59+
### Eval output
60+
(kind: ok) {"x":{"a":2},"wat0":"joe"}
61+
{"x":{"a":2},"wat0":"joe"}
62+
{"x":{"a":3},"wat0":"joe"}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
function component(a) {
1+
import {mutate} from 'shared-runtime';
2+
function Component({a}) {
23
let x = {a};
34
let y = {};
45
const f0 = function () {
@@ -8,3 +9,9 @@ function component(a) {
89
mutate(y);
910
return y;
1011
}
12+
13+
export const FIXTURE_ENTRYPOINT = {
14+
fn: Component,
15+
params: [{a: 2}],
16+
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
17+
};

0 commit comments

Comments
 (0)