Skip to content

Commit 7ce2a63

Browse files
authored
[compiler] update fixtures (#33573)
--- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33573). * #33571 * #33558 * #33547 * #33543 * #33533 * #33532 * #33530 * #33526 * #33522 * #33518 * #33514 * __->__ #33573
1 parent b067c6f commit 7ce2a63

File tree

4 files changed

+140
-176
lines changed

4 files changed

+140
-176
lines changed

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/array-map-named-callback-cross-context.expect.md

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -57,67 +57,62 @@ import { Stringify } from "shared-runtime";
5757
* - cb1 is not assumed to be called since it's only used as a call operand
5858
*/
5959
function useFoo(t0) {
60-
const $ = _c(14);
61-
let arr1;
62-
let arr2;
60+
const $ = _c(13);
61+
const { arr1, arr2 } = t0;
6362
let t1;
64-
if ($[0] !== t0) {
65-
({ arr1, arr2 } = t0);
66-
let t2;
67-
if ($[4] !== arr1[0]) {
68-
t2 = (e) => arr1[0].value + e.value;
69-
$[4] = arr1[0];
70-
$[5] = t2;
71-
} else {
72-
t2 = $[5];
73-
}
74-
const cb1 = t2;
75-
t1 = () => arr1.map(cb1);
76-
$[0] = t0;
77-
$[1] = arr1;
78-
$[2] = arr2;
79-
$[3] = t1;
63+
if ($[0] !== arr1[0]) {
64+
t1 = (e) => arr1[0].value + e.value;
65+
$[0] = arr1[0];
66+
$[1] = t1;
8067
} else {
81-
arr1 = $[1];
82-
arr2 = $[2];
83-
t1 = $[3];
68+
t1 = $[1];
8469
}
85-
const getArrMap1 = t1;
70+
const cb1 = t1;
8671
let t2;
87-
if ($[6] !== arr2) {
88-
t2 = (e_0) => arr2[0].value + e_0.value;
89-
$[6] = arr2;
90-
$[7] = t2;
72+
if ($[2] !== arr1 || $[3] !== cb1) {
73+
t2 = () => arr1.map(cb1);
74+
$[2] = arr1;
75+
$[3] = cb1;
76+
$[4] = t2;
9177
} else {
92-
t2 = $[7];
78+
t2 = $[4];
9379
}
94-
const cb2 = t2;
80+
const getArrMap1 = t2;
9581
let t3;
96-
if ($[8] !== arr1 || $[9] !== cb2) {
97-
t3 = () => arr1.map(cb2);
98-
$[8] = arr1;
99-
$[9] = cb2;
100-
$[10] = t3;
82+
if ($[5] !== arr2) {
83+
t3 = (e_0) => arr2[0].value + e_0.value;
84+
$[5] = arr2;
85+
$[6] = t3;
10186
} else {
102-
t3 = $[10];
87+
t3 = $[6];
10388
}
104-
const getArrMap2 = t3;
89+
const cb2 = t3;
10590
let t4;
106-
if ($[11] !== getArrMap1 || $[12] !== getArrMap2) {
107-
t4 = (
91+
if ($[7] !== arr1 || $[8] !== cb2) {
92+
t4 = () => arr1.map(cb2);
93+
$[7] = arr1;
94+
$[8] = cb2;
95+
$[9] = t4;
96+
} else {
97+
t4 = $[9];
98+
}
99+
const getArrMap2 = t4;
100+
let t5;
101+
if ($[10] !== getArrMap1 || $[11] !== getArrMap2) {
102+
t5 = (
108103
<Stringify
109104
getArrMap1={getArrMap1}
110105
getArrMap2={getArrMap2}
111106
shouldInvokeFns={true}
112107
/>
113108
);
114-
$[11] = getArrMap1;
115-
$[12] = getArrMap2;
116-
$[13] = t4;
109+
$[10] = getArrMap1;
110+
$[11] = getArrMap2;
111+
$[12] = t5;
117112
} else {
118-
t4 = $[13];
113+
t5 = $[12];
119114
}
120-
return t4;
115+
return t5;
121116
}
122117

123118
export const FIXTURE_ENTRYPOINT = {

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/array-map-named-callback-cross-context.expect.md

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -58,67 +58,62 @@ import { Stringify } from "shared-runtime";
5858
* - cb1 is not assumed to be called since it's only used as a call operand
5959
*/
6060
function useFoo(t0) {
61-
const $ = _c(14);
62-
let arr1;
63-
let arr2;
61+
const $ = _c(13);
62+
const { arr1, arr2 } = t0;
6463
let t1;
65-
if ($[0] !== t0) {
66-
({ arr1, arr2 } = t0);
67-
let t2;
68-
if ($[4] !== arr1[0]) {
69-
t2 = (e) => arr1[0].value + e.value;
70-
$[4] = arr1[0];
71-
$[5] = t2;
72-
} else {
73-
t2 = $[5];
74-
}
75-
const cb1 = t2;
76-
t1 = () => arr1.map(cb1);
77-
$[0] = t0;
78-
$[1] = arr1;
79-
$[2] = arr2;
80-
$[3] = t1;
64+
if ($[0] !== arr1[0]) {
65+
t1 = (e) => arr1[0].value + e.value;
66+
$[0] = arr1[0];
67+
$[1] = t1;
8168
} else {
82-
arr1 = $[1];
83-
arr2 = $[2];
84-
t1 = $[3];
69+
t1 = $[1];
8570
}
86-
const getArrMap1 = t1;
71+
const cb1 = t1;
8772
let t2;
88-
if ($[6] !== arr2) {
89-
t2 = (e_0) => arr2[0].value + e_0.value;
90-
$[6] = arr2;
91-
$[7] = t2;
73+
if ($[2] !== arr1 || $[3] !== cb1) {
74+
t2 = () => arr1.map(cb1);
75+
$[2] = arr1;
76+
$[3] = cb1;
77+
$[4] = t2;
9278
} else {
93-
t2 = $[7];
79+
t2 = $[4];
9480
}
95-
const cb2 = t2;
81+
const getArrMap1 = t2;
9682
let t3;
97-
if ($[8] !== arr1 || $[9] !== cb2) {
98-
t3 = () => arr1.map(cb2);
99-
$[8] = arr1;
100-
$[9] = cb2;
101-
$[10] = t3;
83+
if ($[5] !== arr2) {
84+
t3 = (e_0) => arr2[0].value + e_0.value;
85+
$[5] = arr2;
86+
$[6] = t3;
10287
} else {
103-
t3 = $[10];
88+
t3 = $[6];
10489
}
105-
const getArrMap2 = t3;
90+
const cb2 = t3;
10691
let t4;
107-
if ($[11] !== getArrMap1 || $[12] !== getArrMap2) {
108-
t4 = (
92+
if ($[7] !== arr1 || $[8] !== cb2) {
93+
t4 = () => arr1.map(cb2);
94+
$[7] = arr1;
95+
$[8] = cb2;
96+
$[9] = t4;
97+
} else {
98+
t4 = $[9];
99+
}
100+
const getArrMap2 = t4;
101+
let t5;
102+
if ($[10] !== getArrMap1 || $[11] !== getArrMap2) {
103+
t5 = (
109104
<Stringify
110105
getArrMap1={getArrMap1}
111106
getArrMap2={getArrMap2}
112107
shouldInvokeFns={true}
113108
/>
114109
);
115-
$[11] = getArrMap1;
116-
$[12] = getArrMap2;
117-
$[13] = t4;
110+
$[10] = getArrMap1;
111+
$[11] = getArrMap2;
112+
$[12] = t5;
118113
} else {
119-
t4 = $[13];
114+
t5 = $[12];
120115
}
121-
return t4;
116+
return t5;
122117
}
123118

124119
export const FIXTURE_ENTRYPOINT = {

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/shared-hook-calls.expect.md

Lines changed: 32 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -30,60 +30,47 @@ import { c as _c, useFire } from "react/compiler-runtime"; // @enableFire @enabl
3030
import { fire } from "react";
3131

3232
function Component(t0) {
33-
const $ = _c(13);
34-
let bar;
35-
let baz;
36-
let foo;
37-
if ($[0] !== t0) {
38-
({ bar, baz } = t0);
39-
let t1;
40-
if ($[4] !== bar) {
41-
t1 = () => {
42-
console.log(bar);
43-
};
44-
$[4] = bar;
45-
$[5] = t1;
46-
} else {
47-
t1 = $[5];
48-
}
49-
foo = t1;
50-
$[0] = t0;
51-
$[1] = bar;
52-
$[2] = baz;
53-
$[3] = foo;
54-
} else {
55-
bar = $[1];
56-
baz = $[2];
57-
foo = $[3];
58-
}
59-
const t1 = useFire(foo);
60-
const t2 = useFire(baz);
61-
let t3;
62-
if ($[6] !== bar || $[7] !== t1 || $[8] !== t2) {
63-
t3 = () => {
64-
t1(bar);
65-
t2(bar);
33+
const $ = _c(9);
34+
const { bar, baz } = t0;
35+
let t1;
36+
if ($[0] !== bar) {
37+
t1 = () => {
38+
console.log(bar);
6639
};
67-
$[6] = bar;
68-
$[7] = t1;
69-
$[8] = t2;
70-
$[9] = t3;
40+
$[0] = bar;
41+
$[1] = t1;
7142
} else {
72-
t3 = $[9];
43+
t1 = $[1];
7344
}
74-
useEffect(t3);
45+
const foo = t1;
46+
const t2 = useFire(foo);
47+
const t3 = useFire(baz);
7548
let t4;
76-
if ($[10] !== bar || $[11] !== t1) {
49+
if ($[2] !== bar || $[3] !== t2 || $[4] !== t3) {
7750
t4 = () => {
78-
t1(bar);
51+
t2(bar);
52+
t3(bar);
7953
};
80-
$[10] = bar;
81-
$[11] = t1;
82-
$[12] = t4;
54+
$[2] = bar;
55+
$[3] = t2;
56+
$[4] = t3;
57+
$[5] = t4;
8358
} else {
84-
t4 = $[12];
59+
t4 = $[5];
8560
}
8661
useEffect(t4);
62+
let t5;
63+
if ($[6] !== bar || $[7] !== t2) {
64+
t5 = () => {
65+
t2(bar);
66+
};
67+
$[6] = bar;
68+
$[7] = t2;
69+
$[8] = t5;
70+
} else {
71+
t5 = $[8];
72+
}
73+
useEffect(t5);
8774
return null;
8875
}
8976

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/shared-hook-calls.expect.md

Lines changed: 32 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -30,60 +30,47 @@ import { c as _c, useFire } from "react/compiler-runtime"; // @enableFire
3030
import { fire } from "react";
3131

3232
function Component(t0) {
33-
const $ = _c(13);
34-
let bar;
35-
let baz;
36-
let foo;
37-
if ($[0] !== t0) {
38-
({ bar, baz } = t0);
39-
let t1;
40-
if ($[4] !== bar) {
41-
t1 = () => {
42-
console.log(bar);
43-
};
44-
$[4] = bar;
45-
$[5] = t1;
46-
} else {
47-
t1 = $[5];
48-
}
49-
foo = t1;
50-
$[0] = t0;
51-
$[1] = bar;
52-
$[2] = baz;
53-
$[3] = foo;
54-
} else {
55-
bar = $[1];
56-
baz = $[2];
57-
foo = $[3];
58-
}
59-
const t1 = useFire(foo);
60-
const t2 = useFire(baz);
61-
let t3;
62-
if ($[6] !== bar || $[7] !== t1 || $[8] !== t2) {
63-
t3 = () => {
64-
t1(bar);
65-
t2(bar);
33+
const $ = _c(9);
34+
const { bar, baz } = t0;
35+
let t1;
36+
if ($[0] !== bar) {
37+
t1 = () => {
38+
console.log(bar);
6639
};
67-
$[6] = bar;
68-
$[7] = t1;
69-
$[8] = t2;
70-
$[9] = t3;
40+
$[0] = bar;
41+
$[1] = t1;
7142
} else {
72-
t3 = $[9];
43+
t1 = $[1];
7344
}
74-
useEffect(t3);
45+
const foo = t1;
46+
const t2 = useFire(foo);
47+
const t3 = useFire(baz);
7548
let t4;
76-
if ($[10] !== bar || $[11] !== t1) {
49+
if ($[2] !== bar || $[3] !== t2 || $[4] !== t3) {
7750
t4 = () => {
78-
t1(bar);
51+
t2(bar);
52+
t3(bar);
7953
};
80-
$[10] = bar;
81-
$[11] = t1;
82-
$[12] = t4;
54+
$[2] = bar;
55+
$[3] = t2;
56+
$[4] = t3;
57+
$[5] = t4;
8358
} else {
84-
t4 = $[12];
59+
t4 = $[5];
8560
}
8661
useEffect(t4);
62+
let t5;
63+
if ($[6] !== bar || $[7] !== t2) {
64+
t5 = () => {
65+
t2(bar);
66+
};
67+
$[6] = bar;
68+
$[7] = t2;
69+
$[8] = t5;
70+
} else {
71+
t5 = $[8];
72+
}
73+
useEffect(t5);
8774
return null;
8875
}
8976

0 commit comments

Comments
 (0)