@samitouri / QOS-React-2 / commits / b447c93edc

[test] Add failing test for lambda turning value reactive

Sathya Gunasekaran committed May 31, 2023 at 15:37 UTC b447c93edc1837b9b50d7ade46cb2eb348716040
2 files changed +50
compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-mutated-non-reactive-to-reactive.expect.md new
+43
@@ -0,0 +1,43 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function f(a) {
6 + let x;
7 + (() => {
8 + x = { a };
9 + })();
10 + return <div x={x} />;
11 +}
12 +
13 +```
14 +
15 +## Code
16 +
17 +```javascript
18 +import { unstable_useMemoCache as useMemoCache } from "react";
19 +function f(a) {
20 + const $ = useMemoCache(3);
21 + const c_0 = $[0] !== a;
22 + let x;
23 + if (c_0) {
24 + (() => {
25 + x = { a };
26 + })();
27 + $[0] = a;
28 + $[1] = x;
29 + } else {
30 + x = $[1];
31 + }
32 + let t0;
33 + if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
34 + t0 = <div x={x} />;
35 + $[2] = t0;
36 + } else {
37 + t0 = $[2];
38 + }
39 + return t0;
40 +}
41 +
42 +```
43 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-mutated-non-reactive-to-reactive.js new
+7
@@ -0,0 +1,7 @@
1 +function f(a) {
2 + let x;
3 + (() => {
4 + x = { a };
5 + })();
6 + return <div x={x} />;
7 +}