Skip to content

Commit 4468e46

Browse files
hi-ogawajames-elicxcodex
authored
test(rsc): add hoist fixture coverage (#1175)
Co-authored-by: James <james@eli.cx> Co-authored-by: Codex <noreply@openai.com>
1 parent 8bd768c commit 4468e46

File tree

100 files changed

+1346
-554
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+1346
-554
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Writing to a captured local only mutates the hoisted action's bound
2+
// parameter copy, not the original outer binding.
3+
function Counter() {
4+
let local = 0
5+
6+
async function updateLocal() {
7+
'use server'
8+
local = 1
9+
}
10+
11+
return 'something'
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Writing to a captured local only mutates the hoisted action's bound
2+
// parameter copy, not the original outer binding.
3+
function Counter() {
4+
let local = 0
5+
6+
const updateLocal = /* #__PURE__ */ $$register($$hoist_0_updateLocal, "<id>", "$$hoist_0_updateLocal").bind(null, __enc([local]));
7+
8+
return 'something'
9+
}
10+
11+
;export async function $$hoist_0_updateLocal($$hoist_encoded) {
12+
const [local] = __dec($$hoist_encoded);
13+
'use server'
14+
local = 1
15+
};
16+
/* #__PURE__ */ Object.defineProperty($$hoist_0_updateLocal, "name", { value: "updateLocal" });
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Writing to a captured local only mutates the hoisted action's bound
2+
// parameter copy, not the original outer binding.
3+
function Counter() {
4+
let local = 0
5+
6+
const updateLocal = /* #__PURE__ */ $$register($$hoist_0_updateLocal, "<id>", "$$hoist_0_updateLocal").bind(null, local);
7+
8+
return 'something'
9+
}
10+
11+
;export async function $$hoist_0_updateLocal(local) {
12+
'use server'
13+
local = 1
14+
};
15+
/* #__PURE__ */ Object.defineProperty($$hoist_0_updateLocal, "name", { value: "updateLocal" });
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Mutating a captured local is local to the hoisted invocation copy.
2+
function Counter() {
3+
let local = 0
4+
5+
async function updateLocal() {
6+
'use server'
7+
local++
8+
}
9+
10+
return 'something'
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Mutating a captured local is local to the hoisted invocation copy.
2+
function Counter() {
3+
let local = 0
4+
5+
const updateLocal = /* #__PURE__ */ $$register($$hoist_0_updateLocal, "<id>", "$$hoist_0_updateLocal").bind(null, __enc([local]));
6+
7+
return 'something'
8+
}
9+
10+
;export async function $$hoist_0_updateLocal($$hoist_encoded) {
11+
const [local] = __dec($$hoist_encoded);
12+
'use server'
13+
local++
14+
};
15+
/* #__PURE__ */ Object.defineProperty($$hoist_0_updateLocal, "name", { value: "updateLocal" });
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Mutating a captured local is local to the hoisted invocation copy.
2+
function Counter() {
3+
let local = 0
4+
5+
const updateLocal = /* #__PURE__ */ $$register($$hoist_0_updateLocal, "<id>", "$$hoist_0_updateLocal").bind(null, local);
6+
7+
return 'something'
8+
}
9+
10+
;export async function $$hoist_0_updateLocal(local) {
11+
'use server'
12+
local++
13+
};
14+
/* #__PURE__ */ Object.defineProperty($$hoist_0_updateLocal, "name", { value: "updateLocal" });
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function outer(config, err) {
2+
async function action() {
3+
'use server'
4+
try {
5+
return config.value
6+
} catch (err) {
7+
return err.message
8+
}
9+
}
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function outer(config, err) {
2+
const action = /* #__PURE__ */ $$register($$hoist_0_action, "<id>", "$$hoist_0_action").bind(null, __enc([{ value: config.value }]));
3+
}
4+
5+
;export async function $$hoist_0_action($$hoist_encoded) {
6+
const [config] = __dec($$hoist_encoded);
7+
'use server'
8+
try {
9+
return config.value
10+
} catch (err) {
11+
return err.message
12+
}
13+
};
14+
/* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" });
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function outer(config, err) {
2+
const action = /* #__PURE__ */ $$register($$hoist_0_action, "<id>", "$$hoist_0_action").bind(null, { value: config.value });
3+
}
4+
5+
;export async function $$hoist_0_action(config) {
6+
'use server'
7+
try {
8+
return config.value
9+
} catch (err) {
10+
return err.message
11+
}
12+
};
13+
/* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" });
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function outer(config) {
2+
async function action() {
3+
'use server'
4+
class Helper {
5+
run() {
6+
return config.value
7+
}
8+
}
9+
return new Helper().run()
10+
}
11+
}

0 commit comments

Comments
 (0)