[tests] failing tests for dependencies and codegen (#1414)
mofeiZ committed
Mar 24, 2023 at 15:23 UTC
568048af0f3eccb8cd450158eb140bdb811e13c8
4 files changed
+79
compiler/forget/src/__tests__/fixtures/compiler/_bug.nested-optional-member-expr.expect.md
new
+31
@@ -0,0 +1,31 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+function Component(props) {
6
+ let x = foo(props.a?.b.c.d);
7
+ return x;
8
+}
9
+
10
+```
11
+
12
+## Code
13
+
14
+```javascript
15
+function Component(props) {
16
+ const $ = React.unstable_useMemoCache(2);
17
+ const c_0 = $[0] !== props.a.b.c.d;
18
+ let t0;
19
+ if (c_0) {
20
+ t0 = foo(props.a?.b?.c?.d);
21
+ $[0] = props.a.b.c.d;
22
+ $[1] = t0;
23
+ } else {
24
+ t0 = $[1];
25
+ }
26
+ const x = t0;
27
+ return x;
28
+}
29
+
30
+```
31
+
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/_bug.nested-optional-member-expr.js
new
+4
@@ -0,0 +1,4 @@
1
+function Component(props) {
2
+ let x = foo(props.a?.b.c.d);
3
+ return x;
4
+}
compiler/forget/src/__tests__/fixtures/compiler/_bug.primitive-computed-load.expect.md
new
+35
@@ -0,0 +1,35 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+function Component(props) {
6
+ let a = foo();
7
+ // freeze `a` so we know the next line cannot mutate it
8
+ <div>{a}</div>;
9
+
10
+ // b should be dependent on `props.a`
11
+ let b = bar(a[props.a] + 1);
12
+ return b;
13
+}
14
+
15
+```
16
+
17
+## Code
18
+
19
+```javascript
20
+function Component(props) {
21
+ const $ = React.unstable_useMemoCache(1);
22
+ const a = foo();
23
+ let t0;
24
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
25
+ t0 = bar(a[props.a] + 1);
26
+ $[0] = t0;
27
+ } else {
28
+ t0 = $[0];
29
+ }
30
+ const b = t0;
31
+ return b;
32
+}
33
+
34
+```
35
+
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/_bug.primitive-computed-load.js
new
+9
@@ -0,0 +1,9 @@
1
+function Component(props) {
2
+ let a = foo();
3
+ // freeze `a` so we know the next line cannot mutate it
4
+ <div>{a}</div>;
5
+
6
+ // b should be dependent on `props.a`
7
+ let b = bar(a[props.a] + 1);
8
+ return b;
9
+}