Skip to content

Commit 1a77920

Browse files
committed
[compiler][test fixtures] Add enablePropagateDepsInHIR to forked tests
Annotates fixtures added in #31030 with `@enablePropagateDepsInHIR` to fork behavior (and commit snapshot differences) ghstack-source-id: e423e8c Pull Request resolved: #31031
1 parent 943e45e commit 1a77920

28 files changed

+210
-124
lines changed

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-break-labeled.expect.md

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

44
```javascript
5+
// @enablePropagateDepsInHIR
56
/**
67
* props.b *does* influence `a`
78
*/
@@ -29,13 +30,19 @@ export const FIXTURE_ENTRYPOINT = {
2930
## Code
3031

3132
```javascript
32-
import { c as _c } from "react/compiler-runtime"; /**
33+
import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
34+
/**
3335
* props.b *does* influence `a`
3436
*/
3537
function Component(props) {
36-
const $ = _c(2);
38+
const $ = _c(5);
3739
let a;
38-
if ($[0] !== props) {
40+
if (
41+
$[0] !== props.a ||
42+
$[1] !== props.b ||
43+
$[2] !== props.c ||
44+
$[3] !== props.d
45+
) {
3946
a = [];
4047
a.push(props.a);
4148
bb0: {
@@ -47,10 +54,13 @@ function Component(props) {
4754
}
4855

4956
a.push(props.d);
50-
$[0] = props;
51-
$[1] = a;
57+
$[0] = props.a;
58+
$[1] = props.b;
59+
$[2] = props.c;
60+
$[3] = props.d;
61+
$[4] = a;
5262
} else {
53-
a = $[1];
63+
a = $[4];
5464
}
5565
return a;
5666
}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-break-labeled.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @enablePropagateDepsInHIR
12
/**
23
* props.b *does* influence `a`
34
*/

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-early-return.expect.md

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

44
```javascript
5+
// @enablePropagateDepsInHIR
56
/**
67
* props.b does *not* influence `a`
78
*/
@@ -66,14 +67,15 @@ export const FIXTURE_ENTRYPOINT = {
6667
## Code
6768

6869
```javascript
69-
import { c as _c } from "react/compiler-runtime"; /**
70+
import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
71+
/**
7072
* props.b does *not* influence `a`
7173
*/
7274
function ComponentA(props) {
73-
const $ = _c(3);
75+
const $ = _c(5);
7476
let a_DEBUG;
7577
let t0;
76-
if ($[0] !== props) {
78+
if ($[0] !== props.a || $[1] !== props.b || $[2] !== props.d) {
7779
t0 = Symbol.for("react.early_return_sentinel");
7880
bb0: {
7981
a_DEBUG = [];
@@ -85,12 +87,14 @@ function ComponentA(props) {
8587

8688
a_DEBUG.push(props.d);
8789
}
88-
$[0] = props;
89-
$[1] = a_DEBUG;
90-
$[2] = t0;
90+
$[0] = props.a;
91+
$[1] = props.b;
92+
$[2] = props.d;
93+
$[3] = a_DEBUG;
94+
$[4] = t0;
9195
} else {
92-
a_DEBUG = $[1];
93-
t0 = $[2];
96+
a_DEBUG = $[3];
97+
t0 = $[4];
9498
}
9599
if (t0 !== Symbol.for("react.early_return_sentinel")) {
96100
return t0;
@@ -102,20 +106,28 @@ function ComponentA(props) {
102106
* props.b *does* influence `a`
103107
*/
104108
function ComponentB(props) {
105-
const $ = _c(2);
109+
const $ = _c(5);
106110
let a;
107-
if ($[0] !== props) {
111+
if (
112+
$[0] !== props.a ||
113+
$[1] !== props.b ||
114+
$[2] !== props.c ||
115+
$[3] !== props.d
116+
) {
108117
a = [];
109118
a.push(props.a);
110119
if (props.b) {
111120
a.push(props.c);
112121
}
113122

114123
a.push(props.d);
115-
$[0] = props;
116-
$[1] = a;
124+
$[0] = props.a;
125+
$[1] = props.b;
126+
$[2] = props.c;
127+
$[3] = props.d;
128+
$[4] = a;
117129
} else {
118-
a = $[1];
130+
a = $[4];
119131
}
120132
return a;
121133
}
@@ -124,10 +136,15 @@ function ComponentB(props) {
124136
* props.b *does* influence `a`, but only in a way that is never observable
125137
*/
126138
function ComponentC(props) {
127-
const $ = _c(3);
139+
const $ = _c(6);
128140
let a;
129141
let t0;
130-
if ($[0] !== props) {
142+
if (
143+
$[0] !== props.a ||
144+
$[1] !== props.b ||
145+
$[2] !== props.c ||
146+
$[3] !== props.d
147+
) {
131148
t0 = Symbol.for("react.early_return_sentinel");
132149
bb0: {
133150
a = [];
@@ -140,12 +157,15 @@ function ComponentC(props) {
140157

141158
a.push(props.d);
142159
}
143-
$[0] = props;
144-
$[1] = a;
145-
$[2] = t0;
160+
$[0] = props.a;
161+
$[1] = props.b;
162+
$[2] = props.c;
163+
$[3] = props.d;
164+
$[4] = a;
165+
$[5] = t0;
146166
} else {
147-
a = $[1];
148-
t0 = $[2];
167+
a = $[4];
168+
t0 = $[5];
149169
}
150170
if (t0 !== Symbol.for("react.early_return_sentinel")) {
151171
return t0;
@@ -157,10 +177,15 @@ function ComponentC(props) {
157177
* props.b *does* influence `a`
158178
*/
159179
function ComponentD(props) {
160-
const $ = _c(3);
180+
const $ = _c(6);
161181
let a;
162182
let t0;
163-
if ($[0] !== props) {
183+
if (
184+
$[0] !== props.a ||
185+
$[1] !== props.b ||
186+
$[2] !== props.c ||
187+
$[3] !== props.d
188+
) {
164189
t0 = Symbol.for("react.early_return_sentinel");
165190
bb0: {
166191
a = [];
@@ -173,12 +198,15 @@ function ComponentD(props) {
173198

174199
a.push(props.d);
175200
}
176-
$[0] = props;
177-
$[1] = a;
178-
$[2] = t0;
201+
$[0] = props.a;
202+
$[1] = props.b;
203+
$[2] = props.c;
204+
$[3] = props.d;
205+
$[4] = a;
206+
$[5] = t0;
179207
} else {
180-
a = $[1];
181-
t0 = $[2];
208+
a = $[4];
209+
t0 = $[5];
182210
}
183211
if (t0 !== Symbol.for("react.early_return_sentinel")) {
184212
return t0;

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-early-return.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @enablePropagateDepsInHIR
12
/**
23
* props.b does *not* influence `a`
34
*/

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-on-mutable.expect.md

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

44
```javascript
5+
// @enablePropagateDepsInHIR
56
function ComponentA(props) {
67
const a = [];
78
const b = [];
@@ -34,11 +35,11 @@ function mayMutate() {}
3435
## Code
3536

3637
```javascript
37-
import { c as _c } from "react/compiler-runtime";
38+
import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
3839
function ComponentA(props) {
39-
const $ = _c(2);
40+
const $ = _c(4);
4041
let t0;
41-
if ($[0] !== props) {
42+
if ($[0] !== props.p0 || $[1] !== props.p1 || $[2] !== props.p2) {
4243
const a = [];
4344
const b = [];
4445
if (b) {
@@ -49,18 +50,20 @@ function ComponentA(props) {
4950
}
5051

5152
t0 = <Foo a={a} b={b} />;
52-
$[0] = props;
53-
$[1] = t0;
53+
$[0] = props.p0;
54+
$[1] = props.p1;
55+
$[2] = props.p2;
56+
$[3] = t0;
5457
} else {
55-
t0 = $[1];
58+
t0 = $[3];
5659
}
5760
return t0;
5861
}
5962

6063
function ComponentB(props) {
61-
const $ = _c(2);
64+
const $ = _c(4);
6265
let t0;
63-
if ($[0] !== props) {
66+
if ($[0] !== props.p0 || $[1] !== props.p1 || $[2] !== props.p2) {
6467
const a = [];
6568
const b = [];
6669
if (mayMutate(b)) {
@@ -71,10 +74,12 @@ function ComponentB(props) {
7174
}
7275

7376
t0 = <Foo a={a} b={b} />;
74-
$[0] = props;
75-
$[1] = t0;
77+
$[0] = props.p0;
78+
$[1] = props.p1;
79+
$[2] = props.p2;
80+
$[3] = t0;
7681
} else {
77-
t0 = $[1];
82+
t0 = $[3];
7883
}
7984
return t0;
8085
}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-on-mutable.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @enablePropagateDepsInHIR
12
function ComponentA(props) {
23
const a = [];
34
const b = [];

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/early-return-nested-early-return-within-reactive-scope.expect.md

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

44
```javascript
5+
// @enablePropagateDepsInHIR
56
function Component(props) {
67
let x = [];
78
if (props.cond) {
@@ -29,24 +30,24 @@ export const FIXTURE_ENTRYPOINT = {
2930
## Code
3031

3132
```javascript
32-
import { c as _c } from "react/compiler-runtime";
33+
import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
3334
function Component(props) {
34-
const $ = _c(5);
35+
const $ = _c(7);
3536
let t0;
36-
if ($[0] !== props) {
37+
if ($[0] !== props.cond || $[1] !== props.a || $[2] !== props.b) {
3738
t0 = Symbol.for("react.early_return_sentinel");
3839
bb0: {
3940
const x = [];
4041
if (props.cond) {
4142
x.push(props.a);
4243
if (props.b) {
4344
let t1;
44-
if ($[2] !== props.b) {
45+
if ($[4] !== props.b) {
4546
t1 = [props.b];
46-
$[2] = props.b;
47-
$[3] = t1;
47+
$[4] = props.b;
48+
$[5] = t1;
4849
} else {
49-
t1 = $[3];
50+
t1 = $[5];
5051
}
5152
const y = t1;
5253
x.push(y);
@@ -58,20 +59,22 @@ function Component(props) {
5859
break bb0;
5960
} else {
6061
let t1;
61-
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
62+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
6263
t1 = foo();
63-
$[4] = t1;
64+
$[6] = t1;
6465
} else {
65-
t1 = $[4];
66+
t1 = $[6];
6667
}
6768
t0 = t1;
6869
break bb0;
6970
}
7071
}
71-
$[0] = props;
72-
$[1] = t0;
72+
$[0] = props.cond;
73+
$[1] = props.a;
74+
$[2] = props.b;
75+
$[3] = t0;
7376
} else {
74-
t0 = $[1];
77+
t0 = $[3];
7578
}
7679
if (t0 !== Symbol.for("react.early_return_sentinel")) {
7780
return t0;

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/early-return-nested-early-return-within-reactive-scope.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @enablePropagateDepsInHIR
12
function Component(props) {
23
let x = [];
34
if (props.cond) {

0 commit comments

Comments
 (0)