[compiler][ez] Move compiler gating tests (#32595)
Move all gating tests to `gating/` --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32595). * #32596 * __->__ #32595 * #32594 * #32593 * #32522 * #32521
mofeiZ committed
Mar 13, 2025 at 12:06 UTC
1c79cb82ab8d3bd1f099115704f28df1097beb46
44 files changed
+402
-166
compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts
+1
-1
@@ -663,7 +663,7 @@ const testComplexConfigDefaults: PartialEnvironmentConfig = {
663
source: 'react-compiler-runtime',
664
importSpecifierName: 'shouldInstrument',
665
},
666
- globalGating: '__DEV__',
666
+ globalGating: 'DEV',
667
},
668
enableEmitHookGuards: {
669
source: 'react-compiler-runtime',
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/arrow-function-expr-gating-test.expect.md
deleted
-35
@@ -1,35 +0,0 @@
1
-
2
-## Input
3
-
4
-```javascript
5
-// @gating
6
-const ErrorView = (error, _retry) => <MessageBox error={error}></MessageBox>;
7
-
8
-export default ErrorView;
9
-
10
-```
11
-
12
-## Code
13
-
14
-```javascript
15
-import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
16
-import { c as _c } from "react/compiler-runtime"; // @gating
17
-const ErrorView = isForgetEnabled_Fixtures()
18
- ? (error, _retry) => {
19
- const $ = _c(2);
20
- let t0;
21
- if ($[0] !== error) {
22
- t0 = <MessageBox error={error} />;
23
- $[0] = error;
24
- $[1] = t0;
25
- } else {
26
- t0 = $[1];
27
- }
28
- return t0;
29
- }
30
- : (error, _retry) => <MessageBox error={error}></MessageBox>;
31
-
32
-export default ErrorView;
33
-
34
-```
35
-
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/arrow-function-expr-gating-test.js
deleted
-4
@@ -1,4 +0,0 @@
1
-// @gating
2
-const ErrorView = (error, _retry) => <MessageBox error={error}></MessageBox>;
3
-
4
-export default ErrorView;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/codegen-emit-imports-same-source.expect.md
+1
-1
@@ -21,7 +21,7 @@ import {
21
import { c as _c } from "react/compiler-runtime"; // @enableEmitFreeze @enableEmitInstrumentForget
22
23
function useFoo(props) {
24
- if (__DEV__ && shouldInstrument)
24
+ if (DEV && shouldInstrument)
25
useRenderCounter("useFoo", "/codegen-emit-imports-same-source.ts");
26
const $ = _c(2);
27
let t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/codegen-instrument-forget-test.expect.md
+2
-2
@@ -28,7 +28,7 @@ import { c as _c } from "react/compiler-runtime"; // @enableEmitInstrumentForget
28
29
function Bar(props) {
30
"use forget";
31
- if (__DEV__ && shouldInstrument)
31
+ if (DEV && shouldInstrument)
32
useRenderCounter("Bar", "/codegen-instrument-forget-test.ts");
33
const $ = _c(2);
34
let t0;
@@ -48,7 +48,7 @@ function NoForget(props) {
48
49
function Foo(props) {
50
"use forget";
51
- if (__DEV__ && shouldInstrument)
51
+ if (DEV && shouldInstrument)
52
useRenderCounter("Foo", "/codegen-instrument-forget-test.ts");
53
const $ = _c(2);
54
let t0;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating-test-export-function-and-default.js
deleted
-14
@@ -1,14 +0,0 @@
1
-// @gating @compilationMode(annotation)
2
-export default function Bar(props) {
3
- 'use forget';
4
- return <div>{props.bar}</div>;
5
-}
6
-
7
-function NoForget(props) {
8
- return <Bar>{props.noForget}</Bar>;
9
-}
10
-
11
-export function Foo(props) {
12
- 'use forget';
13
- return <Foo>{props.bar}</Foo>;
14
-}
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/arrow-function-expr-gating-test.expect.md
new
+50
@@ -0,0 +1,50 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+// @gating
6
+import {Stringify} from 'shared-runtime';
7
+const ErrorView = ({error, _retry}) => <Stringify error={error}></Stringify>;
8
+
9
+export default ErrorView;
10
+
11
+export const FIXTURE_ENTRYPOINT = {
12
+ fn: eval('ErrorView'),
13
+ params: [{}],
14
+};
15
+
16
+```
17
+
18
+## Code
19
+
20
+```javascript
21
+import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
22
+import { c as _c } from "react/compiler-runtime"; // @gating
23
+import { Stringify } from "shared-runtime";
24
+const ErrorView = isForgetEnabled_Fixtures()
25
+ ? (t0) => {
26
+ const $ = _c(2);
27
+ const { error } = t0;
28
+ let t1;
29
+ if ($[0] !== error) {
30
+ t1 = <Stringify error={error} />;
31
+ $[0] = error;
32
+ $[1] = t1;
33
+ } else {
34
+ t1 = $[1];
35
+ }
36
+ return t1;
37
+ }
38
+ : ({ error, _retry }) => <Stringify error={error}></Stringify>;
39
+
40
+export default ErrorView;
41
+
42
+export const FIXTURE_ENTRYPOINT = {
43
+ fn: eval("ErrorView"),
44
+ params: [{}],
45
+};
46
+
47
+```
48
+
49
+### Eval output
50
+(kind: ok) <div>{}</div>
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/arrow-function-expr-gating-test.js
new
+10
@@ -0,0 +1,10 @@
1
+// @gating
2
+import {Stringify} from 'shared-runtime';
3
+const ErrorView = ({error, _retry}) => <Stringify error={error}></Stringify>;
4
+
5
+export default ErrorView;
6
+
7
+export const FIXTURE_ENTRYPOINT = {
8
+ fn: eval('ErrorView'),
9
+ params: [{}],
10
+};
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/codegen-instrument-forget-gating-test.expect.md
renamed
+52
-12
@@ -15,9 +15,22 @@ function NoForget(props) {
15
16
function Foo(props) {
17
'use forget';
18
- return <Foo>{props.bar}</Foo>;
18
+ if (props.bar < 0) {
19
+ return props.children;
20
+ }
21
+ return (
22
+ <Foo bar={props.bar - 1}>
23
+ <NoForget />
24
+ </Foo>
25
+ );
26
}
27
28
+global.DEV = true;
29
+export const FIXTURE_ENTRYPOINT = {
30
+ fn: eval('Foo'),
31
+ params: [{bar: 2}],
32
+};
33
+
34
```
35
36
## Code
@@ -29,7 +42,7 @@ import { c as _c } from "react/compiler-runtime"; // @enableEmitInstrumentForget
42
const Bar = isForgetEnabled_Fixtures()
43
? function Bar(props) {
44
"use forget";
32
- if (__DEV__ && shouldInstrument)
45
+ if (DEV && shouldInstrument)
46
useRenderCounter("Bar", "/codegen-instrument-forget-gating-test.ts");
47
const $ = _c(2);
48
let t0;
@@ -53,23 +66,50 @@ function NoForget(props) {
66
const Foo = isForgetEnabled_Fixtures()
67
? function Foo(props) {
68
"use forget";
56
- if (__DEV__ && shouldInstrument)
69
+ if (DEV && shouldInstrument)
70
useRenderCounter("Foo", "/codegen-instrument-forget-gating-test.ts");
58
- const $ = _c(2);
59
- let t0;
60
- if ($[0] !== props.bar) {
61
- t0 = <Foo>{props.bar}</Foo>;
62
- $[0] = props.bar;
71
+ const $ = _c(3);
72
+ if (props.bar < 0) {
73
+ return props.children;
74
+ }
75
+
76
+ const t0 = props.bar - 1;
77
+ let t1;
78
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
79
+ t1 = <NoForget />;
80
+ $[0] = t1;
81
+ } else {
82
+ t1 = $[0];
83
+ }
84
+ let t2;
85
+ if ($[1] !== t0) {
86
+ t2 = <Foo bar={t0}>{t1}</Foo>;
87
$[1] = t0;
88
+ $[2] = t2;
89
} else {
65
- t0 = $[1];
90
+ t2 = $[2];
91
}
67
- return t0;
92
+ return t2;
93
}
94
: function Foo(props) {
95
"use forget";
71
- return <Foo>{props.bar}</Foo>;
96
+ if (props.bar < 0) {
97
+ return props.children;
98
+ }
99
+ return (
100
+ <Foo bar={props.bar - 1}>
101
+ <NoForget />
102
+ </Foo>
103
+ );
104
};
105
106
+global.DEV = true;
107
+export const FIXTURE_ENTRYPOINT = {
108
+ fn: eval("Foo"),
109
+ params: [{ bar: 2 }],
110
+};
111
+
112
```
75
-
\ No newline at end of file
113
+
114
+### Eval output
115
+(kind: ok) <div></div>
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/codegen-instrument-forget-gating-test.js
renamed
+14
-1
@@ -11,5 +11,18 @@ function NoForget(props) {
11
12
function Foo(props) {
13
'use forget';
14
- return <Foo>{props.bar}</Foo>;
14
+ if (props.bar < 0) {
15
+ return props.children;
16
+ }
17
+ return (
18
+ <Foo bar={props.bar - 1}>
19
+ <NoForget />
20
+ </Foo>
21
+ );
22
}
23
+
24
+global.DEV = true;
25
+export const FIXTURE_ENTRYPOINT = {
26
+ fn: eval('Foo'),
27
+ params: [{bar: 2}],
28
+};
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/error.component-syntax-ref-gating.flow.expect.md
renamed
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/error.component-syntax-ref-gating.flow.js
renamed
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/error.gating-hoisting.expect.md
renamed
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/error.gating-hoisting.js
renamed
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/error.gating-use-before-decl.expect.md
renamed
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/error.gating-use-before-decl.js
renamed
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/gating-access-function-name-in-component.expect.md
renamed
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/gating-access-function-name-in-component.js
renamed
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/gating-preserves-function-properties.expect.md
renamed
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/gating-preserves-function-properties.tsx
renamed
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/gating-test-export-default-function.expect.md
renamed
+13
-1
@@ -17,6 +17,11 @@ function Foo(props) {
17
return <Foo>{props.bar}</Foo>;
18
}
19
20
+export const FIXTURE_ENTRYPOINT = {
21
+ fn: eval('Bar'),
22
+ params: [{bar: 2}],
23
+};
24
+
25
```
26
27
## Code
@@ -66,5 +71,12 @@ const Foo = isForgetEnabled_Fixtures()
71
return <Foo>{props.bar}</Foo>;
72
};
73
74
+export const FIXTURE_ENTRYPOINT = {
75
+ fn: eval("Bar"),
76
+ params: [{ bar: 2 }],
77
+};
78
+
79
```
70
-
\ No newline at end of file
80
+
81
+### Eval output
82
+(kind: ok) <div>2</div>
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/gating-test-export-default-function.js
renamed
+5
@@ -12,3 +12,8 @@ function Foo(props) {
12
'use forget';
13
return <Foo>{props.bar}</Foo>;
14
}
15
+
16
+export const FIXTURE_ENTRYPOINT = {
17
+ fn: eval('Bar'),
18
+ params: [{bar: 2}],
19
+};
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/gating-test-export-function-and-default.expect.md
renamed
+50
-13
@@ -12,11 +12,23 @@ function NoForget(props) {
12
return <Bar>{props.noForget}</Bar>;
13
}
14
15
-export function Foo(props) {
15
+function Foo(props) {
16
'use forget';
17
- return <Foo>{props.bar}</Foo>;
17
+ if (props.bar < 0) {
18
+ return props.children;
19
+ }
20
+ return (
21
+ <Foo bar={props.bar - 1}>
22
+ <NoForget />
23
+ </Foo>
24
+ );
25
}
26
27
+export const FIXTURE_ENTRYPOINT = {
28
+ fn: eval('Bar'),
29
+ params: [{bar: 2}],
30
+};
31
+
32
```
33
34
## Code
@@ -47,25 +59,50 @@ export default Bar;
59
function NoForget(props) {
60
return <Bar>{props.noForget}</Bar>;
61
}
50
-
51
-export const Foo = isForgetEnabled_Fixtures()
62
+const Foo = isForgetEnabled_Fixtures()
63
? function Foo(props) {
64
"use forget";
54
- const $ = _c(2);
55
- let t0;
56
- if ($[0] !== props.bar) {
57
- t0 = <Foo>{props.bar}</Foo>;
58
- $[0] = props.bar;
65
+ const $ = _c(3);
66
+ if (props.bar < 0) {
67
+ return props.children;
68
+ }
69
+
70
+ const t0 = props.bar - 1;
71
+ let t1;
72
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
73
+ t1 = <NoForget />;
74
+ $[0] = t1;
75
+ } else {
76
+ t1 = $[0];
77
+ }
78
+ let t2;
79
+ if ($[1] !== t0) {
80
+ t2 = <Foo bar={t0}>{t1}</Foo>;
81
$[1] = t0;
82
+ $[2] = t2;
83
} else {
61
- t0 = $[1];
84
+ t2 = $[2];
85
}
63
- return t0;
86
+ return t2;
87
}
88
: function Foo(props) {
89
"use forget";
67
- return <Foo>{props.bar}</Foo>;
90
+ if (props.bar < 0) {
91
+ return props.children;
92
+ }
93
+ return (
94
+ <Foo bar={props.bar - 1}>
95
+ <NoForget />
96
+ </Foo>
97
+ );
98
};
99
100
+export const FIXTURE_ENTRYPOINT = {
101
+ fn: eval("Bar"),
102
+ params: [{ bar: 2 }],
103
+};
104
+
105
```
71
-
\ No newline at end of file
106
+
107
+### Eval output
108
+(kind: ok) <div>2</div>
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/gating-test-export-function-and-default.js
new
+26
@@ -0,0 +1,26 @@
1
+// @gating @compilationMode(annotation)
2
+export default function Bar(props) {
3
+ 'use forget';
4
+ return <div>{props.bar}</div>;
5
+}
6
+
7
+function NoForget(props) {
8
+ return <Bar>{props.noForget}</Bar>;
9
+}
10
+
11
+function Foo(props) {
12
+ 'use forget';
13
+ if (props.bar < 0) {
14
+ return props.children;
15
+ }
16
+ return (
17
+ <Foo bar={props.bar - 1}>
18
+ <NoForget />
19
+ </Foo>
20
+ );
21
+}
22
+
23
+export const FIXTURE_ENTRYPOINT = {
24
+ fn: eval('Bar'),
25
+ params: [{bar: 2}],
26
+};
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/gating-test-export-function.expect.md
renamed
+13
-1
@@ -17,6 +17,11 @@ export function Foo(props) {
17
return <Foo>{props.bar}</Foo>;
18
}
19
20
+export const FIXTURE_ENTRYPOINT = {
21
+ fn: eval('Bar'),
22
+ params: [{bar: 2}],
23
+};
24
+
25
```
26
27
## Code
@@ -66,5 +71,12 @@ export const Foo = isForgetEnabled_Fixtures()
71
return <Foo>{props.bar}</Foo>;
72
};
73
74
+export const FIXTURE_ENTRYPOINT = {
75
+ fn: eval("Bar"),
76
+ params: [{ bar: 2 }],
77
+};
78
+
79
```
70
-
\ No newline at end of file
80
+
81
+### Eval output
82
+(kind: ok) <div>2</div>
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/gating-test-export-function.js
renamed
+5
@@ -12,3 +12,8 @@ export function Foo(props) {
12
'use forget';
13
return <Foo>{props.bar}</Foo>;
14
}
15
+
16
+export const FIXTURE_ENTRYPOINT = {
17
+ fn: eval('Bar'),
18
+ params: [{bar: 2}],
19
+};
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/gating-test.expect.md
renamed
+13
-1
@@ -17,6 +17,11 @@ function Foo(props) {
17
return <Foo>{props.bar}</Foo>;
18
}
19
20
+export const FIXTURE_ENTRYPOINT = {
21
+ fn: eval('Bar'),
22
+ params: [{bar: 2}],
23
+};
24
+
25
```
26
27
## Code
@@ -65,5 +70,12 @@ const Foo = isForgetEnabled_Fixtures()
70
return <Foo>{props.bar}</Foo>;
71
};
72
73
+export const FIXTURE_ENTRYPOINT = {
74
+ fn: eval("Bar"),
75
+ params: [{ bar: 2 }],
76
+};
77
+
78
```
69
-
\ No newline at end of file
79
+
80
+### Eval output
81
+(kind: ok) <div>2</div>
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/gating-test.js
renamed
+5
@@ -12,3 +12,8 @@ function Foo(props) {
12
'use forget';
13
return <Foo>{props.bar}</Foo>;
14
}
15
+
16
+export const FIXTURE_ENTRYPOINT = {
17
+ fn: eval('Bar'),
18
+ params: [{bar: 2}],
19
+};
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/gating-with-hoisted-type-reference.flow.expect.md
renamed
+13
-1
@@ -13,6 +13,11 @@ component Component(value: string) {
13
14
export default memo<Props>(Component);
15
16
+export const FIXTURE_ENTRYPOINT = {
17
+ fn: eval('Component'),
18
+ params: [{value: 'foo'}],
19
+};
20
+
21
```
22
23
## Code
@@ -43,5 +48,12 @@ const Component = isForgetEnabled_Fixtures()
48
49
export default memo<Props>(Component);
50
51
+export const FIXTURE_ENTRYPOINT = {
52
+ fn: eval("Component"),
53
+ params: [{ value: "foo" }],
54
+};
55
+
56
```
47
-
\ No newline at end of file
57
+
58
+### Eval output
59
+(kind: ok) <div>foo</div>
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/gating-with-hoisted-type-reference.flow.js
renamed
+5
@@ -8,3 +8,8 @@ component Component(value: string) {
8
}
9
10
export default memo<Props>(Component);
11
+
12
+export const FIXTURE_ENTRYPOINT = {
13
+ fn: eval('Component'),
14
+ params: [{value: 'foo'}],
15
+};
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/infer-function-expression-React-memo-gating.expect.md
renamed
+4
-1
@@ -35,4 +35,7 @@ export default React.forwardRef(
35
);
36
37
```
38
-
\ No newline at end of file
38
+
39
+### Eval output
40
+(kind: exception) Fixture not implemented
41
+logs: ['forwardRef render functions accept exactly two parameters: props and ref. %s','Did you forget to use the ref parameter?']
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/infer-function-expression-React-memo-gating.js
renamed
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/multi-arrow-expr-export-default-gating-test.expect.md
renamed
+12
-9
@@ -3,17 +3,17 @@
3
4
```javascript
5
// @gating
6
-const ErrorView = (error, _retry) => <MessageBox error={error}></MessageBox>;
6
+import {Stringify} from 'shared-runtime';
7
8
-const Renderer = props => (
8
+const ErrorView = (error, _retry) => <Stringify error={error}></Stringify>;
9
+
10
+export default props => (
11
<Foo>
12
<Bar></Bar>
13
<ErrorView></ErrorView>
14
</Foo>
15
);
16
15
-export default Renderer;
16
-
17
```
18
19
## Code
@@ -21,12 +21,14 @@ export default Renderer;
21
```javascript
22
import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
23
import { c as _c } from "react/compiler-runtime"; // @gating
24
+import { Stringify } from "shared-runtime";
25
+
26
const ErrorView = isForgetEnabled_Fixtures()
27
? (error, _retry) => {
28
const $ = _c(2);
29
let t0;
30
if ($[0] !== error) {
29
- t0 = <MessageBox error={error} />;
31
+ t0 = <Stringify error={error} />;
32
$[0] = error;
33
$[1] = t0;
34
} else {
@@ -34,9 +36,9 @@ const ErrorView = isForgetEnabled_Fixtures()
36
}
37
return t0;
38
}
37
- : (error, _retry) => <MessageBox error={error}></MessageBox>;
39
+ : (error, _retry) => <Stringify error={error}></Stringify>;
40
39
-const Renderer = isForgetEnabled_Fixtures()
41
+export default isForgetEnabled_Fixtures()
42
? (props) => {
43
const $ = _c(1);
44
let t0;
@@ -59,7 +61,8 @@ const Renderer = isForgetEnabled_Fixtures()
61
<ErrorView></ErrorView>
62
</Foo>
63
);
62
-export default Renderer;
64
65
```
65
-
\ No newline at end of file
66
+
67
+### Eval output
68
+(kind: exception) Fixture not implemented
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/multi-arrow-expr-export-default-gating-test.js
new
+11
@@ -0,0 +1,11 @@
1
+// @gating
2
+import {Stringify} from 'shared-runtime';
3
+
4
+const ErrorView = (error, _retry) => <Stringify error={error}></Stringify>;
5
+
6
+export default props => (
7
+ <Foo>
8
+ <Bar></Bar>
9
+ <ErrorView></ErrorView>
10
+ </Foo>
11
+);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/multi-arrow-expr-export-gating-test.expect.md
renamed
+28
-13
@@ -3,15 +3,22 @@
3
4
```javascript
5
// @gating
6
-const ErrorView = (error, _retry) => <MessageBox error={error}></MessageBox>;
6
+import {Stringify} from 'shared-runtime';
7
+
8
+const ErrorView = (error, _retry) => <Stringify error={error}></Stringify>;
9
10
export const Renderer = props => (
9
- <Foo>
10
- <Bar></Bar>
11
+ <div>
12
+ <span></span>
13
<ErrorView></ErrorView>
12
- </Foo>
14
+ </div>
15
);
16
17
+export const FIXTURE_ENTRYPOINT = {
18
+ fn: eval('Renderer'),
19
+ params: [{}],
20
+};
21
+
22
```
23
24
## Code
@@ -19,12 +26,14 @@ export const Renderer = props => (
26
```javascript
27
import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
28
import { c as _c } from "react/compiler-runtime"; // @gating
29
+import { Stringify } from "shared-runtime";
30
+
31
const ErrorView = isForgetEnabled_Fixtures()
32
? (error, _retry) => {
33
const $ = _c(2);
34
let t0;
35
if ($[0] !== error) {
27
- t0 = <MessageBox error={error} />;
36
+ t0 = <Stringify error={error} />;
37
$[0] = error;
38
$[1] = t0;
39
} else {
@@ -32,7 +41,7 @@ const ErrorView = isForgetEnabled_Fixtures()
41
}
42
return t0;
43
}
35
- : (error, _retry) => <MessageBox error={error}></MessageBox>;
44
+ : (error, _retry) => <Stringify error={error}></Stringify>;
45
46
export const Renderer = isForgetEnabled_Fixtures()
47
? (props) => {
@@ -40,10 +49,10 @@ export const Renderer = isForgetEnabled_Fixtures()
49
let t0;
50
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
51
t0 = (
43
- <Foo>
44
- <Bar />
52
+ <div>
53
+ <span />
54
<ErrorView />
46
- </Foo>
55
+ </div>
56
);
57
$[0] = t0;
58
} else {
@@ -52,11 +61,17 @@ export const Renderer = isForgetEnabled_Fixtures()
61
return t0;
62
}
63
: (props) => (
55
- <Foo>
56
- <Bar></Bar>
64
+ <div>
65
+ <span></span>
66
<ErrorView></ErrorView>
58
- </Foo>
67
+ </div>
68
);
69
+export const FIXTURE_ENTRYPOINT = {
70
+ fn: eval("Renderer"),
71
+ params: [{}],
72
+};
73
74
```
62
-
\ No newline at end of file
75
+
76
+### Eval output
77
+(kind: ok) <div><span></span><div>{"error":{}}</div></div>
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/multi-arrow-expr-export-gating-test.js
new
+16
@@ -0,0 +1,16 @@
1
+// @gating
2
+import {Stringify} from 'shared-runtime';
3
+
4
+const ErrorView = (error, _retry) => <Stringify error={error}></Stringify>;
5
+
6
+export const Renderer = props => (
7
+ <div>
8
+ <span></span>
9
+ <ErrorView></ErrorView>
10
+ </div>
11
+);
12
+
13
+export const FIXTURE_ENTRYPOINT = {
14
+ fn: eval('Renderer'),
15
+ params: [{}],
16
+};
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/multi-arrow-expr-gating-test.expect.md
renamed
+34
-15
@@ -3,15 +3,24 @@
3
4
```javascript
5
// @gating
6
-const ErrorView = (error, _retry) => <MessageBox error={error}></MessageBox>;
6
+import {Stringify} from 'shared-runtime';
7
8
-export default Renderer = props => (
9
- <Foo>
10
- <Bar></Bar>
8
+const ErrorView = (error, _retry) => <Stringify error={error}></Stringify>;
9
+
10
+const Renderer = props => (
11
+ <div>
12
+ <span></span>
13
<ErrorView></ErrorView>
12
- </Foo>
14
+ </div>
15
);
16
17
+export default Renderer;
18
+
19
+export const FIXTURE_ENTRYPOINT = {
20
+ fn: eval('Renderer'),
21
+ params: [{}],
22
+};
23
+
24
```
25
26
## Code
@@ -19,12 +28,14 @@ export default Renderer = props => (
28
```javascript
29
import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
30
import { c as _c } from "react/compiler-runtime"; // @gating
31
+import { Stringify } from "shared-runtime";
32
+
33
const ErrorView = isForgetEnabled_Fixtures()
34
? (error, _retry) => {
35
const $ = _c(2);
36
let t0;
37
if ($[0] !== error) {
27
- t0 = <MessageBox error={error} />;
38
+ t0 = <Stringify error={error} />;
39
$[0] = error;
40
$[1] = t0;
41
} else {
@@ -32,18 +43,18 @@ const ErrorView = isForgetEnabled_Fixtures()
43
}
44
return t0;
45
}
35
- : (error, _retry) => <MessageBox error={error}></MessageBox>;
46
+ : (error, _retry) => <Stringify error={error}></Stringify>;
47
37
-export default Renderer = isForgetEnabled_Fixtures()
48
+const Renderer = isForgetEnabled_Fixtures()
49
? (props) => {
50
const $ = _c(1);
51
let t0;
52
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
53
t0 = (
43
- <Foo>
44
- <Bar />
54
+ <div>
55
+ <span />
56
<ErrorView />
46
- </Foo>
57
+ </div>
58
);
59
$[0] = t0;
60
} else {
@@ -52,11 +63,19 @@ export default Renderer = isForgetEnabled_Fixtures()
63
return t0;
64
}
65
: (props) => (
55
- <Foo>
56
- <Bar></Bar>
66
+ <div>
67
+ <span></span>
68
<ErrorView></ErrorView>
58
- </Foo>
69
+ </div>
70
);
71
+export default Renderer;
72
+
73
+export const FIXTURE_ENTRYPOINT = {
74
+ fn: eval("Renderer"),
75
+ params: [{}],
76
+};
77
78
```
62
-
\ No newline at end of file
79
+
80
+### Eval output
81
+(kind: ok) <div><span></span><div>{"error":{}}</div></div>
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/multi-arrow-expr-gating-test.js
new
+18
@@ -0,0 +1,18 @@
1
+// @gating
2
+import {Stringify} from 'shared-runtime';
3
+
4
+const ErrorView = (error, _retry) => <Stringify error={error}></Stringify>;
5
+
6
+const Renderer = props => (
7
+ <div>
8
+ <span></span>
9
+ <ErrorView></ErrorView>
10
+ </div>
11
+);
12
+
13
+export default Renderer;
14
+
15
+export const FIXTURE_ENTRYPOINT = {
16
+ fn: eval('Renderer'),
17
+ params: [{}],
18
+};
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/repro-no-gating-import-without-compiled-functions.expect.md
renamed
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/repro-no-gating-import-without-compiled-functions.js
renamed
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/multi-arrow-expr-export-default-gating-test.js
deleted
-9
@@ -1,9 +0,0 @@
1
-// @gating
2
-const ErrorView = (error, _retry) => <MessageBox error={error}></MessageBox>;
3
-
4
-export default Renderer = props => (
5
- <Foo>
6
- <Bar></Bar>
7
- <ErrorView></ErrorView>
8
- </Foo>
9
-);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/multi-arrow-expr-export-gating-test.js
deleted
-9
@@ -1,9 +0,0 @@
1
-// @gating
2
-const ErrorView = (error, _retry) => <MessageBox error={error}></MessageBox>;
3
-
4
-export const Renderer = props => (
5
- <Foo>
6
- <Bar></Bar>
7
- <ErrorView></ErrorView>
8
- </Foo>
9
-);
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/multi-arrow-expr-gating-test.js
deleted
-11
@@ -1,11 +0,0 @@
1
-// @gating
2
-const ErrorView = (error, _retry) => <MessageBox error={error}></MessageBox>;
3
-
4
-const Renderer = props => (
5
- <Foo>
6
- <Bar></Bar>
7
- <ErrorView></ErrorView>
8
- </Foo>
9
-);
10
-
11
-export default Renderer;
compiler/packages/snap/src/SproutTodoFilter.ts
+1
-12
@@ -222,7 +222,6 @@ const skipFilter = new Set([
222
'array-at-mutate-after-capture',
223
'array-join',
224
'array-push-effect',
225
- 'arrow-function-expr-gating-test',
225
'assignment-in-nested-if',
226
'await-side-effecting-promise',
227
'await',
@@ -335,16 +334,10 @@ const skipFilter = new Set([
334
'babel-existing-react-import',
335
'babel-existing-react-kitchensink-import',
336
'call',
338
- 'codegen-instrument-forget-gating-test',
337
'codegen-instrument-forget-test',
338
'conditional-on-mutable',
339
'constructor',
340
'frozen-after-alias',
343
- 'gating-test-export-default-function',
344
- 'gating-test-export-function-and-default',
345
- 'gating-test-export-function',
346
- 'gating-test',
347
- 'gating-with-hoisted-type-reference.flow',
341
'hook-call',
342
'hooks-freeze-arguments',
343
'hooks-freeze-possibly-mutable-arguments',
@@ -352,8 +345,6 @@ const skipFilter = new Set([
345
'independent',
346
'interdependent-across-if',
347
'interdependent',
355
- 'multi-arrow-expr-export-gating-test',
356
- 'multi-arrow-expr-gating-test',
348
'mutable-liverange-loop',
349
'sequence-expression',
350
'ssa-call-jsx-2',
@@ -361,7 +352,6 @@ const skipFilter = new Set([
352
'ssa-newexpression',
353
'ssa-shadowing',
354
'template-literal',
364
- 'multi-arrow-expr-export-default-gating-test',
355
356
// works, but appears differently when printing
357
// due to optional function argument
@@ -407,7 +397,6 @@ const skipFilter = new Set([
397
'infer-functions-hook-with-hook-call',
398
'infer-functions-hook-with-jsx',
399
'infer-function-expression-component',
410
- 'infer-function-expression-React-memo-gating',
400
'infer-skip-components-without-hooks-or-jsx',
401
'class-component-with-render-helper',
402
'fbt/fbtparam-with-jsx-element-content',
@@ -422,7 +411,7 @@ const skipFilter = new Set([
411
'transitive-freeze-function-expressions',
412
413
// nothing to compile/run
425
- 'repro-no-gating-import-without-compiled-functions',
414
+ 'gating/repro-no-gating-import-without-compiled-functions',
415
416
// TODOs
417
'rules-of-hooks/todo.bail.rules-of-hooks-279ac76f53af',