diff --git a/test/js/samples/var-in-block/expected.js b/test/js/samples/var-in-block/expected.js new file mode 100644 index 0000000000..53e0e43530 --- /dev/null +++ b/test/js/samples/var-in-block/expected.js @@ -0,0 +1,46 @@ +/* generated by Svelte vX.Y.Z */ +import { + SvelteComponent, + detach, + init, + insert, + noop, + safe_not_equal, + text +} from "svelte/internal"; + +function create_fragment(ctx) { + let t; + + return { + c() { + t = text(/*one*/ ctx[0]); + }, + m(target, anchor) { + insert(target, t, anchor); + }, + p: noop, + i: noop, + o: noop, + d(detaching) { + if (detaching) detach(t); + } + }; +} + +function instance($$self) { + { + var one = 1; + } + + return [one]; +} + +class Component extends SvelteComponent { + constructor(options) { + super(); + init(this, options, instance, create_fragment, safe_not_equal, {}); + } +} + +export default Component; \ No newline at end of file diff --git a/test/js/samples/var-in-block/input.svelte b/test/js/samples/var-in-block/input.svelte new file mode 100644 index 0000000000..5aa45f0aa4 --- /dev/null +++ b/test/js/samples/var-in-block/input.svelte @@ -0,0 +1,7 @@ + + +{one} diff --git a/test/runtime/samples/var-in-block/_config.js b/test/runtime/samples/var-in-block/_config.js new file mode 100644 index 0000000000..69523b27b4 --- /dev/null +++ b/test/runtime/samples/var-in-block/_config.js @@ -0,0 +1,3 @@ +export default { + html: '
12345
67890
' +} diff --git a/test/runtime/samples/var-in-block/main.svelte b/test/runtime/samples/var-in-block/main.svelte new file mode 100644 index 0000000000..ee3ca575a9 --- /dev/null +++ b/test/runtime/samples/var-in-block/main.svelte @@ -0,0 +1,9 @@ + + +{foo}
+{bar}
diff --git a/test/runtime/samples/var-in-for-in-loop/_config.js b/test/runtime/samples/var-in-for-in-loop/_config.js new file mode 100644 index 0000000000..65ef73b63f --- /dev/null +++ b/test/runtime/samples/var-in-for-in-loop/_config.js @@ -0,0 +1,3 @@ +export default { + html: '0
2
4
6
8
' +} diff --git a/test/runtime/samples/var-in-for-in-loop/main.svelte b/test/runtime/samples/var-in-for-in-loop/main.svelte new file mode 100644 index 0000000000..8cc83d9305 --- /dev/null +++ b/test/runtime/samples/var-in-for-in-loop/main.svelte @@ -0,0 +1,10 @@ + + +{#each array as a} +{a}
+{/each} diff --git a/test/runtime/samples/var-in-for-loop/_config.js b/test/runtime/samples/var-in-for-loop/_config.js new file mode 100644 index 0000000000..ba7a73f4ef --- /dev/null +++ b/test/runtime/samples/var-in-for-loop/_config.js @@ -0,0 +1,3 @@ +export default { + html: '0
1
2
3
4
' +} diff --git a/test/runtime/samples/var-in-for-loop/main.svelte b/test/runtime/samples/var-in-for-loop/main.svelte new file mode 100644 index 0000000000..acf38eecae --- /dev/null +++ b/test/runtime/samples/var-in-for-loop/main.svelte @@ -0,0 +1,10 @@ + + +{#each array as a} +{a}
+{/each} diff --git a/test/runtime/samples/var-in-function/_config.js b/test/runtime/samples/var-in-function/_config.js new file mode 100644 index 0000000000..f5c4a16cc0 --- /dev/null +++ b/test/runtime/samples/var-in-function/_config.js @@ -0,0 +1,11 @@ +export default { + html: '0
', + + async test({ assert, target, window }) { + const button = target.querySelector('button'); + const clickEvent = new window.MouseEvent('click'); + + await button.dispatchEvent(clickEvent); + assert.htmlEqual(target.innerHTML, '4
'); + } +}; diff --git a/test/runtime/samples/var-in-function/main.svelte b/test/runtime/samples/var-in-function/main.svelte new file mode 100644 index 0000000000..1dab3ff6b6 --- /dev/null +++ b/test/runtime/samples/var-in-function/main.svelte @@ -0,0 +1,10 @@ + + + +{foo}
diff --git a/test/runtime/samples/var-in-if-block/_config.js b/test/runtime/samples/var-in-if-block/_config.js new file mode 100644 index 0000000000..ac343ee414 --- /dev/null +++ b/test/runtime/samples/var-in-if-block/_config.js @@ -0,0 +1,13 @@ +export default { + props: { + condition: true + }, + + html: 'true
123
0
', + + test({ assert, component, target }) { + component.condition = false; + + assert.htmlEqual(target.innerHTML, 'false
123
0
'); + } +}; diff --git a/test/runtime/samples/var-in-if-block/main.svelte b/test/runtime/samples/var-in-if-block/main.svelte new file mode 100644 index 0000000000..fe65066444 --- /dev/null +++ b/test/runtime/samples/var-in-if-block/main.svelte @@ -0,0 +1,15 @@ + + +{condition}
+{b}
+{c}
diff --git a/test/runtime/samples/var-in-while-block/_config.js b/test/runtime/samples/var-in-while-block/_config.js new file mode 100644 index 0000000000..1ba2c535ec --- /dev/null +++ b/test/runtime/samples/var-in-while-block/_config.js @@ -0,0 +1,7 @@ +export default { + props: { + a: 13 + }, + + html: '169
' +}; diff --git a/test/runtime/samples/var-in-while-block/main.svelte b/test/runtime/samples/var-in-while-block/main.svelte new file mode 100644 index 0000000000..87a231c37c --- /dev/null +++ b/test/runtime/samples/var-in-while-block/main.svelte @@ -0,0 +1,9 @@ + + +{b}