+ {:else}
+ {datum.bar}
+ {/if}
+{/each}
diff --git a/test/runtime/samples/each-block-scope-shadow-self/_config.js b/test/runtime/samples/each-block-scope-shadow-self/_config.js
new file mode 100644
index 0000000000..1669dc5b6e
--- /dev/null
+++ b/test/runtime/samples/each-block-scope-shadow-self/_config.js
@@ -0,0 +1,13 @@
+export default {
+ async test({ assert, component, target }) {
+ assert.equal(target.querySelectorAll('input').length, 3);
+
+ const input = target.querySelector('input');
+ input.value = 'svelte';
+ await input.dispatchEvent(new window.Event('input'));
+
+ assert.equal(target.querySelectorAll('input').length, 3);
+ assert.deepEqual(component.data, { a: 'svelte', b: 'B', c: 'C' });
+ assert.deepEqual(component.x, ['a', 'b', 'c']);
+ },
+};
diff --git a/test/runtime/samples/each-block-scope-shadow-self/main.svelte b/test/runtime/samples/each-block-scope-shadow-self/main.svelte
new file mode 100644
index 0000000000..e3643c524a
--- /dev/null
+++ b/test/runtime/samples/each-block-scope-shadow-self/main.svelte
@@ -0,0 +1,15 @@
+
+
+{#each x as x}
+
+{/each}
\ No newline at end of file
diff --git a/test/runtime/samples/each-block-scope-shadow/_config.js b/test/runtime/samples/each-block-scope-shadow/_config.js
index 8005bc93d5..dff254a7c4 100644
--- a/test/runtime/samples/each-block-scope-shadow/_config.js
+++ b/test/runtime/samples/each-block-scope-shadow/_config.js
@@ -1,3 +1,3 @@
export default {
- html: '(alpaca)(baboon)(capybara)'
+ html: '(alpaca)(baboon)(capybara) (lemur)'
};
diff --git a/test/runtime/samples/each-block-scope-shadow/main.svelte b/test/runtime/samples/each-block-scope-shadow/main.svelte
index b6c256e14f..58294d35b4 100644
--- a/test/runtime/samples/each-block-scope-shadow/main.svelte
+++ b/test/runtime/samples/each-block-scope-shadow/main.svelte
@@ -2,7 +2,9 @@
({animal})
{/each}
+({animal})
+
\ No newline at end of file
diff --git a/test/runtime/samples/each-block-string/_config.js b/test/runtime/samples/each-block-string/_config.js
new file mode 100644
index 0000000000..7366c964eb
--- /dev/null
+++ b/test/runtime/samples/each-block-string/_config.js
@@ -0,0 +1,10 @@
+export default {
+ compileOptions: {
+ dev: true
+ },
+ html: `
+ f
+ o
+ o
+ `
+};
diff --git a/test/runtime/samples/each-block-string/main.svelte b/test/runtime/samples/each-block-string/main.svelte
new file mode 100644
index 0000000000..ae60f0f6b3
--- /dev/null
+++ b/test/runtime/samples/each-block-string/main.svelte
@@ -0,0 +1,3 @@
+{#each 'foo' as c}
+ {c}
+{/each}
diff --git a/test/runtime/samples/empty-dom/_config.js b/test/runtime/samples/empty-dom/_config.js
new file mode 100644
index 0000000000..e3e3d0ecd5
--- /dev/null
+++ b/test/runtime/samples/empty-dom/_config.js
@@ -0,0 +1,3 @@
+export default {
+ html: '',
+};
\ No newline at end of file
diff --git a/test/runtime/samples/empty-dom/main.svelte b/test/runtime/samples/empty-dom/main.svelte
new file mode 100644
index 0000000000..3098443ea3
--- /dev/null
+++ b/test/runtime/samples/empty-dom/main.svelte
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/test/runtime/samples/event-handler-dynamic-2/_config.js b/test/runtime/samples/event-handler-dynamic-2/_config.js
new file mode 100644
index 0000000000..c996d8f2aa
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-2/_config.js
@@ -0,0 +1,33 @@
+export default {
+ html: `
+ toggle
+ 0
+ handler_a
+ handler_b
+ `,
+
+ async test({ assert, target, window }) {
+ const [toggle, handler_a, handler_b] = target.querySelectorAll('button');
+ const p = target.querySelector('p');
+
+ const event = new window.MouseEvent('click');
+
+ await handler_a.dispatchEvent(event);
+ assert.equal(p.innerHTML, '1');
+
+ await toggle.dispatchEvent(event);
+
+ await handler_a.dispatchEvent(event);
+ assert.equal(p.innerHTML, '2');
+
+ await toggle.dispatchEvent(event);
+
+ await handler_b.dispatchEvent(event);
+ assert.equal(p.innerHTML, '1');
+
+ await toggle.dispatchEvent(event);
+
+ await handler_b.dispatchEvent(event);
+ assert.equal(p.innerHTML, '2');
+ },
+};
diff --git a/test/runtime/samples/event-handler-dynamic-2/main.svelte b/test/runtime/samples/event-handler-dynamic-2/main.svelte
new file mode 100644
index 0000000000..1b2041d3b8
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-2/main.svelte
@@ -0,0 +1,20 @@
+
+
+ flag = !flag}>toggle
+
+{number}
+
+handler_a
+handler_b
diff --git a/test/runtime/samples/event-handler-dynamic-bound-var/Nested.svelte b/test/runtime/samples/event-handler-dynamic-bound-var/Nested.svelte
new file mode 100644
index 0000000000..948fc308c0
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-bound-var/Nested.svelte
@@ -0,0 +1,7 @@
+
+{text}
\ No newline at end of file
diff --git a/test/runtime/samples/event-handler-dynamic-bound-var/_config.js b/test/runtime/samples/event-handler-dynamic-bound-var/_config.js
new file mode 100644
index 0000000000..c832127c09
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-bound-var/_config.js
@@ -0,0 +1,20 @@
+export default {
+ html: `
+ Click Me
+ Hello World
+ `,
+ async test({ assert, component, target, window }) {
+ const button = target.querySelector('button');
+
+ const event = new window.MouseEvent('click');
+
+ await button.dispatchEvent(event);
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ Click Me
+ Bye World
+ `
+ );
+ },
+};
diff --git a/test/runtime/samples/event-handler-dynamic-bound-var/main.svelte b/test/runtime/samples/event-handler-dynamic-bound-var/main.svelte
new file mode 100644
index 0000000000..bb7d9befc4
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-bound-var/main.svelte
@@ -0,0 +1,8 @@
+
+
+Click Me
+
+
diff --git a/test/runtime/samples/event-handler-dynamic-expression/_config.js b/test/runtime/samples/event-handler-dynamic-expression/_config.js
new file mode 100644
index 0000000000..c4d259a542
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-expression/_config.js
@@ -0,0 +1,20 @@
+export default {
+ html: `bar `,
+
+ async test({ assert, component, target, window }) {
+ const [button] = target.querySelectorAll(
+ 'button'
+ );
+
+ const event = new window.MouseEvent('click');
+
+ await button.dispatchEvent(event);
+ assert.htmlEqual(target.innerHTML, `foo `);
+
+ await button.dispatchEvent(event);
+ assert.htmlEqual(target.innerHTML, `bar `);
+
+ await button.dispatchEvent(event);
+ assert.htmlEqual(target.innerHTML, `foo `);
+ },
+};
diff --git a/test/runtime/samples/event-handler-dynamic-expression/main.svelte b/test/runtime/samples/event-handler-dynamic-expression/main.svelte
new file mode 100644
index 0000000000..f53aa7aadd
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-expression/main.svelte
@@ -0,0 +1,12 @@
+
+
+{name}
\ No newline at end of file
diff --git a/test/runtime/samples/event-handler-dynamic-hash/_config.js b/test/runtime/samples/event-handler-dynamic-hash/_config.js
new file mode 100644
index 0000000000..e60e561524
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-hash/_config.js
@@ -0,0 +1,56 @@
+export default {
+ html: `
+
+ set handler 1
+ set handler 2
+
+ 0
+ click
+ `,
+
+ async test({ assert, component, target, window }) {
+ const [updateButton1, updateButton2, button] = target.querySelectorAll(
+ 'button'
+ );
+
+ const event = new window.MouseEvent('click');
+ let err = "";
+ window.addEventListener('error', (e) => {
+ e.preventDefault();
+ err = e.message;
+ });
+
+ await button.dispatchEvent(event);
+ assert.equal(err, "", err);
+ assert.htmlEqual(target.innerHTML, `
+
+ set handler 1
+ set handler 2
+
+ 0
+ click
+ `);
+
+ await updateButton1.dispatchEvent(event);
+ await button.dispatchEvent(event);
+ assert.htmlEqual(target.innerHTML, `
+
+ set handler 1
+ set handler 2
+
+ 1
+ click
+ `);
+
+ await updateButton2.dispatchEvent(event);
+ await button.dispatchEvent(event);
+ assert.htmlEqual(target.innerHTML, `
+
+ set handler 1
+ set handler 2
+
+ 2
+ click
+ `);
+ },
+};
diff --git a/test/runtime/samples/event-handler-dynamic-hash/main.svelte b/test/runtime/samples/event-handler-dynamic-hash/main.svelte
new file mode 100644
index 0000000000..c81af02006
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-hash/main.svelte
@@ -0,0 +1,23 @@
+
+
+
+set handler 1
+set handler 2
+
+
+{ number }
+
+click
\ No newline at end of file
diff --git a/test/runtime/samples/event-handler-dynamic-invalid/_config.js b/test/runtime/samples/event-handler-dynamic-invalid/_config.js
new file mode 100644
index 0000000000..ba1777f945
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-invalid/_config.js
@@ -0,0 +1,28 @@
+export default {
+ html: `undef
+ null
+ invalid `,
+
+ async test({ assert, component, target, window }) {
+ const [buttonUndef, buttonNull, buttonInvalid] = target.querySelectorAll(
+ 'button'
+ );
+
+ const event = new window.MouseEvent('click');
+ let err = "";
+ window.addEventListener('error', (e) => {
+ e.preventDefault();
+ err = e.message;
+ });
+
+ // All three should not throw if proper checking is done in runtime code
+ await buttonUndef.dispatchEvent(event);
+ assert.equal(err, "", err);
+
+ await buttonNull.dispatchEvent(event);
+ assert.equal(err, "", err);
+
+ await buttonInvalid.dispatchEvent(event);
+ assert.equal(err, "", err);
+ },
+};
diff --git a/test/runtime/samples/event-handler-dynamic-invalid/main.svelte b/test/runtime/samples/event-handler-dynamic-invalid/main.svelte
new file mode 100644
index 0000000000..f4e8c5fdb7
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-invalid/main.svelte
@@ -0,0 +1,13 @@
+
+
+undef
+null
+invalid
diff --git a/test/runtime/samples/event-handler-dynamic-modifier-once/_config.js b/test/runtime/samples/event-handler-dynamic-modifier-once/_config.js
new file mode 100644
index 0000000000..41daf374c8
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-modifier-once/_config.js
@@ -0,0 +1,16 @@
+export default {
+ html: `
+ 0
+ `,
+
+ async test({ assert, component, target, window }) {
+ const button = target.querySelector('button');
+ const event = new window.MouseEvent('click');
+
+ await button.dispatchEvent(event);
+ assert.equal(component.count, 1);
+
+ await button.dispatchEvent(event);
+ assert.equal(component.count, 1);
+ }
+};
diff --git a/test/runtime/samples/event-handler-dynamic-modifier-once/main.svelte b/test/runtime/samples/event-handler-dynamic-modifier-once/main.svelte
new file mode 100644
index 0000000000..d363d708ba
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-modifier-once/main.svelte
@@ -0,0 +1,7 @@
+
+
+{count}
\ No newline at end of file
diff --git a/test/runtime/samples/event-handler-dynamic-modifier-prevent-default/_config.js b/test/runtime/samples/event-handler-dynamic-modifier-prevent-default/_config.js
new file mode 100644
index 0000000000..4fa032bf37
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-modifier-prevent-default/_config.js
@@ -0,0 +1,16 @@
+export default {
+ html: `
+ click me
+ `,
+
+ async test({ assert, component, target, window }) {
+ const button = target.querySelector('button');
+ const event = new window.MouseEvent('click', {
+ cancelable: true
+ });
+
+ await button.dispatchEvent(event);
+
+ assert.ok(component.default_was_prevented);
+ }
+};
diff --git a/test/runtime/samples/event-handler-dynamic-modifier-prevent-default/main.svelte b/test/runtime/samples/event-handler-dynamic-modifier-prevent-default/main.svelte
new file mode 100644
index 0000000000..49d42f3305
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-modifier-prevent-default/main.svelte
@@ -0,0 +1,11 @@
+
+
+click me
\ No newline at end of file
diff --git a/test/runtime/samples/event-handler-dynamic-modifier-self/_config.js b/test/runtime/samples/event-handler-dynamic-modifier-self/_config.js
new file mode 100644
index 0000000000..6d7d29e482
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-modifier-self/_config.js
@@ -0,0 +1,16 @@
+export default {
+ html: `
+
+ click me
+
+ `,
+
+ async test({ assert, component, target, window }) {
+ const button = target.querySelector('button');
+ const event = new window.MouseEvent('click');
+
+ await button.dispatchEvent(event);
+
+ assert.ok(!component.inner_clicked);
+ },
+};
diff --git a/test/runtime/samples/event-handler-dynamic-modifier-self/main.svelte b/test/runtime/samples/event-handler-dynamic-modifier-self/main.svelte
new file mode 100644
index 0000000000..b57d88ec02
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-modifier-self/main.svelte
@@ -0,0 +1,13 @@
+
+
+
+ click me
+
diff --git a/test/runtime/samples/event-handler-dynamic-modifier-stop-propagation/_config.js b/test/runtime/samples/event-handler-dynamic-modifier-stop-propagation/_config.js
new file mode 100644
index 0000000000..8517429e5c
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-modifier-stop-propagation/_config.js
@@ -0,0 +1,19 @@
+export default {
+ html: `
+
+ click me
+
+ `,
+
+ async test({ assert, component, target, window }) {
+ const button = target.querySelector('button');
+ const event = new window.MouseEvent('click', {
+ bubbles: true
+ });
+
+ await button.dispatchEvent(event);
+
+ assert.ok(component.inner_clicked);
+ assert.ok(!component.outer_clicked);
+ }
+};
diff --git a/test/runtime/samples/event-handler-dynamic-modifier-stop-propagation/main.svelte b/test/runtime/samples/event-handler-dynamic-modifier-stop-propagation/main.svelte
new file mode 100644
index 0000000000..bad7359927
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-modifier-stop-propagation/main.svelte
@@ -0,0 +1,20 @@
+
+
+
+ click me
+
\ No newline at end of file
diff --git a/test/runtime/samples/event-handler-dynamic-multiple/_config.js b/test/runtime/samples/event-handler-dynamic-multiple/_config.js
new file mode 100644
index 0000000000..cf17c61f60
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-multiple/_config.js
@@ -0,0 +1,14 @@
+export default {
+ html: `
+ click me
+ `,
+
+ async test({ assert, component, target, window }) {
+ const button = target.querySelector('button');
+ const event = new window.MouseEvent('click');
+
+ await button.dispatchEvent(event);
+ assert.equal(component.clickHandlerOne, 1);
+ assert.equal(component.clickHandlerTwo, 1);
+ }
+};
diff --git a/test/runtime/samples/event-handler-dynamic-multiple/main.svelte b/test/runtime/samples/event-handler-dynamic-multiple/main.svelte
new file mode 100644
index 0000000000..2dbbe61ea6
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic-multiple/main.svelte
@@ -0,0 +1,11 @@
+
+
+click me
diff --git a/test/runtime/samples/event-handler-dynamic/_config.js b/test/runtime/samples/event-handler-dynamic/_config.js
new file mode 100644
index 0000000000..e60e561524
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic/_config.js
@@ -0,0 +1,56 @@
+export default {
+ html: `
+
+ set handler 1
+ set handler 2
+
+ 0
+ click
+ `,
+
+ async test({ assert, component, target, window }) {
+ const [updateButton1, updateButton2, button] = target.querySelectorAll(
+ 'button'
+ );
+
+ const event = new window.MouseEvent('click');
+ let err = "";
+ window.addEventListener('error', (e) => {
+ e.preventDefault();
+ err = e.message;
+ });
+
+ await button.dispatchEvent(event);
+ assert.equal(err, "", err);
+ assert.htmlEqual(target.innerHTML, `
+
+ set handler 1
+ set handler 2
+
+ 0
+ click
+ `);
+
+ await updateButton1.dispatchEvent(event);
+ await button.dispatchEvent(event);
+ assert.htmlEqual(target.innerHTML, `
+
+ set handler 1
+ set handler 2
+
+ 1
+ click
+ `);
+
+ await updateButton2.dispatchEvent(event);
+ await button.dispatchEvent(event);
+ assert.htmlEqual(target.innerHTML, `
+
+ set handler 1
+ set handler 2
+
+ 2
+ click
+ `);
+ },
+};
diff --git a/test/runtime/samples/event-handler-dynamic/main.svelte b/test/runtime/samples/event-handler-dynamic/main.svelte
new file mode 100644
index 0000000000..17c9ae6cf0
--- /dev/null
+++ b/test/runtime/samples/event-handler-dynamic/main.svelte
@@ -0,0 +1,23 @@
+
+
+
+set handler 1
+set handler 2
+
+
+{ number }
+
+click
\ No newline at end of file
diff --git a/test/runtime/samples/event-handler-modifier-body-once/_config.js b/test/runtime/samples/event-handler-modifier-body-once/_config.js
new file mode 100644
index 0000000000..4127034010
--- /dev/null
+++ b/test/runtime/samples/event-handler-modifier-body-once/_config.js
@@ -0,0 +1,11 @@
+export default {
+ async test({ assert, component, window }) {
+ const event = new window.MouseEvent('click');
+
+ await window.document.body.dispatchEvent(event);
+ assert.equal(component.count, 1);
+
+ await window.document.body.dispatchEvent(event);
+ assert.equal(component.count, 1);
+ }
+};
diff --git a/test/runtime/samples/event-handler-modifier-body-once/main.svelte b/test/runtime/samples/event-handler-modifier-body-once/main.svelte
new file mode 100644
index 0000000000..423a75d1f0
--- /dev/null
+++ b/test/runtime/samples/event-handler-modifier-body-once/main.svelte
@@ -0,0 +1,5 @@
+
+
+ count += 1}"/>
\ No newline at end of file
diff --git a/test/runtime/samples/globals-shadowed-by-each-binding/_config.js b/test/runtime/samples/globals-shadowed-by-each-binding/_config.js
new file mode 100644
index 0000000000..f69e5e8b0e
--- /dev/null
+++ b/test/runtime/samples/globals-shadowed-by-each-binding/_config.js
@@ -0,0 +1,3 @@
+export default {
+ html: 'Alert1
Alert2
',
+};
diff --git a/test/runtime/samples/globals-shadowed-by-each-binding/main.svelte b/test/runtime/samples/globals-shadowed-by-each-binding/main.svelte
new file mode 100644
index 0000000000..3d0ac3f3ec
--- /dev/null
+++ b/test/runtime/samples/globals-shadowed-by-each-binding/main.svelte
@@ -0,0 +1,7 @@
+
+
+{#each alerts as alert}
+ {alert}
+{/each}
diff --git a/test/runtime/samples/head-if-block/_config.js b/test/runtime/samples/head-if-block/_config.js
index 439ed2cb1b..cb8b6eccb9 100644
--- a/test/runtime/samples/head-if-block/_config.js
+++ b/test/runtime/samples/head-if-block/_config.js
@@ -3,7 +3,7 @@ export default {
condition: false
},
- test({ assert, component, target, window }) {
+ test({ assert, component, window }) {
assert.equal(window.document.title, '');
component.condition = true;
diff --git a/test/runtime/samples/if-block-component-store-function-conditionals/Widget.svelte b/test/runtime/samples/if-block-component-store-function-conditionals/Widget.svelte
new file mode 100644
index 0000000000..a74ce95de5
--- /dev/null
+++ b/test/runtime/samples/if-block-component-store-function-conditionals/Widget.svelte
@@ -0,0 +1 @@
+OK
\ No newline at end of file
diff --git a/test/runtime/samples/if-block-component-store-function-conditionals/_config.js b/test/runtime/samples/if-block-component-store-function-conditionals/_config.js
new file mode 100644
index 0000000000..db171f2fd1
--- /dev/null
+++ b/test/runtime/samples/if-block-component-store-function-conditionals/_config.js
@@ -0,0 +1,3 @@
+export default {
+ html: 'OK
',
+};
diff --git a/test/runtime/samples/if-block-component-store-function-conditionals/main.svelte b/test/runtime/samples/if-block-component-store-function-conditionals/main.svelte
new file mode 100644
index 0000000000..765654f0d2
--- /dev/null
+++ b/test/runtime/samples/if-block-component-store-function-conditionals/main.svelte
@@ -0,0 +1,12 @@
+
+
+{#if $a || b() }
+
+{:else}
+ fail
+{/if}
\ No newline at end of file
diff --git a/test/runtime/samples/if-block-compound-outro-no-dependencies/_config.js b/test/runtime/samples/if-block-compound-outro-no-dependencies/_config.js
new file mode 100644
index 0000000000..58b0521022
--- /dev/null
+++ b/test/runtime/samples/if-block-compound-outro-no-dependencies/_config.js
@@ -0,0 +1,3 @@
+export default {
+ html: `blah blah blah blah`
+};
diff --git a/test/runtime/samples/if-block-compound-outro-no-dependencies/main.svelte b/test/runtime/samples/if-block-compound-outro-no-dependencies/main.svelte
new file mode 100644
index 0000000000..84224116da
--- /dev/null
+++ b/test/runtime/samples/if-block-compound-outro-no-dependencies/main.svelte
@@ -0,0 +1,32 @@
+
+
+{#if $foo}
+ blah
+{:else}
+ {#if bar()}
+
+ {/if}
+{/if}
+
+{#if $foo}
+ blah
+{:else}
+ {#if bar}
+
+ {/if}
+{/if}
+
+{#if $foo}
+ blah
+{:else if bar()}
+
+{/if}
+
+{#if $foo}
+ blah
+{:else if bar}
+
+{/if}
diff --git a/test/runtime/samples/instrumentation-update-expression/_config.js b/test/runtime/samples/instrumentation-update-expression/_config.js
new file mode 100644
index 0000000000..cc33422f6f
--- /dev/null
+++ b/test/runtime/samples/instrumentation-update-expression/_config.js
@@ -0,0 +1,31 @@
+export default {
+ html: `
+ 0
+ foo++
+ ++foo
+ 0
+ bar.bar++
+ ++bar.bar
+ `,
+ async test({ assert, target, window }) {
+ const [foo, bar] = target.querySelectorAll('p');
+ const [button1, button2, button3, button4] = target.querySelectorAll('button');
+ const event = new window.MouseEvent('click');
+
+ await button1.dispatchEvent(event);
+ assert.equal(foo.innerHTML, '1');
+ assert.equal(bar.innerHTML, '0');
+
+ await button2.dispatchEvent(event);
+ assert.equal(foo.innerHTML, '2');
+ assert.equal(bar.innerHTML, '0');
+
+ await button3.dispatchEvent(event);
+ assert.equal(foo.innerHTML, '2');
+ assert.equal(bar.innerHTML, '1');
+
+ await button4.dispatchEvent(event);
+ assert.equal(foo.innerHTML, '2');
+ assert.equal(bar.innerHTML, '2');
+ }
+};
diff --git a/test/runtime/samples/instrumentation-update-expression/main.svelte b/test/runtime/samples/instrumentation-update-expression/main.svelte
new file mode 100644
index 0000000000..0672f6330d
--- /dev/null
+++ b/test/runtime/samples/instrumentation-update-expression/main.svelte
@@ -0,0 +1,14 @@
+
+
+{foo}
+
+ foo++}>foo++
+ ++foo}>++foo
+
+{bar.bar}
+
+ bar.bar++}>bar.bar++
+ ++bar.bar}>++bar.bar
diff --git a/test/runtime/samples/invalidation-in-if-condition/_config.js b/test/runtime/samples/invalidation-in-if-condition/_config.js
index 60b02d9934..27209c75c9 100644
--- a/test/runtime/samples/invalidation-in-if-condition/_config.js
+++ b/test/runtime/samples/invalidation-in-if-condition/_config.js
@@ -1,5 +1,4 @@
export default {
- show: 1,
html: `false 0 `,
async test({ assert, target, window }) {
diff --git a/test/runtime/samples/keyed-each-dev-unique/_config.js b/test/runtime/samples/keyed-each-dev-unique/_config.js
new file mode 100644
index 0000000000..8f46af9d52
--- /dev/null
+++ b/test/runtime/samples/keyed-each-dev-unique/_config.js
@@ -0,0 +1,7 @@
+export default {
+ compileOptions: {
+ dev: true
+ },
+
+ error: `Cannot have duplicate keys in a keyed each`
+};
diff --git a/test/runtime/samples/keyed-each-dev-unique/main.svelte b/test/runtime/samples/keyed-each-dev-unique/main.svelte
new file mode 100644
index 0000000000..870e7beaa1
--- /dev/null
+++ b/test/runtime/samples/keyed-each-dev-unique/main.svelte
@@ -0,0 +1,7 @@
+
+
+{#each array as item (item)}
+ {item}
+{/each}
diff --git a/test/runtime/samples/lifecycle-onmount-infinite-loop/Child.svelte b/test/runtime/samples/lifecycle-onmount-infinite-loop/Child.svelte
new file mode 100644
index 0000000000..ef16875b64
--- /dev/null
+++ b/test/runtime/samples/lifecycle-onmount-infinite-loop/Child.svelte
@@ -0,0 +1 @@
+Child
diff --git a/test/runtime/samples/lifecycle-onmount-infinite-loop/_config.js b/test/runtime/samples/lifecycle-onmount-infinite-loop/_config.js
new file mode 100644
index 0000000000..a76a2686ac
--- /dev/null
+++ b/test/runtime/samples/lifecycle-onmount-infinite-loop/_config.js
@@ -0,0 +1,6 @@
+export default {
+ test({ assert, component }) {
+ const { count } = component;
+ assert.deepEqual(count, 1);
+ }
+};
diff --git a/test/runtime/samples/lifecycle-onmount-infinite-loop/main.svelte b/test/runtime/samples/lifecycle-onmount-infinite-loop/main.svelte
new file mode 100644
index 0000000000..1fa4263e39
--- /dev/null
+++ b/test/runtime/samples/lifecycle-onmount-infinite-loop/main.svelte
@@ -0,0 +1,16 @@
+
+
+
diff --git a/test/runtime/samples/lifecycle-render-order-for-children/_config.js b/test/runtime/samples/lifecycle-render-order-for-children/_config.js
index a1d35d7aa8..033b593aea 100644
--- a/test/runtime/samples/lifecycle-render-order-for-children/_config.js
+++ b/test/runtime/samples/lifecycle-render-order-for-children/_config.js
@@ -3,26 +3,47 @@ import order from './order.js';
export default {
skip_if_ssr: true,
- test({ assert, component, target }) {
- assert.deepEqual(order, [
- '0: beforeUpdate',
- '0: render',
- '1: beforeUpdate',
- '1: render',
- '2: beforeUpdate',
- '2: render',
- '3: beforeUpdate',
- '3: render',
- '1: onMount',
- '1: afterUpdate',
- '2: onMount',
- '2: afterUpdate',
- '3: onMount',
- '3: afterUpdate',
- '0: onMount',
- '0: afterUpdate'
- ]);
+ test({ assert, component, target, compileOptions }) {
+ if (compileOptions.hydratable) {
+ assert.deepEqual(order, [
+ '0: beforeUpdate',
+ '0: render',
+ '1: beforeUpdate',
+ '1: render',
+ '2: beforeUpdate',
+ '2: render',
+ '3: beforeUpdate',
+ '3: render',
+ '1: onMount',
+ '1: afterUpdate',
+ '2: onMount',
+ '2: afterUpdate',
+ '3: onMount',
+ '3: afterUpdate',
+ '0: onMount',
+ '0: afterUpdate',
+ ]);
+ } else {
+ assert.deepEqual(order, [
+ '0: beforeUpdate',
+ '0: render',
+ '1: beforeUpdate',
+ '2: beforeUpdate',
+ '3: beforeUpdate',
+ '1: render',
+ '2: render',
+ '3: render',
+ '1: onMount',
+ '1: afterUpdate',
+ '2: onMount',
+ '2: afterUpdate',
+ '3: onMount',
+ '3: afterUpdate',
+ '0: onMount',
+ '0: afterUpdate',
+ ]);
+ }
order.length = 0;
- }
+ },
};
diff --git a/test/runtime/samples/loop-protect-inner-function/_config.js b/test/runtime/samples/loop-protect-inner-function/_config.js
new file mode 100644
index 0000000000..862d4f4c0f
--- /dev/null
+++ b/test/runtime/samples/loop-protect-inner-function/_config.js
@@ -0,0 +1,7 @@
+export default {
+ html: '
',
+ compileOptions: {
+ dev: true,
+ loopGuardTimeout: 100,
+ }
+};
diff --git a/test/runtime/samples/loop-protect-inner-function/main.svelte b/test/runtime/samples/loop-protect-inner-function/main.svelte
new file mode 100644
index 0000000000..cf5350efde
--- /dev/null
+++ b/test/runtime/samples/loop-protect-inner-function/main.svelte
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/test/runtime/samples/loop-protect/_config.js b/test/runtime/samples/loop-protect/_config.js
new file mode 100644
index 0000000000..75f75c003d
--- /dev/null
+++ b/test/runtime/samples/loop-protect/_config.js
@@ -0,0 +1,7 @@
+export default {
+ error: 'Infinite loop detected',
+ compileOptions: {
+ dev: true,
+ loopGuardTimeout: 100,
+ }
+};
diff --git a/test/runtime/samples/loop-protect/main.svelte b/test/runtime/samples/loop-protect/main.svelte
new file mode 100644
index 0000000000..aff13c82f1
--- /dev/null
+++ b/test/runtime/samples/loop-protect/main.svelte
@@ -0,0 +1,5 @@
+
\ No newline at end of file
diff --git a/test/runtime/samples/module-context-bind/_config.js b/test/runtime/samples/module-context-bind/_config.js
new file mode 100644
index 0000000000..32bc9c4ce9
--- /dev/null
+++ b/test/runtime/samples/module-context-bind/_config.js
@@ -0,0 +1,4 @@
+export default {
+ skip_if_ssr: true,
+ html: 'object
'
+};
diff --git a/test/runtime/samples/module-context-bind/main.svelte b/test/runtime/samples/module-context-bind/main.svelte
new file mode 100644
index 0000000000..1580102bd8
--- /dev/null
+++ b/test/runtime/samples/module-context-bind/main.svelte
@@ -0,0 +1,11 @@
+
+
+
+
+{typeof bar}
diff --git a/test/runtime/samples/module-context-export/Foo.svelte b/test/runtime/samples/module-context-export/Foo.svelte
new file mode 100644
index 0000000000..c992ceef52
--- /dev/null
+++ b/test/runtime/samples/module-context-export/Foo.svelte
@@ -0,0 +1,7 @@
+
+
diff --git a/test/runtime/samples/module-context-export/_config.js b/test/runtime/samples/module-context-export/_config.js
new file mode 100644
index 0000000000..902501fdd4
--- /dev/null
+++ b/test/runtime/samples/module-context-export/_config.js
@@ -0,0 +1,3 @@
+export default {
+ html: `(42)(99)
`
+};
\ No newline at end of file
diff --git a/test/runtime/samples/module-context-export/main.svelte b/test/runtime/samples/module-context-export/main.svelte
new file mode 100644
index 0000000000..60c130ca2f
--- /dev/null
+++ b/test/runtime/samples/module-context-export/main.svelte
@@ -0,0 +1,6 @@
+
+
+({foo})({bar})
\ No newline at end of file
diff --git a/test/runtime/samples/reactive-block-break/_config.js b/test/runtime/samples/reactive-block-break/_config.js
new file mode 100644
index 0000000000..f2d3e6a8f5
--- /dev/null
+++ b/test/runtime/samples/reactive-block-break/_config.js
@@ -0,0 +1,3 @@
+export default {
+ html: `1 2 `
+};
\ No newline at end of file
diff --git a/test/runtime/samples/reactive-block-break/main.svelte b/test/runtime/samples/reactive-block-break/main.svelte
new file mode 100644
index 0000000000..5b0aa005c0
--- /dev/null
+++ b/test/runtime/samples/reactive-block-break/main.svelte
@@ -0,0 +1,14 @@
+
+
+{foo} {bar}
\ No newline at end of file
diff --git a/test/runtime/samples/reactive-compound-operator/_config.js b/test/runtime/samples/reactive-compound-operator/_config.js
new file mode 100644
index 0000000000..dd59fbbf0a
--- /dev/null
+++ b/test/runtime/samples/reactive-compound-operator/_config.js
@@ -0,0 +1,27 @@
+export default {
+ html: `
+ +1
+ count: 0
+ `,
+
+ async test({ assert, component, target, window }) {
+ const click = new window.MouseEvent('click');
+ const button = target.querySelector('button');
+
+ await button.dispatchEvent(click);
+
+ assert.equal(component.x, 2);
+ assert.htmlEqual(target.innerHTML, `
+ +1
+ count: 2
+ `);
+
+ await button.dispatchEvent(click);
+
+ assert.equal(component.x, 6);
+ assert.htmlEqual(target.innerHTML, `
+ +1
+ count: 6
+ `);
+ }
+};
diff --git a/test/runtime/samples/reactive-compound-operator/main.svelte b/test/runtime/samples/reactive-compound-operator/main.svelte
new file mode 100644
index 0000000000..52654aed59
--- /dev/null
+++ b/test/runtime/samples/reactive-compound-operator/main.svelte
@@ -0,0 +1,8 @@
+
+
++1
+count: {x}
diff --git a/test/runtime/samples/reactive-update-expression/_config.js b/test/runtime/samples/reactive-update-expression/_config.js
new file mode 100644
index 0000000000..111460f7dd
--- /dev/null
+++ b/test/runtime/samples/reactive-update-expression/_config.js
@@ -0,0 +1,29 @@
+export default {
+ html: `
+ +1
+ count: 1
+ `,
+
+ async test({ assert, component, target, window }) {
+ const click = new window.MouseEvent('click');
+ const button = target.querySelector('button');
+
+ assert.equal(component.x, 1);
+
+ await button.dispatchEvent(click);
+
+ assert.equal(component.x, 3);
+ assert.htmlEqual(target.innerHTML, `
+ +1
+ count: 3
+ `);
+
+ await button.dispatchEvent(click);
+
+ assert.equal(component.x, 5);
+ assert.htmlEqual(target.innerHTML, `
+ +1
+ count: 5
+ `);
+ }
+};
diff --git a/test/runtime/samples/reactive-update-expression/main.svelte b/test/runtime/samples/reactive-update-expression/main.svelte
new file mode 100644
index 0000000000..0e0b45ddd6
--- /dev/null
+++ b/test/runtime/samples/reactive-update-expression/main.svelte
@@ -0,0 +1,12 @@
+
+
++1
+count: {x}
diff --git a/test/runtime/samples/reactive-value-coerce-precedence/_config.js b/test/runtime/samples/reactive-value-coerce-precedence/_config.js
new file mode 100644
index 0000000000..4fe47e26fa
--- /dev/null
+++ b/test/runtime/samples/reactive-value-coerce-precedence/_config.js
@@ -0,0 +1,5 @@
+export default {
+ html: `
+ true
+ `
+};
diff --git a/test/runtime/samples/reactive-value-coerce-precedence/main.svelte b/test/runtime/samples/reactive-value-coerce-precedence/main.svelte
new file mode 100644
index 0000000000..fc73456e9e
--- /dev/null
+++ b/test/runtime/samples/reactive-value-coerce-precedence/main.svelte
@@ -0,0 +1 @@
+{1 === 1}
\ No newline at end of file
diff --git a/test/runtime/samples/reactive-values-implicit-self-dependency/_config.js b/test/runtime/samples/reactive-values-implicit-self-dependency/_config.js
index d7f2bbf920..f215de098e 100644
--- a/test/runtime/samples/reactive-values-implicit-self-dependency/_config.js
+++ b/test/runtime/samples/reactive-values-implicit-self-dependency/_config.js
@@ -1,5 +1,4 @@
export default {
- show: 1,
html: `
1 / 1
`,
diff --git a/test/runtime/samples/reactive-values-no-implicit-member-expression/_config.js b/test/runtime/samples/reactive-values-no-implicit-member-expression/_config.js
new file mode 100644
index 0000000000..05a8159589
--- /dev/null
+++ b/test/runtime/samples/reactive-values-no-implicit-member-expression/_config.js
@@ -0,0 +1,5 @@
+export default {
+ test({ assert, window }) {
+ assert.equal(window.document.title, 'foo');
+ }
+};
diff --git a/test/runtime/samples/reactive-values-no-implicit-member-expression/main.svelte b/test/runtime/samples/reactive-values-no-implicit-member-expression/main.svelte
new file mode 100644
index 0000000000..a631d4d9f8
--- /dev/null
+++ b/test/runtime/samples/reactive-values-no-implicit-member-expression/main.svelte
@@ -0,0 +1,3 @@
+
diff --git a/test/runtime/samples/reactive-values-store-destructured-undefined/_config.js b/test/runtime/samples/reactive-values-store-destructured-undefined/_config.js
new file mode 100644
index 0000000000..5e3f15f5dc
--- /dev/null
+++ b/test/runtime/samples/reactive-values-store-destructured-undefined/_config.js
@@ -0,0 +1,6 @@
+export default {
+ html: `
+ undefined
+ undefined
+ `
+};
diff --git a/test/runtime/samples/reactive-values-store-destructured-undefined/main.svelte b/test/runtime/samples/reactive-values-store-destructured-undefined/main.svelte
new file mode 100644
index 0000000000..152e0e3e2e
--- /dev/null
+++ b/test/runtime/samples/reactive-values-store-destructured-undefined/main.svelte
@@ -0,0 +1,9 @@
+
+
+{foo1}
+{foo2}
diff --git a/test/runtime/samples/semicolon-hoisting/_config.js b/test/runtime/samples/semicolon-hoisting/_config.js
new file mode 100644
index 0000000000..88d81cdc9e
--- /dev/null
+++ b/test/runtime/samples/semicolon-hoisting/_config.js
@@ -0,0 +1,3 @@
+export default {
+ html: ``
+};
\ No newline at end of file
diff --git a/test/runtime/samples/semicolon-hoisting/main.svelte b/test/runtime/samples/semicolon-hoisting/main.svelte
new file mode 100644
index 0000000000..234fa715d2
--- /dev/null
+++ b/test/runtime/samples/semicolon-hoisting/main.svelte
@@ -0,0 +1,6 @@
+
\ No newline at end of file
diff --git a/test/runtime/samples/sigil-expression-function-body/_config.js b/test/runtime/samples/sigil-expression-function-body/_config.js
new file mode 100644
index 0000000000..fccd0db2d0
--- /dev/null
+++ b/test/runtime/samples/sigil-expression-function-body/_config.js
@@ -0,0 +1,3 @@
+export default {
+ html: `@foo`
+};
diff --git a/test/runtime/samples/sigil-expression-function-body/main.svelte b/test/runtime/samples/sigil-expression-function-body/main.svelte
new file mode 100644
index 0000000000..074496d6f4
--- /dev/null
+++ b/test/runtime/samples/sigil-expression-function-body/main.svelte
@@ -0,0 +1 @@
+{(() => '@foo')()}
diff --git a/test/runtime/samples/spread-element-class/_config.js b/test/runtime/samples/spread-element-class/_config.js
new file mode 100644
index 0000000000..7fc3d49012
--- /dev/null
+++ b/test/runtime/samples/spread-element-class/_config.js
@@ -0,0 +1,7 @@
+export default {
+ html: `hello
`,
+ test({ assert, component, target }) {
+ component.blah = 'goodbye';
+ assert.htmlEqual(target.innerHTML, `goodbye
`);
+ }
+};
diff --git a/test/runtime/samples/spread-element-class/main.svelte b/test/runtime/samples/spread-element-class/main.svelte
new file mode 100644
index 0000000000..026132287b
--- /dev/null
+++ b/test/runtime/samples/spread-element-class/main.svelte
@@ -0,0 +1,5 @@
+
+
+{blah}
diff --git a/test/runtime/samples/spread-element-readonly/_config.js b/test/runtime/samples/spread-element-readonly/_config.js
new file mode 100644
index 0000000000..1d349fd76f
--- /dev/null
+++ b/test/runtime/samples/spread-element-readonly/_config.js
@@ -0,0 +1,9 @@
+export default {
+ skip_if_ssr: true, // DOM and SSR output is different, a separate SSR test exists
+ html: ` `,
+
+ test({ assert, target }) {
+ const div = target.querySelector('input');
+ assert.equal(div.value, 'bar');
+ }
+};
diff --git a/test/runtime/samples/spread-element-readonly/main.svelte b/test/runtime/samples/spread-element-readonly/main.svelte
new file mode 100644
index 0000000000..fc8c849396
--- /dev/null
+++ b/test/runtime/samples/spread-element-readonly/main.svelte
@@ -0,0 +1,9 @@
+
+
+
diff --git a/test/runtime/samples/spread-element-removal/_config.js b/test/runtime/samples/spread-element-removal/_config.js
new file mode 100644
index 0000000000..270804170d
--- /dev/null
+++ b/test/runtime/samples/spread-element-removal/_config.js
@@ -0,0 +1,3 @@
+export default {
+ html: ` `
+};
diff --git a/test/runtime/samples/spread-element-removal/main.svelte b/test/runtime/samples/spread-element-removal/main.svelte
new file mode 100644
index 0000000000..f6adc82c80
--- /dev/null
+++ b/test/runtime/samples/spread-element-removal/main.svelte
@@ -0,0 +1 @@
+
diff --git a/test/runtime/samples/spread-element-scope/_config.js b/test/runtime/samples/spread-element-scope/_config.js
new file mode 100644
index 0000000000..457524ca37
--- /dev/null
+++ b/test/runtime/samples/spread-element-scope/_config.js
@@ -0,0 +1,7 @@
+export default {
+ html: `
+ red
+ red
+ red and bold
+ `
+};
diff --git a/test/runtime/samples/spread-element-scope/main.svelte b/test/runtime/samples/spread-element-scope/main.svelte
new file mode 100644
index 0000000000..7a25f90939
--- /dev/null
+++ b/test/runtime/samples/spread-element-scope/main.svelte
@@ -0,0 +1,10 @@
+
+
+red
+
+red
+
+red and bold
diff --git a/test/runtime/samples/store-auto-subscribe-event-callback/_config.js b/test/runtime/samples/store-auto-subscribe-event-callback/_config.js
new file mode 100644
index 0000000000..747ed3e4ad
--- /dev/null
+++ b/test/runtime/samples/store-auto-subscribe-event-callback/_config.js
@@ -0,0 +1,22 @@
+export default {
+ html: `
+
+ Dirty: false
+ Valid: false
+ `,
+
+ async test({ assert, target, window }) {
+ const input = target.querySelector('input');
+
+ input.value = 'foo';
+ const inputEvent = new window.InputEvent('input');
+
+ await input.dispatchEvent(inputEvent);
+
+ assert.htmlEqual(target.innerHTML, `
+
+ Dirty: true
+ Valid: true
+ `);
+ },
+};
diff --git a/test/runtime/samples/store-auto-subscribe-event-callback/main.svelte b/test/runtime/samples/store-auto-subscribe-event-callback/main.svelte
new file mode 100644
index 0000000000..eca7c202cd
--- /dev/null
+++ b/test/runtime/samples/store-auto-subscribe-event-callback/main.svelte
@@ -0,0 +1,29 @@
+
+
+
+
+Dirty: {$validity.dirty}
+Valid: {$validity.valid}
diff --git a/test/runtime/samples/store-auto-subscribe-nullish/_config.js b/test/runtime/samples/store-auto-subscribe-nullish/_config.js
new file mode 100644
index 0000000000..52e21cef05
--- /dev/null
+++ b/test/runtime/samples/store-auto-subscribe-nullish/_config.js
@@ -0,0 +1,13 @@
+import { writable } from '../../../../store';
+
+export default {
+ html: `
+ undefined
+ `,
+ async test({ assert, component, target }) {
+ component.store = writable('foo');
+ assert.htmlEqual(target.innerHTML, `
+ foo
+ `);
+ }
+};
diff --git a/test/runtime/samples/store-auto-subscribe-nullish/main.svelte b/test/runtime/samples/store-auto-subscribe-nullish/main.svelte
new file mode 100644
index 0000000000..9c1ed4a560
--- /dev/null
+++ b/test/runtime/samples/store-auto-subscribe-nullish/main.svelte
@@ -0,0 +1,5 @@
+
+
+{$store}
diff --git a/test/runtime/samples/store-imported/_config.js b/test/runtime/samples/store-imported/_config.js
index c2d471a329..251866e5ba 100644
--- a/test/runtime/samples/store-imported/_config.js
+++ b/test/runtime/samples/store-imported/_config.js
@@ -1,4 +1,6 @@
export default {
+ compileOptions: { dev: true }, // tests `@validate_store` code generation
+
html: `
42
`
diff --git a/test/runtime/samples/store-invalidation-while-update-1/_config.js b/test/runtime/samples/store-invalidation-while-update-1/_config.js
new file mode 100644
index 0000000000..d0361d2d23
--- /dev/null
+++ b/test/runtime/samples/store-invalidation-while-update-1/_config.js
@@ -0,0 +1,44 @@
+export default {
+ html: `
+
+
+ simple
+ click me
+ `,
+
+ async test({ assert, component, target, window }) {
+ const input = target.querySelector('input');
+ const button = target.querySelector('button');
+
+ const inputEvent = new window.InputEvent('input');
+ const clickEvent = new window.MouseEvent('click');
+
+ input.value = 'foo';
+ await input.dispatchEvent(inputEvent);
+
+ assert.htmlEqual(target.innerHTML, `
+
+ foo
+ foo
+ click me
+ `);
+
+ await button.dispatchEvent(clickEvent);
+ assert.htmlEqual(target.innerHTML, `
+
+ foo
+ clicked
+ click me
+ `);
+
+ input.value = 'bar';
+ await input.dispatchEvent(inputEvent);
+
+ assert.htmlEqual(target.innerHTML, `
+
+ bar
+ bar
+ click me
+ `);
+ }
+};
\ No newline at end of file
diff --git a/test/runtime/samples/store-invalidation-while-update-1/main.svelte b/test/runtime/samples/store-invalidation-while-update-1/main.svelte
new file mode 100644
index 0000000000..f74808ee2e
--- /dev/null
+++ b/test/runtime/samples/store-invalidation-while-update-1/main.svelte
@@ -0,0 +1,20 @@
+
+
+
+{v}
+{$s}
+click me
diff --git a/test/runtime/samples/store-invalidation-while-update-2/_config.js b/test/runtime/samples/store-invalidation-while-update-2/_config.js
new file mode 100644
index 0000000000..422034bc11
--- /dev/null
+++ b/test/runtime/samples/store-invalidation-while-update-2/_config.js
@@ -0,0 +1,44 @@
+export default {
+ html: `
+
+ simple
+
+ click me
+ `,
+
+ async test({ assert, component, target, window }) {
+ const input = target.querySelector('input');
+ const button = target.querySelector('button');
+
+ const inputEvent = new window.InputEvent('input');
+ const clickEvent = new window.MouseEvent('click');
+
+ input.value = 'foo';
+ await input.dispatchEvent(inputEvent);
+
+ assert.htmlEqual(target.innerHTML, `
+ foo
+ foo
+
+ click me
+ `);
+
+ await button.dispatchEvent(clickEvent);
+ assert.htmlEqual(target.innerHTML, `
+ foo
+ clicked
+
+ click me
+ `);
+
+ input.value = 'bar';
+ await input.dispatchEvent(inputEvent);
+
+ assert.htmlEqual(target.innerHTML, `
+ bar
+ bar
+
+ click me
+ `);
+ }
+};
\ No newline at end of file
diff --git a/test/runtime/samples/store-invalidation-while-update-2/main.svelte b/test/runtime/samples/store-invalidation-while-update-2/main.svelte
new file mode 100644
index 0000000000..83e13742ce
--- /dev/null
+++ b/test/runtime/samples/store-invalidation-while-update-2/main.svelte
@@ -0,0 +1,20 @@
+
+
+{v}
+{$s}
+
+click me
diff --git a/test/runtime/samples/store-resubscribe-export/_config.js b/test/runtime/samples/store-resubscribe-export/_config.js
new file mode 100644
index 0000000000..b6e6f11344
--- /dev/null
+++ b/test/runtime/samples/store-resubscribe-export/_config.js
@@ -0,0 +1,27 @@
+let subscribeCalled = false;
+
+const fakeStore = val => ({
+ subscribe: cb => {
+ cb(val);
+ return {
+ unsubscribe: () => {
+ subscribeCalled = true;
+ },
+ };
+ },
+});
+
+export default {
+ props: {
+ foo: fakeStore(1),
+ },
+ html: `
+ 1
+ `,
+
+ async test({ assert, component, target }) {
+ component.foo = fakeStore(5);
+
+ return assert.htmlEqual(target.innerHTML, `5 `);
+ },
+};
diff --git a/test/runtime/samples/store-resubscribe-export/main.svelte b/test/runtime/samples/store-resubscribe-export/main.svelte
new file mode 100644
index 0000000000..44b00544b7
--- /dev/null
+++ b/test/runtime/samples/store-resubscribe-export/main.svelte
@@ -0,0 +1,6 @@
+
+
+{$foo}
diff --git a/test/runtime/samples/svg-tspan-preserve-space/_config.js b/test/runtime/samples/svg-tspan-preserve-space/_config.js
new file mode 100644
index 0000000000..283af0a2b0
--- /dev/null
+++ b/test/runtime/samples/svg-tspan-preserve-space/_config.js
@@ -0,0 +1,3 @@
+export default {
+ html: `foo barfoo bar `,
+};
diff --git a/test/runtime/samples/svg-tspan-preserve-space/main.svelte b/test/runtime/samples/svg-tspan-preserve-space/main.svelte
new file mode 100644
index 0000000000..df43d575a9
--- /dev/null
+++ b/test/runtime/samples/svg-tspan-preserve-space/main.svelte
@@ -0,0 +1 @@
+foo {"bar"}foo bar
\ No newline at end of file
diff --git a/test/runtime/samples/transition-js-nested-each/_config.js b/test/runtime/samples/transition-js-nested-each/_config.js
index 3d2fe3c32e..c21024dd69 100644
--- a/test/runtime/samples/transition-js-nested-each/_config.js
+++ b/test/runtime/samples/transition-js-nested-each/_config.js
@@ -4,7 +4,7 @@ export default {
things: ['a']
},
- test({ assert, component, target, window, raf }) {
+ test({ assert, component, target, raf }) {
component.x = true;
const div = target.querySelector('div');
diff --git a/test/runtime/samples/unchanged-expression-escape/_config.js b/test/runtime/samples/unchanged-expression-escape/_config.js
new file mode 100644
index 0000000000..11a54c0fe9
--- /dev/null
+++ b/test/runtime/samples/unchanged-expression-escape/_config.js
@@ -0,0 +1,7 @@
+export default {
+ html: `
+ Hello world, what's up? this & that
+ Hello world, what's up? this & that
+ Hello world, what's up? this & that
+ `,
+};
diff --git a/test/runtime/samples/unchanged-expression-escape/main.svelte b/test/runtime/samples/unchanged-expression-escape/main.svelte
new file mode 100644
index 0000000000..de61ba5906
--- /dev/null
+++ b/test/runtime/samples/unchanged-expression-escape/main.svelte
@@ -0,0 +1,7 @@
+
+
+Hello {name}, what's up? this & that
+Hello world, what's up? this & that
+Hello {name}, what's up? this & that
\ No newline at end of file
diff --git a/test/runtime/samples/unchanged-expression-xss/_config.js b/test/runtime/samples/unchanged-expression-xss/_config.js
new file mode 100644
index 0000000000..fa5453dbf3
--- /dev/null
+++ b/test/runtime/samples/unchanged-expression-xss/_config.js
@@ -0,0 +1,3 @@
+export default {
+ html: `<b\nstyle='color:\nred;'>RED?!?</b>
`,
+};
diff --git a/test/runtime/samples/unchanged-expression-xss/main.svelte b/test/runtime/samples/unchanged-expression-xss/main.svelte
new file mode 100644
index 0000000000..c2003d07ae
--- /dev/null
+++ b/test/runtime/samples/unchanged-expression-xss/main.svelte
@@ -0,0 +1,5 @@
+
+
+{content}
\ No newline at end of file
diff --git a/test/runtime/samples/window-bind-scroll-update/_config.js b/test/runtime/samples/window-bind-scroll-update/_config.js
index b9b620d1cd..cb13ea11c2 100644
--- a/test/runtime/samples/window-bind-scroll-update/_config.js
+++ b/test/runtime/samples/window-bind-scroll-update/_config.js
@@ -1,10 +1,37 @@
+import { env, useFakeTimers } from "../../../helpers";
+
+let clock;
+
export default {
- skip: true, // JSDOM
+ before_test() {
+ clock = useFakeTimers();
+
+ const window = env();
+ Object.defineProperties(window, {
+ pageYOffset: {
+ value: 0,
+ configurable: true
+ },
+ pageXOffset: {
+ value: 0,
+ configurable: true
+ }
+ });
+ },
- test({ assert, component, target, window }) {
+ after_test() {
+ clock.removeFakeTimers();
+ clock = null;
+ },
+
+ async test({ assert, component, target, window }) {
assert.equal(window.pageYOffset, 0);
+ // clear the previous 'scrolling' state
+ clock.flush();
component.scrollY = 100;
+
+ clock.flush();
assert.equal(window.pageYOffset, 100);
- }
-};
\ No newline at end of file
+ },
+};
diff --git a/test/runtime/samples/window-binding-resize/_config.js b/test/runtime/samples/window-binding-resize/_config.js
index d8fbe69f75..1429f67db8 100644
--- a/test/runtime/samples/window-binding-resize/_config.js
+++ b/test/runtime/samples/window-binding-resize/_config.js
@@ -1,16 +1,25 @@
export default {
html: `1024x768
`,
- skip: true, // some weird stuff happening with JSDOM 11
- // skip: /^v4/.test(process.version), // node 4 apparently does some dumb stuff
+ before_test() {
+ Object.defineProperties(window, {
+ innerWidth: {
+ value: 1024,
+ configurable: true
+ },
+ innerHeight: {
+ value: 768,
+ configurable: true
+ }
+ });
+ },
+
skip_if_ssr: true, // there's some kind of weird bug with this test... it compiles with the wrong require.extensions hook for some bizarre reason
async test({ assert, component, target, window }) {
const event = new window.Event('resize');
- // JSDOM executes window event listeners with `global` rather than
- // `window` (bug?) so we need to do this
- Object.defineProperties(global, {
+ Object.defineProperties(window, {
innerWidth: {
value: 567,
configurable: true
diff --git a/test/runtime/samples/window-binding-scroll-store/_config.js b/test/runtime/samples/window-binding-scroll-store/_config.js
new file mode 100644
index 0000000000..dbab4b36ac
--- /dev/null
+++ b/test/runtime/samples/window-binding-scroll-store/_config.js
@@ -0,0 +1,29 @@
+export default {
+ skip_if_ssr: true,
+ before_test() {
+ Object.defineProperties(window, {
+ pageYOffset: {
+ value: 0,
+ configurable: true,
+ },
+ });
+ },
+ async test({ assert, component, target, window }) {
+ assert.equal(window.pageYOffset, 0);
+
+ const event = new window.Event('scroll');
+ Object.defineProperties(window, {
+ pageYOffset: {
+ value: 234,
+ configurable: true,
+ },
+ });
+
+ await window.dispatchEvent(event);
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `scroll\ny\nis\n234.\n234\n*\n234\n=\n54756
`
+ );
+ },
+};
diff --git a/test/runtime/samples/window-binding-scroll-store/main.svelte b/test/runtime/samples/window-binding-scroll-store/main.svelte
new file mode 100644
index 0000000000..fe225520d7
--- /dev/null
+++ b/test/runtime/samples/window-binding-scroll-store/main.svelte
@@ -0,0 +1,15 @@
+
+
+
+
+
+ scroll y is {$y}. {$y} * {$y} = {$y_squared}
+
+
+
+
+
\ No newline at end of file
diff --git a/test/runtime/samples/window-event/_config.js b/test/runtime/samples/window-event/_config.js
index 16e0f870ef..bd09487f5e 100644
--- a/test/runtime/samples/window-event/_config.js
+++ b/test/runtime/samples/window-event/_config.js
@@ -1,16 +1,12 @@
export default {
html: `undefinedxundefined
`,
- skip: true, // some weird stuff happening with JSDOM 11
- // skip: /^v4/.test(process.version), // node 4 apparently does some dumb stuff
skip_if_ssr: true, // there's some kind of weird bug with this test... it compiles with the wrong require.extensions hook for some bizarre reason
async test({ assert, component, target, window }) {
const event = new window.Event('resize');
- // JSDOM executes window event listeners with `global` rather than
- // `window` (bug?) so we need to do this
- Object.defineProperties(global, {
+ Object.defineProperties(window, {
innerWidth: {
value: 567,
configurable: true
diff --git a/test/runtime/samples/window-event/main.svelte b/test/runtime/samples/window-event/main.svelte
index 1aa84a0890..e246902063 100644
--- a/test/runtime/samples/window-event/main.svelte
+++ b/test/runtime/samples/window-event/main.svelte
@@ -3,6 +3,6 @@
export let height;
-
+
{width}x{height}
\ No newline at end of file
diff --git a/test/server-side-rendering/index.js b/test/server-side-rendering/index.js
index cf6e5ad964..ee1319845d 100644
--- a/test/server-side-rendering/index.js
+++ b/test/server-side-rendering/index.js
@@ -1,12 +1,17 @@
import * as assert from "assert";
import * as fs from "fs";
import * as path from "path";
+import * as glob from 'tiny-glob/sync.js';
import {
showOutput,
loadConfig,
+ loadSvelte,
setupHtmlEqual,
- tryToLoadJson
+ tryToLoadJson,
+ cleanRequireCache,
+ shouldUpdateExpected,
+ mkdirp
} from "../helpers.js";
function tryToReadFile(file) {
@@ -19,23 +24,23 @@ function tryToReadFile(file) {
}
const sveltePath = process.cwd().split('\\').join('/');
+let compile = null;
describe("ssr", () => {
before(() => {
- require("../../register")({
- extensions: ['.svelte', '.html'],
- sveltePath
- });
+ compile = loadSvelte(true).compile;
return setupHtmlEqual();
});
- fs.readdirSync("test/server-side-rendering/samples").forEach(dir => {
+ fs.readdirSync(`${__dirname}/samples`).forEach(dir => {
if (dir[0] === ".") return;
+ const config = loadConfig(`${__dirname}/samples/${dir}/_config.js`);
+
// add .solo to a sample directory name to only run that test, or
// .show to always show the output. or both
- const solo = /\.solo/.test(dir);
+ const solo = config.solo || /\.solo/.test(dir);
const show = /\.show/.test(dir);
if (solo && process.env.CI) {
@@ -43,7 +48,19 @@ describe("ssr", () => {
}
(solo ? it.only : it)(dir, () => {
- dir = path.resolve("test/server-side-rendering/samples", dir);
+ dir = path.resolve(`${__dirname}/samples`, dir);
+
+ cleanRequireCache();
+
+ const compileOptions = {
+ sveltePath,
+ ...config.compileOptions,
+ generate: 'ssr',
+ format: 'cjs'
+ };
+
+ require("../../register")(compileOptions);
+
try {
const Component = require(`${dir}/main.svelte`).default;
@@ -58,23 +75,53 @@ describe("ssr", () => {
fs.writeFileSync(`${dir}/_actual.html`, html);
if (css.code) fs.writeFileSync(`${dir}/_actual.css`, css.code);
- assert.htmlEqual(html, expectedHtml);
- assert.equal(
- css.code.replace(/^\s+/gm, ""),
- expectedCss.replace(/^\s+/gm, "")
- );
+ try {
+ assert.htmlEqual(html, expectedHtml);
+ } catch (error) {
+ if (shouldUpdateExpected()) {
+ fs.writeFileSync(`${dir}/_expected.html`, html);
+ console.log(`Updated ${dir}/_expected.html.`);
+ } else {
+ throw error;
+ }
+ }
+
+ try {
+ assert.equal(
+ css.code.replace(/^\s+/gm, ""),
+ expectedCss.replace(/^\s+/gm, "")
+ );
+ } catch (error) {
+ if (shouldUpdateExpected()) {
+ fs.writeFileSync(`${dir}/_expected.css`, css.code);
+ console.log(`Updated ${dir}/_expected.css.`);
+ } else {
+ throw error;
+ }
+ }
if (fs.existsSync(`${dir}/_expected-head.html`)) {
fs.writeFileSync(`${dir}/_actual-head.html`, head);
- assert.htmlEqual(
- head,
- fs.readFileSync(`${dir}/_expected-head.html`, 'utf-8')
- );
+
+ try {
+ assert.htmlEqual(
+ head,
+ fs.readFileSync(`${dir}/_expected-head.html`, 'utf-8')
+ );
+ } catch (error) {
+ if (shouldUpdateExpected()) {
+ fs.writeFileSync(`${dir}/_expected-head.html`, head);
+ console.log(`Updated ${dir}/_expected-head.html.`);
+ } else {
+ throw error;
+ }
+ }
}
- if (show) showOutput(dir, { generate: 'ssr' });
+ if (show) showOutput(dir, { generate: 'ssr', format: 'cjs' });
} catch (err) {
- showOutput(dir, { generate: 'ssr' });
+ showOutput(dir, { generate: 'ssr', format: 'cjs' });
+ err.stack += `\n\ncmd-click: ${path.relative(process.cwd(), dir)}/main.svelte`;
throw err;
}
});
@@ -85,30 +132,57 @@ describe("ssr", () => {
if (dir[0] === ".") return;
const config = loadConfig(`./runtime/samples/${dir}/_config.js`);
+ const solo = config.solo || /\.solo/.test(dir);
- if (config.solo && process.env.CI) {
+ if (solo && process.env.CI) {
throw new Error("Forgot to remove `solo: true` from test");
}
if (config.skip_if_ssr) return;
- (config.skip ? it.skip : config.solo ? it.only : it)(dir, () => {
+ (config.skip ? it.skip : solo ? it.only : it)(dir, () => {
const cwd = path.resolve("test/runtime/samples", dir);
- Object.keys(require.cache)
- .filter(x => x.endsWith('.svelte'))
- .forEach(file => {
- delete require.cache[file];
- });
+ cleanRequireCache();
delete global.window;
- const compileOptions = Object.assign({ sveltePath }, config.compileOptions, {
- generate: 'ssr'
- });
+ const compileOptions = {
+ sveltePath,
+ ...config.compileOptions,
+ generate: 'ssr',
+ format: 'cjs'
+ };
require("../../register")(compileOptions);
+ glob('**/*.svelte', { cwd }).forEach(file => {
+ if (file[0] === '_') return;
+
+ const dir = `${cwd}/_output/ssr`;
+ const out = `${dir}/${file.replace(/\.svelte$/, '.js')}`;
+
+ if (fs.existsSync(out)) {
+ fs.unlinkSync(out);
+ }
+
+ mkdirp(dir);
+
+ try {
+ const { js } = compile(
+ fs.readFileSync(`${cwd}/${file}`, 'utf-8'),
+ {
+ ...compileOptions,
+ filename: file
+ }
+ );
+
+ fs.writeFileSync(out, js.code);
+ } catch (err) {
+ // do nothing
+ }
+ });
+
try {
if (config.before_test) config.before_test();
@@ -129,11 +203,13 @@ describe("ssr", () => {
showOutput(cwd, compileOptions);
}
} catch (err) {
+ err.stack += `\n\ncmd-click: ${path.relative(process.cwd(), cwd)}/main.svelte`;
+
if (config.error) {
if (typeof config.error === 'function') {
config.error(assert, err);
} else {
- assert.equal(config.error, err.message);
+ assert.equal(err.message, config.error);
}
} else {
showOutput(cwd, compileOptions);
diff --git a/test/server-side-rendering/samples/attribute-boolean/_expected.html b/test/server-side-rendering/samples/attribute-boolean/_expected.html
index 3ca3bfd9a8..5b36bb6c3f 100644
--- a/test/server-side-rendering/samples/attribute-boolean/_expected.html
+++ b/test/server-side-rendering/samples/attribute-boolean/_expected.html
@@ -1 +1,2 @@
+
diff --git a/test/server-side-rendering/samples/attribute-boolean/main.svelte b/test/server-side-rendering/samples/attribute-boolean/main.svelte
index 3ca3bfd9a8..0852e12418 100644
--- a/test/server-side-rendering/samples/attribute-boolean/main.svelte
+++ b/test/server-side-rendering/samples/attribute-boolean/main.svelte
@@ -1 +1,2 @@
+
diff --git a/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_config.js b/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_config.js
new file mode 100644
index 0000000000..ae9b250f86
--- /dev/null
+++ b/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_config.js
@@ -0,0 +1,5 @@
+export default {
+ compileOptions: {
+ hydratable: true
+ }
+};
diff --git a/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_expected-head.html b/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_expected-head.html
new file mode 100644
index 0000000000..107753cdd0
--- /dev/null
+++ b/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_expected-head.html
@@ -0,0 +1,4 @@
+Some Title
+
+
+
\ No newline at end of file
diff --git a/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_expected.html b/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_expected.html
new file mode 100644
index 0000000000..a469e618fa
--- /dev/null
+++ b/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_expected.html
@@ -0,0 +1,3 @@
+
+
+Just a dummy page.
\ No newline at end of file
diff --git a/test/server-side-rendering/samples/head-meta-hydrate-duplicate/main.svelte b/test/server-side-rendering/samples/head-meta-hydrate-duplicate/main.svelte
new file mode 100644
index 0000000000..1a8b125dd2
--- /dev/null
+++ b/test/server-side-rendering/samples/head-meta-hydrate-duplicate/main.svelte
@@ -0,0 +1,8 @@
+
+ Some Title
+
+
+
+
+
+Just a dummy page.
\ No newline at end of file
diff --git a/test/server-side-rendering/samples/head-multiple-title/A.svelte b/test/server-side-rendering/samples/head-multiple-title/A.svelte
new file mode 100644
index 0000000000..b139b4ff77
--- /dev/null
+++ b/test/server-side-rendering/samples/head-multiple-title/A.svelte
@@ -0,0 +1,3 @@
+
+ A
+
diff --git a/test/server-side-rendering/samples/head-multiple-title/B.svelte b/test/server-side-rendering/samples/head-multiple-title/B.svelte
new file mode 100644
index 0000000000..4a29ecb04c
--- /dev/null
+++ b/test/server-side-rendering/samples/head-multiple-title/B.svelte
@@ -0,0 +1,3 @@
+
+ B
+
diff --git a/test/server-side-rendering/samples/head-multiple-title/_expected-head.html b/test/server-side-rendering/samples/head-multiple-title/_expected-head.html
new file mode 100644
index 0000000000..af5c5feba4
--- /dev/null
+++ b/test/server-side-rendering/samples/head-multiple-title/_expected-head.html
@@ -0,0 +1 @@
+B
\ No newline at end of file
diff --git a/test/server-side-rendering/samples/head-multiple-title/_expected.html b/test/server-side-rendering/samples/head-multiple-title/_expected.html
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/server-side-rendering/samples/head-multiple-title/data.json b/test/server-side-rendering/samples/head-multiple-title/data.json
new file mode 100644
index 0000000000..eab238e816
--- /dev/null
+++ b/test/server-side-rendering/samples/head-multiple-title/data.json
@@ -0,0 +1,3 @@
+{
+ "adjective": "custom"
+}
\ No newline at end of file
diff --git a/test/server-side-rendering/samples/head-multiple-title/main.svelte b/test/server-side-rendering/samples/head-multiple-title/main.svelte
new file mode 100644
index 0000000000..fb9a70b923
--- /dev/null
+++ b/test/server-side-rendering/samples/head-multiple-title/main.svelte
@@ -0,0 +1,10 @@
+
+
+
+ Main
+
+
+
diff --git a/test/server-side-rendering/samples/spread-attributes-boolean/_expected.html b/test/server-side-rendering/samples/spread-attributes-boolean/_expected.html
new file mode 100644
index 0000000000..06048d3efa
--- /dev/null
+++ b/test/server-side-rendering/samples/spread-attributes-boolean/_expected.html
@@ -0,0 +1,2 @@
+
+
diff --git a/test/server-side-rendering/samples/spread-attributes-boolean/main.svelte b/test/server-side-rendering/samples/spread-attributes-boolean/main.svelte
new file mode 100644
index 0000000000..3d865c0082
--- /dev/null
+++ b/test/server-side-rendering/samples/spread-attributes-boolean/main.svelte
@@ -0,0 +1,2 @@
+
+
diff --git a/test/server-side-rendering/samples/spread-attributes-white-space/_expected.html b/test/server-side-rendering/samples/spread-attributes-white-space/_expected.html
new file mode 100644
index 0000000000..a73bb17e8c
--- /dev/null
+++ b/test/server-side-rendering/samples/spread-attributes-white-space/_expected.html
@@ -0,0 +1,8 @@
+
+
+
\ No newline at end of file
diff --git a/test/server-side-rendering/samples/spread-attributes-white-space/main.svelte b/test/server-side-rendering/samples/spread-attributes-white-space/main.svelte
new file mode 100644
index 0000000000..6919d9ea54
--- /dev/null
+++ b/test/server-side-rendering/samples/spread-attributes-white-space/main.svelte
@@ -0,0 +1,12 @@
+
+
+
+
+
diff --git a/test/server-side-rendering/samples/spread-attributes/_expected.html b/test/server-side-rendering/samples/spread-attributes/_expected.html
new file mode 100644
index 0000000000..b78eafb8f4
--- /dev/null
+++ b/test/server-side-rendering/samples/spread-attributes/_expected.html
@@ -0,0 +1 @@
+
diff --git a/test/server-side-rendering/samples/spread-attributes/main.svelte b/test/server-side-rendering/samples/spread-attributes/main.svelte
new file mode 100644
index 0000000000..fc8c849396
--- /dev/null
+++ b/test/server-side-rendering/samples/spread-attributes/main.svelte
@@ -0,0 +1,9 @@
+
+
+
diff --git a/test/sourcemaps/index.js b/test/sourcemaps/index.js
index ee169ebe1b..0b0424a764 100644
--- a/test/sourcemaps/index.js
+++ b/test/sourcemaps/index.js
@@ -6,7 +6,7 @@ import { SourceMapConsumer } from "source-map";
import { getLocator } from "locate-character";
describe("sourcemaps", () => {
- fs.readdirSync("test/sourcemaps/samples").forEach(dir => {
+ fs.readdirSync(`${__dirname}/samples`).forEach(dir => {
if (dir[0] === ".") return;
// add .solo to a sample directory name to only run that test
@@ -17,12 +17,12 @@ describe("sourcemaps", () => {
throw new Error("Forgot to remove `solo: true` from test");
}
- (solo ? it.only : skip ? it.skip : it)(dir, () => {
+ (solo ? it.only : skip ? it.skip : it)(dir, async () => {
const filename = path.resolve(
- `test/sourcemaps/samples/${dir}/input.svelte`
+ `${__dirname}/samples/${dir}/input.svelte`
);
const outputFilename = path.resolve(
- `test/sourcemaps/samples/${dir}/output`
+ `${__dirname}/samples/${dir}/output`
);
const input = fs.readFileSync(filename, "utf-8").replace(/\s+$/, "");
@@ -61,10 +61,10 @@ describe("sourcemaps", () => {
const locateInSource = getLocator(input);
- const smc = new SourceMapConsumer(js.map);
+ const smc = await new SourceMapConsumer(js.map);
const locateInGenerated = getLocator(_code);
- const smcCss = css.map && new SourceMapConsumer(css.map);
+ const smcCss = css.map && await new SourceMapConsumer(css.map);
const locateInGeneratedCss = getLocator(css.code || '');
test({ assert, code: _code, map: js.map, smc, smcCss, locateInSource, locateInGenerated, locateInGeneratedCss });
diff --git a/test/sourcemaps/samples/basic/test.js b/test/sourcemaps/samples/basic/test.js
index f13ff5d0e1..7059761674 100644
--- a/test/sourcemaps/samples/basic/test.js
+++ b/test/sourcemaps/samples/basic/test.js
@@ -1,31 +1,31 @@
export function test({ assert, smc, locateInSource, locateInGenerated }) {
- const expected = locateInSource( 'foo.bar.baz' );
+ const expected = locateInSource('foo.bar.baz');
let start;
let actual;
- start = locateInGenerated( 'foo.bar.baz' );
+ start = locateInGenerated('ctx[0].bar.baz');
actual = smc.originalPositionFor({
line: start.line + 1,
column: start.column
});
- assert.deepEqual( actual, {
+ assert.deepEqual(actual, {
source: 'input.svelte',
name: null,
line: expected.line + 1,
column: expected.column
});
- start = locateInGenerated( 'foo.bar.baz', start.character + 1 );
+ start = locateInGenerated('ctx[0].bar.baz', start.character + 1);
actual = smc.originalPositionFor({
line: start.line + 1,
column: start.column
});
- assert.deepEqual( actual, {
+ assert.deepEqual(actual, {
source: 'input.svelte',
name: null,
line: expected.line + 1,
diff --git a/test/sourcemaps/samples/each-block/test.js b/test/sourcemaps/samples/each-block/test.js
index 6e9d2d70b0..35479986a5 100644
--- a/test/sourcemaps/samples/each-block/test.js
+++ b/test/sourcemaps/samples/each-block/test.js
@@ -1,15 +1,15 @@
-export function test({ assert, code, smc, locateInSource, locateInGenerated }) {
+export function test({ assert, code, smc, map, locateInSource, locateInGenerated }) {
const startIndex = code.indexOf('create_main_fragment');
const expected = locateInSource('each');
- const start = locateInGenerated('length', startIndex );
+ const start = locateInGenerated('length', startIndex);
const actual = smc.originalPositionFor({
line: start.line + 1,
column: start.column
});
- assert.deepEqual( actual, {
+ assert.deepEqual(actual, {
source: 'input.svelte',
name: null,
line: expected.line + 1,
diff --git a/test/stats/index.js b/test/stats/index.js
index aafc58c926..acea7a4663 100644
--- a/test/stats/index.js
+++ b/test/stats/index.js
@@ -3,7 +3,7 @@ import * as assert from 'assert';
import { svelte, loadConfig, tryToLoadJson } from '../helpers.js';
describe('stats', () => {
- fs.readdirSync('test/stats/samples').forEach(dir => {
+ fs.readdirSync(`${__dirname}/samples`).forEach(dir => {
if (dir[0] === '.') return;
// add .solo to a sample directory name to only run that test
@@ -15,12 +15,12 @@ describe('stats', () => {
}
(solo ? it.only : skip ? it.skip : it)(dir, () => {
- const config = loadConfig(`./stats/samples/${dir}/_config.js`);
- const filename = `test/stats/samples/${dir}/input.svelte`;
+ const config = loadConfig(`${__dirname}/samples/${dir}/_config.js`);
+ const filename = `${__dirname}/samples/${dir}/input.svelte`;
const input = fs.readFileSync(filename, 'utf-8').replace(/\s+$/, '');
const expectedError = tryToLoadJson(
- `test/stats/samples/${dir}/error.json`
+ `${__dirname}/samples/${dir}/error.json`
);
let result;
diff --git a/test/store/index.js b/test/store/index.js
index a39fab86e6..2af4a6f35d 100644
--- a/test/store/index.js
+++ b/test/store/index.js
@@ -116,6 +116,15 @@ describe('store', () => {
});
});
+ const fake_observable = {
+ subscribe(fn) {
+ fn(42);
+ return {
+ unsubscribe: () => {}
+ };
+ }
+ };
+
describe('derived', () => {
it('maps a single store', () => {
const a = writable(1);
@@ -346,6 +355,11 @@ describe('store', () => {
b.set(2);
assert.deepEqual(get(c), 'two 2');
});
+
+ it('works with RxJS-style observables', () => {
+ const d = derived(fake_observable, _ => _);
+ assert.equal(get(d), 42);
+ });
});
describe('get', () => {
@@ -355,16 +369,7 @@ describe('store', () => {
});
it('works with RxJS-style observables', () => {
- const observable = {
- subscribe(fn) {
- fn(42);
- return {
- unsubscribe: () => {}
- };
- }
- };
-
- assert.equal(get(observable), 42);
+ assert.equal(get(fake_observable), 42);
});
});
});
diff --git a/test/test.js b/test/test.js
index f18c01c149..6ea4bd60ab 100644
--- a/test/test.js
+++ b/test/test.js
@@ -6,6 +6,16 @@ require('./setup');
require('./helpers');
require('../internal');
-glob('*/index.js', { cwd: 'test' }).forEach((file) => {
- require('./' + file);
-});
+console.clear();
+
+const test_folders = glob('*/index.js', { cwd: 'test' });
+const solo_folders = test_folders.filter(folder => /\.solo/.test(folder));
+
+if (solo_folders.length) {
+ if (process.env.CI) {
+ throw new Error('Forgot to remove `.solo` from test');
+ }
+ solo_folders.forEach(name => require('./' + name));
+} else {
+ test_folders.forEach(name => require('./' + name));
+}
diff --git a/test/validator/index.js b/test/validator/index.js
index 1e54cc20db..9bce5e149b 100644
--- a/test/validator/index.js
+++ b/test/validator/index.js
@@ -3,7 +3,7 @@ import * as assert from "assert";
import { svelte, loadConfig, tryToLoadJson } from "../helpers.js";
describe("validate", () => {
- fs.readdirSync("test/validator/samples").forEach(dir => {
+ fs.readdirSync(`${__dirname}/samples`).forEach(dir => {
if (dir[0] === ".") return;
// add .solo to a sample directory name to only run that test
@@ -15,11 +15,12 @@ describe("validate", () => {
}
(solo ? it.only : skip ? it.skip : it)(dir, () => {
- const config = loadConfig(`./validator/samples/${dir}/_config.js`);
+ const config = loadConfig(`${__dirname}/samples/${dir}/_config.js`);
- const input = fs.readFileSync(`test/validator/samples/${dir}/input.svelte`, "utf-8").replace(/\s+$/, "");
- const expected_warnings = tryToLoadJson(`test/validator/samples/${dir}/warnings.json`) || [];
- const expected_errors = tryToLoadJson(`test/validator/samples/${dir}/errors.json`);
+ const input = fs.readFileSync(`${__dirname}/samples/${dir}/input.svelte`, "utf-8").replace(/\s+$/, "");
+ const expected_warnings = tryToLoadJson(`${__dirname}/samples/${dir}/warnings.json`) || [];
+ const expected_errors = tryToLoadJson(`${__dirname}/samples/${dir}/errors.json`);
+ const options = tryToLoadJson(`${__dirname}/samples/${dir}/options.json`);
let error;
@@ -27,7 +28,9 @@ describe("validate", () => {
const { warnings } = svelte.compile(input, {
dev: config.dev,
legacy: config.legacy,
- generate: false
+ generate: false,
+ customElement: config.customElement,
+ ...options,
});
assert.deepEqual(warnings.map(w => ({
diff --git a/test/validator/samples/binding-await-catch/errors.json b/test/validator/samples/binding-await-catch/errors.json
new file mode 100644
index 0000000000..00141686f3
--- /dev/null
+++ b/test/validator/samples/binding-await-catch/errors.json
@@ -0,0 +1,9 @@
+[
+ {
+ "code": "invalid-binding",
+ "message": "Cannot bind to a variable declared with {#await ... then} or {:catch} blocks",
+ "pos": 79,
+ "start": { "line": 6, "column": 9, "character": 79 },
+ "end": { "line": 6, "column": 27, "character": 97 }
+ }
+]
diff --git a/test/validator/samples/binding-await-catch/input.svelte b/test/validator/samples/binding-await-catch/input.svelte
new file mode 100644
index 0000000000..b640f6305b
--- /dev/null
+++ b/test/validator/samples/binding-await-catch/input.svelte
@@ -0,0 +1,7 @@
+
+{#await promise}
+{:catch error}
+
+{/await}
diff --git a/test/validator/samples/binding-await-then-2/errors.json b/test/validator/samples/binding-await-then-2/errors.json
new file mode 100644
index 0000000000..e734ed4717
--- /dev/null
+++ b/test/validator/samples/binding-await-then-2/errors.json
@@ -0,0 +1,9 @@
+[
+ {
+ "code": "invalid-binding",
+ "message": "Cannot bind to a variable declared with {#await ... then} or {:catch} blocks",
+ "pos": 78,
+ "start": { "line": 6, "column": 9, "character": 78 },
+ "end": { "line": 6, "column": 19, "character": 88 }
+ }
+]
diff --git a/test/validator/samples/binding-await-then-2/input.svelte b/test/validator/samples/binding-await-then-2/input.svelte
new file mode 100644
index 0000000000..e8c56c8e0b
--- /dev/null
+++ b/test/validator/samples/binding-await-then-2/input.svelte
@@ -0,0 +1,7 @@
+
+{#await promise}
+{:then value}
+
+{/await}
diff --git a/test/validator/samples/binding-await-then/errors.json b/test/validator/samples/binding-await-then/errors.json
new file mode 100644
index 0000000000..a611e7731f
--- /dev/null
+++ b/test/validator/samples/binding-await-then/errors.json
@@ -0,0 +1,9 @@
+[
+ {
+ "code": "invalid-binding",
+ "message": "Cannot bind to a variable declared with {#await ... then} or {:catch} blocks",
+ "pos": 75,
+ "start": { "line": 5, "column": 9, "character": 75 },
+ "end": { "line": 5, "column": 19, "character": 85 }
+ }
+]
diff --git a/test/validator/samples/binding-await-then/input.svelte b/test/validator/samples/binding-await-then/input.svelte
new file mode 100644
index 0000000000..bc55ef97e4
--- /dev/null
+++ b/test/validator/samples/binding-await-then/input.svelte
@@ -0,0 +1,6 @@
+
+{#await promise then value}
+
+{/await}
diff --git a/test/validator/samples/component-dynamic/input.svelte b/test/validator/samples/component-dynamic/input.svelte
new file mode 100644
index 0000000000..f591a84fe1
--- /dev/null
+++ b/test/validator/samples/component-dynamic/input.svelte
@@ -0,0 +1,18 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/validator/samples/component-dynamic/options.json b/test/validator/samples/component-dynamic/options.json
new file mode 100644
index 0000000000..3a50892eba
--- /dev/null
+++ b/test/validator/samples/component-dynamic/options.json
@@ -0,0 +1,3 @@
+{
+ "generate": true
+}
\ No newline at end of file
diff --git a/test/validator/samples/component-dynamic/warnings.json b/test/validator/samples/component-dynamic/warnings.json
new file mode 100644
index 0000000000..457ef11a1e
--- /dev/null
+++ b/test/validator/samples/component-dynamic/warnings.json
@@ -0,0 +1,47 @@
+[
+ {
+ "code": "reactive-component",
+ "message": " will not be reactive if Let changes. Use if you want this reactivity.",
+ "pos": 190,
+ "end": {
+ "character": 197,
+ "column": 7,
+ "line": 15
+ },
+ "start": {
+ "character": 190,
+ "column": 0,
+ "line": 15
+ }
+ },
+ {
+ "message": " will not be reactive if ExportLet changes. Use if you want this reactivity.",
+ "code": "reactive-component",
+ "pos": 198,
+ "end": {
+ "character": 211,
+ "column": 13,
+ "line": 16
+ },
+ "start": {
+ "character": 198,
+ "column": 0,
+ "line": 16
+ }
+ },
+ {
+ "message": " will not be reactive if Reactive changes. Use if you want this reactivity.",
+ "code": "reactive-component",
+ "pos": 212,
+ "end": {
+ "character": 224,
+ "column": 12,
+ "line": 17
+ },
+ "start": {
+ "character": 212,
+ "column": 0,
+ "line": 17
+ }
+ }
+]
diff --git a/test/validator/samples/each-block-invalid-context-destructured-object/errors.json b/test/validator/samples/each-block-invalid-context-destructured-object/errors.json
new file mode 100644
index 0000000000..085021ff5a
--- /dev/null
+++ b/test/validator/samples/each-block-invalid-context-destructured-object/errors.json
@@ -0,0 +1,15 @@
+[{
+ "code": "unexpected-reserved-word",
+ "message": "'case' is a reserved word in JavaScript and cannot be used here",
+ "start": {
+ "line": 1,
+ "column": 18,
+ "character": 18
+ },
+ "end": {
+ "line": 1,
+ "column": 18,
+ "character": 18
+ },
+ "pos": 18
+}]
diff --git a/test/validator/samples/each-block-invalid-context-destructured-object/input.svelte b/test/validator/samples/each-block-invalid-context-destructured-object/input.svelte
new file mode 100644
index 0000000000..a891f131a0
--- /dev/null
+++ b/test/validator/samples/each-block-invalid-context-destructured-object/input.svelte
@@ -0,0 +1,3 @@
+{#each cases as { case }}
+ {case.title}
+{/each}
diff --git a/test/validator/samples/invalid-empty-css-declaration/errors.json b/test/validator/samples/invalid-empty-css-declaration/errors.json
new file mode 100644
index 0000000000..f141168077
--- /dev/null
+++ b/test/validator/samples/invalid-empty-css-declaration/errors.json
@@ -0,0 +1,12 @@
+[{
+ "code": "invalid-declaration",
+ "message": "Declaration cannot be empty",
+ "start": {
+ "line": 11, "column": 0, "character": 93
+ },
+ "end": {
+ "line": 11, "column": 0, "character": 93
+ },
+ "pos": 93,
+ "frame": " 9: color: blue;\n10: }\n11: \n ^"
+}]
\ No newline at end of file
diff --git a/test/validator/samples/invalid-empty-css-declaration/input.svelte b/test/validator/samples/invalid-empty-css-declaration/input.svelte
new file mode 100644
index 0000000000..1262b8e08a
--- /dev/null
+++ b/test/validator/samples/invalid-empty-css-declaration/input.svelte
@@ -0,0 +1,11 @@
+
+
+
\ No newline at end of file
diff --git a/test/validator/samples/missing-component-global/input.svelte b/test/validator/samples/missing-component-global/input.svelte
new file mode 100644
index 0000000000..5d17448bd4
--- /dev/null
+++ b/test/validator/samples/missing-component-global/input.svelte
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/test/validator/samples/missing-component-global/warnings.json b/test/validator/samples/missing-component-global/warnings.json
new file mode 100644
index 0000000000..c9de56619a
--- /dev/null
+++ b/test/validator/samples/missing-component-global/warnings.json
@@ -0,0 +1,15 @@
+[{
+ "code": "missing-declaration",
+ "message": "'String' is not defined. Consider adding a
+{$q}
diff --git a/test/validator/samples/unreferenced-variables/warnings.json b/test/validator/samples/unreferenced-variables/warnings.json
new file mode 100644
index 0000000000..dfac58ebdb
--- /dev/null
+++ b/test/validator/samples/unreferenced-variables/warnings.json
@@ -0,0 +1,77 @@
+[
+ {
+ "code": "unused-export-let",
+ "end": {
+ "character": 103,
+ "column": 12,
+ "line": 8
+ },
+ "message": "Component has unused export property 'd'. If it is for external reference only, please consider using `export const d`",
+ "pos": 102,
+ "start": {
+ "character": 102,
+ "column": 11,
+ "line": 8
+ }
+ },
+ {
+ "code": "unused-export-let",
+ "end": {
+ "character": 106,
+ "column": 15,
+ "line": 8
+ },
+ "message": "Component has unused export property 'e'. If it is for external reference only, please consider using `export const e`",
+ "pos": 105,
+ "start": {
+ "character": 105,
+ "column": 14,
+ "line": 8
+ }
+ },
+ {
+ "code": "unused-export-let",
+ "end": {
+ "character": 130,
+ "column": 18,
+ "line": 9
+ },
+ "message": "Component has unused export property 'g'. If it is for external reference only, please consider using `export const g`",
+ "pos": 125,
+ "start": {
+ "character": 125,
+ "column": 13,
+ "line": 9
+ }
+ },
+ {
+ "code": "unused-export-let",
+ "end": {
+ "character": 150,
+ "column": 18,
+ "line": 10
+ },
+ "message": "Component has unused export property 'h'. If it is for external reference only, please consider using `export const h`",
+ "pos": 145,
+ "start": {
+ "character": 145,
+ "column": 13,
+ "line": 10
+ }
+ },
+ {
+ "code": "unused-export-let",
+ "end": {
+ "character": 199,
+ "column": 25,
+ "line": 12
+ },
+ "message": "Component has unused export property 'j'. If it is for external reference only, please consider using `export const j`",
+ "pos": 187,
+ "start": {
+ "character": 187,
+ "column": 13,
+ "line": 12
+ }
+ }
+]
diff --git a/test/vars/index.js b/test/vars/index.js
index 66ffd94c70..a12ac177f2 100644
--- a/test/vars/index.js
+++ b/test/vars/index.js
@@ -3,7 +3,7 @@ import * as assert from 'assert';
import { svelte, loadConfig, tryToLoadJson } from '../helpers.js';
describe('vars', () => {
- fs.readdirSync('test/vars/samples').forEach(dir => {
+ fs.readdirSync(`${__dirname}/samples`).forEach(dir => {
if (dir[0] === '.') return;
// add .solo to a sample directory name to only run that test
@@ -16,12 +16,12 @@ describe('vars', () => {
for (const generate of ['dom', 'ssr', false]) {
(solo ? it.only : skip ? it.skip : it)(`${dir}, generate: ${generate}`, () => {
- const config = loadConfig(`./vars/samples/${dir}/_config.js`);
- const filename = `test/vars/samples/${dir}/input.svelte`;
+ const config = loadConfig(`${__dirname}/samples/${dir}/_config.js`);
+ const filename = `${__dirname}/samples/${dir}/input.svelte`;
const input = fs.readFileSync(filename, 'utf-8').replace(/\s+$/, '');
const expectedError = tryToLoadJson(
- `test/vars/samples/${dir}/error.json`
+ `${__dirname}/samples/${dir}/error.json`
);
let result;
diff --git a/test/vars/samples/$$props-logicless/_config.js b/test/vars/samples/$$props-logicless/_config.js
index b0d76bebbd..20f9b99466 100644
--- a/test/vars/samples/$$props-logicless/_config.js
+++ b/test/vars/samples/$$props-logicless/_config.js
@@ -9,6 +9,7 @@ export default {
mutated: false,
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: false
}
]);
diff --git a/test/vars/samples/$$props/_config.js b/test/vars/samples/$$props/_config.js
index b0d76bebbd..20f9b99466 100644
--- a/test/vars/samples/$$props/_config.js
+++ b/test/vars/samples/$$props/_config.js
@@ -9,6 +9,7 @@ export default {
mutated: false,
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: false
}
]);
diff --git a/test/vars/samples/actions/_config.js b/test/vars/samples/actions/_config.js
index 6b6f8696e7..4cc2b9d18c 100644
--- a/test/vars/samples/actions/_config.js
+++ b/test/vars/samples/actions/_config.js
@@ -9,6 +9,7 @@ export default {
name: 'hoistable_foo',
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: false
},
{
@@ -19,6 +20,7 @@ export default {
name: 'foo',
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: true
}
]);
diff --git a/test/vars/samples/animations/_config.js b/test/vars/samples/animations/_config.js
index 6b6f8696e7..4cc2b9d18c 100644
--- a/test/vars/samples/animations/_config.js
+++ b/test/vars/samples/animations/_config.js
@@ -9,6 +9,7 @@ export default {
name: 'hoistable_foo',
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: false
},
{
@@ -19,6 +20,7 @@ export default {
name: 'foo',
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: true
}
]);
diff --git a/test/vars/samples/component-namespaced/_config.js b/test/vars/samples/component-namespaced/_config.js
index ac63873967..a801c52780 100644
--- a/test/vars/samples/component-namespaced/_config.js
+++ b/test/vars/samples/component-namespaced/_config.js
@@ -9,6 +9,7 @@ export default {
mutated: false,
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: false
}
]);
diff --git a/test/vars/samples/duplicate-non-hoistable/_config.js b/test/vars/samples/duplicate-non-hoistable/_config.js
index bb7f52d4db..4ebc5b00cf 100644
--- a/test/vars/samples/duplicate-non-hoistable/_config.js
+++ b/test/vars/samples/duplicate-non-hoistable/_config.js
@@ -9,6 +9,7 @@ export default {
mutated: false,
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: true
}
]);
diff --git a/test/vars/samples/duplicate-vars/_config.js b/test/vars/samples/duplicate-vars/_config.js
index 276ae130a1..eb10c44a9a 100644
--- a/test/vars/samples/duplicate-vars/_config.js
+++ b/test/vars/samples/duplicate-vars/_config.js
@@ -9,6 +9,7 @@ export default {
mutated: false,
reassigned: false,
referenced: false,
+ referenced_from_script: false,
writable: true
},
{
@@ -19,6 +20,7 @@ export default {
mutated: false,
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: true
}
]);
diff --git a/test/vars/samples/implicit-reactive/_config.js b/test/vars/samples/implicit-reactive/_config.js
index fd67e8b249..770de590e6 100644
--- a/test/vars/samples/implicit-reactive/_config.js
+++ b/test/vars/samples/implicit-reactive/_config.js
@@ -9,6 +9,7 @@ export default {
mutated: false,
reassigned: false,
referenced: true,
+ referenced_from_script: true,
writable: true
},
{
@@ -19,6 +20,7 @@ export default {
mutated: false,
reassigned: true,
referenced: true,
+ referenced_from_script: false,
writable: true
}
]);
diff --git a/test/vars/samples/imports/_config.js b/test/vars/samples/imports/_config.js
index 90f2468b54..ecf120c7d6 100644
--- a/test/vars/samples/imports/_config.js
+++ b/test/vars/samples/imports/_config.js
@@ -9,6 +9,7 @@ export default {
mutated: false,
reassigned: false,
referenced: false,
+ referenced_from_script: false,
writable: false
},
{
@@ -19,6 +20,7 @@ export default {
mutated: false,
reassigned: false,
referenced: false,
+ referenced_from_script: false,
writable: false
},
{
@@ -29,6 +31,7 @@ export default {
mutated: false,
reassigned: false,
referenced: false,
+ referenced_from_script: false,
writable: false
}
]);
diff --git a/test/vars/samples/mutated-vs-reassigned-bindings/_config.js b/test/vars/samples/mutated-vs-reassigned-bindings/_config.js
index 21fc14d820..ba499674d2 100644
--- a/test/vars/samples/mutated-vs-reassigned-bindings/_config.js
+++ b/test/vars/samples/mutated-vs-reassigned-bindings/_config.js
@@ -9,6 +9,7 @@ export default {
mutated: false,
reassigned: true,
referenced: true,
+ referenced_from_script: false,
writable: true
},
{
@@ -19,6 +20,7 @@ export default {
mutated: true,
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: false
}
]);
diff --git a/test/vars/samples/mutated-vs-reassigned/_config.js b/test/vars/samples/mutated-vs-reassigned/_config.js
index 21fc14d820..ba499674d2 100644
--- a/test/vars/samples/mutated-vs-reassigned/_config.js
+++ b/test/vars/samples/mutated-vs-reassigned/_config.js
@@ -9,6 +9,7 @@ export default {
mutated: false,
reassigned: true,
referenced: true,
+ referenced_from_script: false,
writable: true
},
{
@@ -19,6 +20,7 @@ export default {
mutated: true,
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: false
}
]);
diff --git a/test/vars/samples/props/_config.js b/test/vars/samples/props/_config.js
index 0c5c6f7e2a..a51c93fb03 100644
--- a/test/vars/samples/props/_config.js
+++ b/test/vars/samples/props/_config.js
@@ -9,6 +9,7 @@ export default {
mutated: false,
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: true
},
{
@@ -19,6 +20,7 @@ export default {
mutated: false,
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: true
},
{
@@ -29,6 +31,7 @@ export default {
mutated: false,
reassigned: false,
referenced: false,
+ referenced_from_script: true,
writable: true
},
{
@@ -39,6 +42,7 @@ export default {
mutated: false,
reassigned: true,
referenced: true,
+ referenced_from_script: true,
writable: true
}
]);
diff --git a/test/vars/samples/referenced-from-script/_config.js b/test/vars/samples/referenced-from-script/_config.js
new file mode 100644
index 0000000000..191a52f8cc
--- /dev/null
+++ b/test/vars/samples/referenced-from-script/_config.js
@@ -0,0 +1,160 @@
+export default {
+ test(assert, vars) {
+ assert.deepEqual(vars, [
+ {
+ name: 'i',
+ export_name: null,
+ injected: false,
+ module: false,
+ mutated: false,
+ reassigned: false,
+ referenced: false,
+ writable: false,
+ referenced_from_script: false,
+ },
+ {
+ name: 'j',
+ export_name: null,
+ injected: false,
+ module: false,
+ mutated: false,
+ reassigned: false,
+ referenced: false,
+ writable: false,
+ referenced_from_script: false,
+ },
+ {
+ name: 'k',
+ export_name: null,
+ injected: false,
+ module: false,
+ mutated: false,
+ reassigned: false,
+ referenced: false,
+ writable: false,
+ referenced_from_script: false,
+ },
+ {
+ name: 'a',
+ export_name: null,
+ injected: false,
+ module: false,
+ mutated: false,
+ reassigned: true,
+ referenced: false,
+ writable: true,
+ referenced_from_script: true,
+ },
+ {
+ name: 'b',
+ export_name: null,
+ injected: false,
+ module: false,
+ mutated: false,
+ reassigned: false,
+ referenced: false,
+ writable: true,
+ referenced_from_script: true,
+ },
+ {
+ name: 'c',
+ export_name: null,
+ injected: false,
+ module: false,
+ mutated: false,
+ reassigned: false,
+ referenced: false,
+ writable: true,
+ referenced_from_script: true,
+ },
+ {
+ name: 'd',
+ export_name: null,
+ injected: false,
+ module: false,
+ mutated: false,
+ reassigned: false,
+ referenced: false,
+ writable: true,
+ referenced_from_script: true,
+ },
+ {
+ name: 'e',
+ export_name: null,
+ injected: false,
+ module: false,
+ mutated: false,
+ reassigned: false,
+ referenced: false,
+ writable: true,
+ referenced_from_script: false,
+ },
+ {
+ name: 'f',
+ export_name: 'f',
+ injected: false,
+ module: false,
+ mutated: false,
+ reassigned: false,
+ referenced: false,
+ writable: true,
+ referenced_from_script: false,
+ },
+ {
+ name: 'g',
+ export_name: null,
+ injected: false,
+ module: false,
+ mutated: false,
+ reassigned: false,
+ referenced: false,
+ writable: true,
+ referenced_from_script: true,
+ },
+ {
+ name: 'h',
+ export_name: null,
+ injected: false,
+ module: false,
+ mutated: false,
+ reassigned: true,
+ referenced: false,
+ writable: true,
+ referenced_from_script: true,
+ },
+ {
+ name: 'foo',
+ export_name: null,
+ injected: false,
+ module: false,
+ mutated: false,
+ reassigned: false,
+ referenced: false,
+ writable: false,
+ referenced_from_script: false,
+ },
+ {
+ name: 'l',
+ export_name: null,
+ injected: false,
+ module: false,
+ mutated: false,
+ reassigned: false,
+ referenced: false,
+ referenced_from_script: true,
+ writable: false,
+ },
+ {
+ name: 'bar',
+ export_name: 'bar',
+ injected: false,
+ module: false,
+ mutated: false,
+ reassigned: false,
+ referenced: false,
+ writable: false,
+ referenced_from_script: false,
+ },
+ ]);
+ },
+};
diff --git a/test/vars/samples/referenced-from-script/input.svelte b/test/vars/samples/referenced-from-script/input.svelte
new file mode 100644
index 0000000000..fbec4e6cf7
--- /dev/null
+++ b/test/vars/samples/referenced-from-script/input.svelte
@@ -0,0 +1,16 @@
+
diff --git a/test/vars/samples/store-referenced/_config.js b/test/vars/samples/store-referenced/_config.js
index 632a9e5b3f..bac35d1dba 100644
--- a/test/vars/samples/store-referenced/_config.js
+++ b/test/vars/samples/store-referenced/_config.js
@@ -9,6 +9,7 @@ export default {
mutated: false,
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: true
},
{
@@ -19,6 +20,7 @@ export default {
mutated: true,
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: true
}
]);
diff --git a/test/vars/samples/store-unreferenced/_config.js b/test/vars/samples/store-unreferenced/_config.js
index 86e467c859..4965e52fec 100644
--- a/test/vars/samples/store-unreferenced/_config.js
+++ b/test/vars/samples/store-unreferenced/_config.js
@@ -9,6 +9,7 @@ export default {
mutated: false,
reassigned: false,
referenced: true,
+ referenced_from_script: true,
writable: true
},
{
@@ -19,6 +20,7 @@ export default {
mutated: true,
reassigned: false,
referenced: false,
+ referenced_from_script: false,
writable: true
}
]);
diff --git a/test/vars/samples/template-references/_config.js b/test/vars/samples/template-references/_config.js
index adacc0d2ef..674e351517 100644
--- a/test/vars/samples/template-references/_config.js
+++ b/test/vars/samples/template-references/_config.js
@@ -9,6 +9,7 @@ export default {
name: 'Bar',
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: false,
},
{
@@ -19,6 +20,7 @@ export default {
name: 'foo',
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: true,
},
{
@@ -29,6 +31,7 @@ export default {
name: 'baz',
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: true,
},
]);
diff --git a/test/vars/samples/transitions/_config.js b/test/vars/samples/transitions/_config.js
index b2522a1b56..29a99b16cc 100644
--- a/test/vars/samples/transitions/_config.js
+++ b/test/vars/samples/transitions/_config.js
@@ -9,6 +9,7 @@ export default {
name: 'hoistable_foo',
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: false
},
{
@@ -19,6 +20,7 @@ export default {
name: 'hoistable_bar',
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: false
},
{
@@ -29,6 +31,7 @@ export default {
name: 'hoistable_baz',
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: false
},
{
@@ -39,6 +42,7 @@ export default {
name: 'foo',
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: true
},
{
@@ -49,6 +53,7 @@ export default {
name: 'bar',
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: true
},
{
@@ -59,6 +64,7 @@ export default {
name: 'baz',
reassigned: false,
referenced: true,
+ referenced_from_script: false,
writable: true
}
]);