@samitouri / QOS-React-2 / commits / 39d837d918

Update fixtures from workspace rebase

I updated these yesterday, looks like they got added back in the workspace PR. Rebases are hard, all good!

Joe Savona committed Jun 5, 2023 at 14:16 UTC 39d837d9185fa2543c5fd2dff0a9e97176aae49b
18 files changed -411
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/_bug.capturing-reference-changes-type.expect.md deleted
-41
@@ -1,41 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function component(a) {
6 - let x = { a };
7 - let y = 1;
8 - (function () {
9 - y = x;
10 - })();
11 - mutate(y);
12 - return y;
13 -}
14 -
15 -```
16 -
17 -## Code
18 -
19 -```javascript
20 -import { unstable_useMemoCache as useMemoCache } from "react";
21 -function component(a) {
22 - const $ = useMemoCache(2);
23 - const c_0 = $[0] !== a;
24 - let y;
25 - if (c_0) {
26 - const x = { a };
27 - y = 1;
28 - (function () {
29 - y = x;
30 - })();
31 - mutate(y);
32 - $[0] = a;
33 - $[1] = y;
34 - } else {
35 - y = $[1];
36 - }
37 - return y;
38 -}
39 -
40 -```
41 -
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/_bug.capturing-reference-changes-type.js deleted
-9
@@ -1,9 +0,0 @@
1 -function component(a) {
2 - let x = { a };
3 - let y = 1;
4 - (function () {
5 - y = x;
6 - })();
7 - mutate(y);
8 - return y;
9 -}
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/_bug.computed-call-evaluation-order.expect.md deleted
-60
@@ -1,60 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -// Should print A, B, arg, original
6 -function Component() {
7 - const changeF = (o) => {
8 - o.f = () => console.log("new");
9 - };
10 - const x = {
11 - f: () => console.log("original"),
12 - };
13 -
14 - (console.log("A"), x)[(console.log("B"), "f")](
15 - (changeF(x), console.log("arg"), 1)
16 - );
17 - return x;
18 -}
19 -
20 -```
21 -
22 -## Code
23 -
24 -```javascript
25 -import { unstable_useMemoCache as useMemoCache } from "react"; // Should print A, B, arg, original
26 -function Component() {
27 - const $ = useMemoCache(3);
28 - let t0;
29 - if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
30 - t0 = (o) => {
31 - o.f = () => console.log("new");
32 - };
33 - $[0] = t0;
34 - } else {
35 - t0 = $[0];
36 - }
37 - const changeF = t0;
38 - let t1;
39 - if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
40 - t1 = () => console.log("original");
41 - $[1] = t1;
42 - } else {
43 - t1 = $[1];
44 - }
45 - let x;
46 - if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
47 - x = { f: t1 };
48 -
49 - (console.log("A"), x)[(console.log("B"), "f")](
50 - (changeF(x), console.log("arg"), 1)
51 - );
52 - $[2] = x;
53 - } else {
54 - x = $[2];
55 - }
56 - return x;
57 -}
58 -
59 -```
60 -
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/_bug.computed-call-evaluation-order.js deleted
-14
@@ -1,14 +0,0 @@
1 -// Should print A, B, arg, original
2 -function Component() {
3 - const changeF = (o) => {
4 - o.f = () => console.log("new");
5 - };
6 - const x = {
7 - f: () => console.log("original"),
8 - };
9 -
10 - (console.log("A"), x)[(console.log("B"), "f")](
11 - (changeF(x), console.log("arg"), 1)
12 - );
13 - return x;
14 -}
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/_bug.lambda-reassign-shadowed-primitive.expect.md deleted
-44
@@ -1,44 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function Component() {
6 - const x = {};
7 - {
8 - let x = 56;
9 - const fn = function () {
10 - x = 42;
11 - };
12 - fn();
13 - }
14 - return x; // should return {}
15 -}
16 -
17 -```
18 -
19 -## Code
20 -
21 -```javascript
22 -import { unstable_useMemoCache as useMemoCache } from "react";
23 -function Component() {
24 - const $ = useMemoCache(1);
25 - let t0;
26 - if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
27 - t0 = {};
28 - $[0] = t0;
29 - } else {
30 - t0 = $[0];
31 - }
32 - const x = t0;
33 -
34 - let x_0;
35 - x_0 = 56;
36 - const fn = function () {
37 - x_0 = 42;
38 - };
39 - fn();
40 - return x;
41 -}
42 -
43 -```
44 -
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/_bug.lambda-reassign-shadowed-primitive.js deleted
-11
@@ -1,11 +0,0 @@
1 -function Component() {
2 - const x = {};
3 - {
4 - let x = 56;
5 - const fn = function () {
6 - x = 42;
7 - };
8 - fn();
9 - }
10 - return x; // should return {}
11 -}
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/_bug.property-call-evaluation-order.expect.md deleted
-58
@@ -1,58 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -// Should print A, arg, original
6 -
7 -function Component() {
8 - const changeF = (o) => {
9 - o.f = () => console.log("new");
10 - };
11 - const x = {
12 - f: () => console.log("original"),
13 - };
14 -
15 - (console.log("A"), x).f((changeF(x), console.log("arg"), 1));
16 - return x;
17 -}
18 -
19 -```
20 -
21 -## Code
22 -
23 -```javascript
24 -import { unstable_useMemoCache as useMemoCache } from "react"; // Should print A, arg, original
25 -
26 -function Component() {
27 - const $ = useMemoCache(3);
28 - let t0;
29 - if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
30 - t0 = (o) => {
31 - o.f = () => console.log("new");
32 - };
33 - $[0] = t0;
34 - } else {
35 - t0 = $[0];
36 - }
37 - const changeF = t0;
38 - let t1;
39 - if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
40 - t1 = () => console.log("original");
41 - $[1] = t1;
42 - } else {
43 - t1 = $[1];
44 - }
45 - let x;
46 - if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
47 - x = { f: t1 };
48 -
49 - (console.log("A"), x).f((changeF(x), console.log("arg"), 1));
50 - $[2] = x;
51 - } else {
52 - x = $[2];
53 - }
54 - return x;
55 -}
56 -
57 -```
58 -
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/_bug.property-call-evaluation-order.js deleted
-13
@@ -1,13 +0,0 @@
1 -// Should print A, arg, original
2 -
3 -function Component() {
4 - const changeF = (o) => {
5 - o.f = () => console.log("new");
6 - };
7 - const x = {
8 - f: () => console.log("original"),
9 - };
10 -
11 - (console.log("A"), x).f((changeF(x), console.log("arg"), 1));
12 - return x;
13 -}
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-after-aliased-freeze.expect.md deleted
-31
@@ -1,31 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function Component(props) {
6 - let x = [];
7 - let y = x;
8 -
9 - if (props.p1) {
10 - x = [];
11 - }
12 -
13 - let _ = <Component x={x} />;
14 -
15 - // y is MaybeFrozen at this point, since it may alias to x
16 - // (which is the above line freezes)
17 - y.push(props.p2);
18 -
19 - return <Component x={x} y={y} />;
20 -}
21 -
22 -```
23 -
24 -
25 -## Error
26 -
27 -```
28 -[ReactForget] InvalidInput: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $46:TObject<BuiltInArray> (frozen) (13:13)
29 -```
30 -
31 -
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-after-aliased-freeze.js deleted
-16
@@ -1,16 +0,0 @@
1 -function Component(props) {
2 - let x = [];
3 - let y = x;
4 -
5 - if (props.p1) {
6 - x = [];
7 - }
8 -
9 - let _ = <Component x={x} />;
10 -
11 - // y is MaybeFrozen at this point, since it may alias to x
12 - // (which is the above line freezes)
13 - y.push(props.p2);
14 -
15 - return <Component x={x} y={y} />;
16 -}
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-after-freeze.expect.md deleted
-25
@@ -1,25 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function Component(props) {
6 - let x = [];
7 -
8 - let _ = <Component x={x} />;
9 -
10 - // x is Frozen at this point
11 - x.push(props.p2);
12 -
13 - return <div>{_}</div>;
14 -}
15 -
16 -```
17 -
18 -
19 -## Error
20 -
21 -```
22 -[ReactForget] InvalidInput: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $27:TObject<BuiltInArray> (frozen) (7:7)
23 -```
24 -
25 -
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-after-freeze.js deleted
-10
@@ -1,10 +0,0 @@
1 -function Component(props) {
2 - let x = [];
3 -
4 - let _ = <Component x={x} />;
5 -
6 - // x is Frozen at this point
7 - x.push(props.p2);
8 -
9 - return <div>{_}</div>;
10 -}
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.sketchy-code-use-forget.expect.md deleted
-22
@@ -1,22 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -/* eslint-disable react-hooks/rules-of-hooks */
6 -function lowercasecomponent() {
7 - "use forget";
8 - const x = [];
9 - return <div>{x}</div>;
10 -}
11 -/* eslint-enable react-hooks/rules-of-hooks */
12 -
13 -```
14 -
15 -
16 -## Error
17 -
18 -```
19 -[ReactForget] UnsafeInput: One or more React eslint rules is disabled. eslint-disable react-hooks/rules-of-hooks (1:1)
20 -```
21 -
22 -
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.sketchy-code-use-forget.js deleted
-7
@@ -1,7 +0,0 @@
1 -/* eslint-disable react-hooks/rules-of-hooks */
2 -function lowercasecomponent() {
3 - "use forget";
4 - const x = [];
5 - return <div>{x}</div>;
6 -}
7 -/* eslint-enable react-hooks/rules-of-hooks */
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.useMemo-async-callback.expect.md deleted
-21
@@ -1,21 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function component(a, b) {
6 - let x = useMemo(async () => {
7 - await a;
8 - }, []);
9 - return x;
10 -}
11 -
12 -```
13 -
14 -
15 -## Error
16 -
17 -```
18 -[ReactForget] InvalidInput: useMemo callbacks may not be async or generator functions (2:4)
19 -```
20 -
21 -
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.useMemo-async-callback.js deleted
-6
@@ -1,6 +0,0 @@
1 -function component(a, b) {
2 - let x = useMemo(async () => {
3 - await a;
4 - }, []);
5 - return x;
6 -}
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.useMemo-callback-args.expect.md deleted
-19
@@ -1,19 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function component(a, b) {
6 - let x = useMemo((c) => a, []);
7 - return x;
8 -}
9 -
10 -```
11 -
12 -
13 -## Error
14 -
15 -```
16 -[ReactForget] InvalidInput: useMemo callbacks may not accept any arguments (2:2)
17 -```
18 -
19 -
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.useMemo-callback-args.js deleted
-4
@@ -1,4 +0,0 @@
1 -function component(a, b) {
2 - let x = useMemo((c) => a, []);
3 - return x;
4 -}