Skip to content

Commit bdc2ac5

Browse files
committed
add test
1 parent 945973b commit bdc2ac5

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { test } from '../../test';
2+
3+
export default test({});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import 'svelte/internal/disclose-version';
2+
import * as $ from 'svelte/internal/client';
3+
4+
var on_click = (_, count) => $.update(count);
5+
var root = $.template(`<h1></h1> <p></p> <button> </button> <p></p> <p></p> <p></p> <!>`, 1);
6+
7+
export default function App($$anchor) {
8+
let a = 1;
9+
let b = 2;
10+
let name = 'world';
11+
let count = $.state(0);
12+
13+
function Component() {} // placeholder component
14+
15+
var fragment = root();
16+
var h1 = $.first_child(fragment);
17+
18+
h1.textContent = 'Hello, world!';
19+
20+
var p = $.sibling(h1, 2);
21+
22+
p.textContent = '1 + 2 = 3';
23+
24+
var button = $.sibling(p, 2);
25+
26+
button.__click = [on_click, count];
27+
28+
var text = $.child(button);
29+
30+
$.reset(button);
31+
32+
var p_1 = $.sibling(button, 2);
33+
34+
p_1.textContent = '1 + 2 = 3';
35+
36+
var p_2 = $.sibling(p_1, 2);
37+
38+
p_2.textContent = 'Sum is 3';
39+
40+
var p_3 = $.sibling(p_2, 2);
41+
42+
p_3.textContent = '1';
43+
44+
var node = $.sibling(p_3, 2);
45+
46+
Component(node, {
47+
a: 1,
48+
get count() {
49+
return $.get(count);
50+
},
51+
c: 3
52+
});
53+
54+
$.template_effect(() => $.set_text(text, `Count is ${$.get(count) ?? ''}`));
55+
$.append($$anchor, fragment);
56+
}
57+
58+
$.delegate(['click']);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as $ from 'svelte/internal/server';
2+
3+
export default function App($$payload) {
4+
let a = 1;
5+
let b = 2;
6+
let name = 'world';
7+
let count = 0;
8+
9+
function Component() {} // placeholder component
10+
$$payload.out += `<h1>Hello, ${$.escape(name)}!</h1> <p>${$.escape(a)} + ${$.escape(b)} = ${$.escape(a + b)}</p> <button>Count is ${$.escape(count)}</button> <p>1 + 2 = ${$.escape(1 + 2)}</p> <p>Sum is ${$.escape((a, b, a + b))}</p> <p>${$.escape(a === 1 ? a : b)}</p> `;
11+
Component($$payload, { a, count, c: a + b });
12+
$$payload.out += `<!---->`;
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<script>
2+
let a = 1;
3+
let b = 2;
4+
let name = 'world';
5+
let count = $state(0);
6+
function Component() {
7+
// placeholder component
8+
}
9+
</script>
10+
<h1>Hello, {name}!</h1>
11+
<p>{a} + {b} = {a + b}</p>
12+
<button onclick={() => count++}>Count is {count}</button>
13+
<p>{1} + {2} = {1 + 2}</p>
14+
<p>Sum is {(a, b, a + b)}</p>
15+
<p>{a === 1 ? a : b}</p>
16+
<Component {a} {count} c={a+b} />

0 commit comments

Comments
 (0)