From 9223f56323daa2026bf4b373cdfd7022d06f2baf Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Mon, 10 Jun 2019 15:43:11 -0700 Subject: [PATCH] Fix tests --- test/js/samples/debug-empty/expected.js | 36 ++++++++----- .../debug-foo-bar-baz-things/expected.js | 53 ++++++++++++------- test/js/samples/debug-foo/expected.js | 51 +++++++++++------- test/js/samples/debug-hoisted/expected.js | 13 ++++- .../expected.js | 35 +++++++----- test/js/samples/event-modifiers/expected.js | 2 +- 6 files changed, 120 insertions(+), 70 deletions(-) diff --git a/test/js/samples/debug-empty/expected.js b/test/js/samples/debug-empty/expected.js index 6f07993590..dac09a363e 100644 --- a/test/js/samples/debug-empty/expected.js +++ b/test/js/samples/debug-empty/expected.js @@ -2,14 +2,15 @@ import { SvelteComponentDev, add_location, - append, - detach, + append_dev, + detach_dev, + dispatch_dev, element, init, - insert, + insert_dev, noop, safe_not_equal, - set_data, + set_data_dev, space, text } from "svelte/internal"; @@ -19,7 +20,7 @@ const file = undefined; function create_fragment(ctx) { var h1, t0, t1, t2, t3; - return { + const block = { c: function create() { h1 = element("h1"); t0 = text("Hello "); @@ -35,16 +36,16 @@ function create_fragment(ctx) { }, m: function mount(target, anchor) { - insert(target, h1, anchor); - append(h1, t0); - append(h1, t1); - append(h1, t2); - insert(target, t3, anchor); + insert_dev(target, h1, anchor); + append_dev(h1, t0); + append_dev(h1, t1); + append_dev(h1, t2); + insert_dev(target, t3, anchor); }, p: function update(changed, ctx) { if (changed.name) { - set_data(t1, ctx.name); + set_data_dev(t1, ctx.name); } debugger; @@ -55,11 +56,13 @@ function create_fragment(ctx) { d: function destroy(detaching) { if (detaching) { - detach(h1); - detach(t3); + detach_dev(h1); + detach_dev(t3); } } }; + dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment.name, type: "component", source: "", ctx }); + return block; } function instance($$self, $$props, $$invalidate) { @@ -74,6 +77,10 @@ function instance($$self, $$props, $$invalidate) { if ('name' in $$props) $$invalidate('name', name = $$props.name); }; + $$self.$unsafe_set = $$values => { + if ('name' in $$values) $$invalidate('name', name = $$values.name); + }; + return { name }; } @@ -81,6 +88,7 @@ class Component extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance, create_fragment, safe_not_equal, ["name"]); + dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Component", id: create_fragment.name }); const { ctx } = this.$$; const props = options.props || {}; @@ -98,4 +106,4 @@ class Component extends SvelteComponentDev { } } -export default Component; \ No newline at end of file +export default Component; diff --git a/test/js/samples/debug-foo-bar-baz-things/expected.js b/test/js/samples/debug-foo-bar-baz-things/expected.js index eea35d5ba7..6ea41a380b 100644 --- a/test/js/samples/debug-foo-bar-baz-things/expected.js +++ b/test/js/samples/debug-foo-bar-baz-things/expected.js @@ -2,15 +2,16 @@ import { SvelteComponentDev, add_location, - append, + append_dev, destroy_each, - detach, + detach_dev, + dispatch_dev, element, init, - insert, + insert_dev, noop, safe_not_equal, - set_data, + set_data_dev, space, text } from "svelte/internal"; @@ -27,7 +28,7 @@ function get_each_context(ctx, list, i) { function create_each_block(ctx) { var span, t0_value = ctx.thing.name, t0, t1; - return { + const block = { c: function create() { span = element("span"); t0 = text(t0_value); @@ -42,14 +43,14 @@ function create_each_block(ctx) { }, m: function mount(target, anchor) { - insert(target, span, anchor); - append(span, t0); - insert(target, t1, anchor); + insert_dev(target, span, anchor); + append_dev(span, t0); + insert_dev(target, t1, anchor); }, p: function update(changed, ctx) { if ((changed.things) && t0_value !== (t0_value = ctx.thing.name)) { - set_data(t0, t0_value); + set_data_dev(t0, t0_value); } if (changed.foo || changed.bar || changed.baz || changed.things) { @@ -61,11 +62,13 @@ function create_each_block(ctx) { d: function destroy(detaching) { if (detaching) { - detach(span); - detach(t1); + detach_dev(span); + detach_dev(t1); } } }; + dispatch_dev("SvelteRegisterBlock", { block, id: create_each_block.name, type: "each", source: "(8:0) {#each things as thing}", ctx }); + return block; } function create_fragment(ctx) { @@ -79,7 +82,7 @@ function create_fragment(ctx) { each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); } - return { + const block = { c: function create() { for (var i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); @@ -101,10 +104,10 @@ function create_fragment(ctx) { each_blocks[i].m(target, anchor); } - insert(target, t0, anchor); - insert(target, p, anchor); - append(p, t1); - append(p, t2); + insert_dev(target, t0, anchor); + insert_dev(target, p, anchor); + append_dev(p, t1); + append_dev(p, t2); }, p: function update(changed, ctx) { @@ -130,7 +133,7 @@ function create_fragment(ctx) { } if (changed.foo) { - set_data(t2, ctx.foo); + set_data_dev(t2, ctx.foo); } }, @@ -141,11 +144,13 @@ function create_fragment(ctx) { destroy_each(each_blocks, detaching); if (detaching) { - detach(t0); - detach(p); + detach_dev(t0); + detach_dev(p); } } }; + dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment.name, type: "component", source: "", ctx }); + return block; } function instance($$self, $$props, $$invalidate) { @@ -163,6 +168,13 @@ function instance($$self, $$props, $$invalidate) { if ('baz' in $$props) $$invalidate('baz', baz = $$props.baz); }; + $$self.$unsafe_set = $$values => { + if ('things' in $$values) $$invalidate('things', things = $$values.things); + if ('foo' in $$values) $$invalidate('foo', foo = $$values.foo); + if ('bar' in $$values) $$invalidate('bar', bar = $$values.bar); + if ('baz' in $$values) $$invalidate('baz', baz = $$values.baz); + }; + return { things, foo, bar, baz }; } @@ -170,6 +182,7 @@ class Component extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance, create_fragment, safe_not_equal, ["things", "foo", "bar", "baz"]); + dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Component", id: create_fragment.name }); const { ctx } = this.$$; const props = options.props || {}; @@ -220,4 +233,4 @@ class Component extends SvelteComponentDev { } } -export default Component; \ No newline at end of file +export default Component; diff --git a/test/js/samples/debug-foo/expected.js b/test/js/samples/debug-foo/expected.js index 5b931d9464..b8bd7f56b7 100644 --- a/test/js/samples/debug-foo/expected.js +++ b/test/js/samples/debug-foo/expected.js @@ -2,15 +2,16 @@ import { SvelteComponentDev, add_location, - append, + append_dev, destroy_each, - detach, + detach_dev, + dispatch_dev, element, init, - insert, + insert_dev, noop, safe_not_equal, - set_data, + set_data_dev, space, text } from "svelte/internal"; @@ -27,7 +28,7 @@ function get_each_context(ctx, list, i) { function create_each_block(ctx) { var span, t0_value = ctx.thing.name, t0, t1; - return { + const block = { c: function create() { span = element("span"); t0 = text(t0_value); @@ -42,14 +43,14 @@ function create_each_block(ctx) { }, m: function mount(target, anchor) { - insert(target, span, anchor); - append(span, t0); - insert(target, t1, anchor); + insert_dev(target, span, anchor); + append_dev(span, t0); + insert_dev(target, t1, anchor); }, p: function update(changed, ctx) { if ((changed.things) && t0_value !== (t0_value = ctx.thing.name)) { - set_data(t0, t0_value); + set_data_dev(t0, t0_value); } if (changed.foo) { @@ -61,11 +62,13 @@ function create_each_block(ctx) { d: function destroy(detaching) { if (detaching) { - detach(span); - detach(t1); + detach_dev(span); + detach_dev(t1); } } }; + dispatch_dev("SvelteRegisterBlock", { block, id: create_each_block.name, type: "each", source: "(6:0) {#each things as thing}", ctx }); + return block; } function create_fragment(ctx) { @@ -79,7 +82,7 @@ function create_fragment(ctx) { each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); } - return { + const block = { c: function create() { for (var i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); @@ -101,10 +104,10 @@ function create_fragment(ctx) { each_blocks[i].m(target, anchor); } - insert(target, t0, anchor); - insert(target, p, anchor); - append(p, t1); - append(p, t2); + insert_dev(target, t0, anchor); + insert_dev(target, p, anchor); + append_dev(p, t1); + append_dev(p, t2); }, p: function update(changed, ctx) { @@ -130,7 +133,7 @@ function create_fragment(ctx) { } if (changed.foo) { - set_data(t2, ctx.foo); + set_data_dev(t2, ctx.foo); } }, @@ -141,11 +144,13 @@ function create_fragment(ctx) { destroy_each(each_blocks, detaching); if (detaching) { - detach(t0); - detach(p); + detach_dev(t0); + detach_dev(p); } } }; + dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment.name, type: "component", source: "", ctx }); + return block; } function instance($$self, $$props, $$invalidate) { @@ -161,6 +166,11 @@ function instance($$self, $$props, $$invalidate) { if ('foo' in $$props) $$invalidate('foo', foo = $$props.foo); }; + $$self.$unsafe_set = $$values => { + if ('things' in $$values) $$invalidate('things', things = $$values.things); + if ('foo' in $$values) $$invalidate('foo', foo = $$values.foo); + }; + return { things, foo }; } @@ -168,6 +178,7 @@ class Component extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance, create_fragment, safe_not_equal, ["things", "foo"]); + dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Component", id: create_fragment.name }); const { ctx } = this.$$; const props = options.props || {}; @@ -196,4 +207,4 @@ class Component extends SvelteComponentDev { } } -export default Component; \ No newline at end of file +export default Component; diff --git a/test/js/samples/debug-hoisted/expected.js b/test/js/samples/debug-hoisted/expected.js index 51d8bf63a3..c250099364 100644 --- a/test/js/samples/debug-hoisted/expected.js +++ b/test/js/samples/debug-hoisted/expected.js @@ -1,6 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { SvelteComponentDev, + dispatch_dev, init, noop, safe_not_equal @@ -9,7 +10,7 @@ import { const file = undefined; function create_fragment(ctx) { - return { + const block = { c: function create() { { const { obj } = ctx; @@ -36,6 +37,8 @@ function create_fragment(ctx) { o: noop, d: noop }; + dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment.name, type: "component", source: "", ctx }); + return block; } let kobzol = 5; @@ -43,6 +46,11 @@ let kobzol = 5; function instance($$self) { let obj = { x: 5 }; + $$self.$unsafe_set = $$values => { + if ('obj' in $$values) $$invalidate('obj', obj = $$values.obj); + if ('kobzol' in $$values) $$invalidate('kobzol', kobzol = $$values.kobzol); + }; + return { obj }; } @@ -50,7 +58,8 @@ class Component extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance, create_fragment, safe_not_equal, []); + dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Component", id: create_fragment.name }); } } -export default Component; \ No newline at end of file +export default Component; diff --git a/test/js/samples/dev-warning-missing-data-computed/expected.js b/test/js/samples/dev-warning-missing-data-computed/expected.js index 5c4b2ece1b..ecbf119efe 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected.js @@ -2,14 +2,15 @@ import { SvelteComponentDev, add_location, - append, - detach, + append_dev, + detach_dev, + dispatch_dev, element, init, - insert, + insert_dev, noop, safe_not_equal, - set_data, + set_data_dev, space, text } from "svelte/internal"; @@ -19,7 +20,7 @@ const file = undefined; function create_fragment(ctx) { var p, t0_value = Math.max(0, ctx.foo), t0, t1, t2; - return { + const block = { c: function create() { p = element("p"); t0 = text(t0_value); @@ -33,19 +34,19 @@ function create_fragment(ctx) { }, m: function mount(target, anchor) { - insert(target, p, anchor); - append(p, t0); - append(p, t1); - append(p, t2); + insert_dev(target, p, anchor); + append_dev(p, t0); + append_dev(p, t1); + append_dev(p, t2); }, p: function update(changed, ctx) { if ((changed.foo) && t0_value !== (t0_value = Math.max(0, ctx.foo))) { - set_data(t0, t0_value); + set_data_dev(t0, t0_value); } if (changed.bar) { - set_data(t2, ctx.bar); + set_data_dev(t2, ctx.bar); } }, @@ -54,10 +55,12 @@ function create_fragment(ctx) { d: function destroy(detaching) { if (detaching) { - detach(p); + detach_dev(p); } } }; + dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment.name, type: "component", source: "", ctx }); + return block; } function instance($$self, $$props, $$invalidate) { @@ -74,6 +77,11 @@ function instance($$self, $$props, $$invalidate) { if ('foo' in $$props) $$invalidate('foo', foo = $$props.foo); }; + $$self.$unsafe_set = $$values => { + if ('foo' in $$values) $$invalidate('foo', foo = $$values.foo); + if ('bar' in $$values) $$invalidate('bar', bar = $$values.bar); + }; + $$self.$$.update = ($$dirty = { foo: 1 }) => { if ($$dirty.foo) { $$invalidate('bar', bar = foo * 2); } }; @@ -85,6 +93,7 @@ class Component extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance, create_fragment, safe_not_equal, ["foo"]); + dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Component", id: create_fragment.name }); const { ctx } = this.$$; const props = options.props || {}; @@ -102,4 +111,4 @@ class Component extends SvelteComponentDev { } } -export default Component; \ No newline at end of file +export default Component; diff --git a/test/js/samples/event-modifiers/expected.js b/test/js/samples/event-modifiers/expected.js index bd449ea5a4..5048cc5955 100644 --- a/test/js/samples/event-modifiers/expected.js +++ b/test/js/samples/event-modifiers/expected.js @@ -75,4 +75,4 @@ class Component extends SvelteComponent { } } -export default Component; \ No newline at end of file +export default Component;