Skip to content

Commit

Permalink
adding tests for sveltejs#4170
Browse files Browse the repository at this point in the history
  • Loading branch information
AnatoleLucet committed Dec 30, 2019
1 parent 4c38134 commit 0d40cb6
Show file tree
Hide file tree
Showing 59 changed files with 191 additions and 137 deletions.
4 changes: 2 additions & 2 deletions test/js/samples/action-custom-event-handler/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ function handleFoo(bar) {
}

function foo(node, callback) {

}

function instance($$self, $$props, $$invalidate) {
let { bar } = $$props;
const foo_function = () => handleFoo(bar);

$$self.$set = $$props => {
if ("bar" in $$props) $$invalidate(0, bar = $$props.bar);
if ("bar" in $$props) $$invalidate({ i: 0, ret: bar = $$props.bar });
};

return [bar, foo_function];
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/bind-online/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function instance($$self, $$props, $$invalidate) {
let online;

function onlinestatuschanged() {
$$invalidate(0, online = navigator.onLine);
$$invalidate({ i: 0, ret: online = navigator.onLine });
}

return [online, onlinestatuschanged];
Expand Down
4 changes: 2 additions & 2 deletions test/js/samples/bind-open/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ function instance($$self, $$props, $$invalidate) {

function details_toggle_handler() {
open = this.open;
$$invalidate(0, open);
$$invalidate({ i: 0, ret: open });
}

$$self.$set = $$props => {
if ("open" in $$props) $$invalidate(0, open = $$props.open);
if ("open" in $$props) $$invalidate({ i: 0, ret: open = $$props.open });
};

return [open, details_toggle_handler];
Expand Down
8 changes: 4 additions & 4 deletions test/js/samples/bind-width-height/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ function instance($$self, $$props, $$invalidate) {
function div_elementresize_handler() {
w = this.offsetWidth;
h = this.offsetHeight;
$$invalidate(0, w);
$$invalidate(1, h);
$$invalidate({ i: 0, ret: w });
$$invalidate({ i: 1, ret: h });
}

$$self.$set = $$props => {
if ("w" in $$props) $$invalidate(0, w = $$props.w);
if ("h" in $$props) $$invalidate(1, h = $$props.h);
if ("w" in $$props) $$invalidate({ i: 0, ret: w = $$props.w });
if ("h" in $$props) $$invalidate({ i: 1, ret: h = $$props.h });
};

return [w, h, div_elementresize_handler];
Expand Down
6 changes: 3 additions & 3 deletions test/js/samples/bindings-readonly-order/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ function instance($$self, $$props, $$invalidate) {

function input0_change_handler() {
files = this.files;
$$invalidate(0, files);
$$invalidate({ i: 0, ret: files });
}

function input1_change_handler() {
files = this.files;
$$invalidate(0, files);
$$invalidate({ i: 0, ret: files });
}

$$self.$set = $$props => {
if ("files" in $$props) $$invalidate(0, files = $$props.files);
if ("files" in $$props) $$invalidate({ i: 0, ret: files = $$props.files });
};

return [files, input0_change_handler, input1_change_handler];
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/capture-inject-dev-only/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function instance($$self, $$props, $$invalidate) {

function input_input_handler() {
foo = this.value;
$$invalidate(0, foo);
$$invalidate({ i: 0, ret: foo });
}

return [foo, input_input_handler];
Expand Down
4 changes: 2 additions & 2 deletions test/js/samples/collapses-text-around-comments/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function instance($$self, $$props, $$invalidate) {
let { foo = 42 } = $$props;

$$self.$set = $$props => {
if ("foo" in $$props) $$invalidate(0, foo = $$props.foo);
if ("foo" in $$props) $$invalidate({ i: 0, ret: foo = $$props.foo });
};

return [foo];
Expand All @@ -63,4 +63,4 @@ class Component extends SvelteComponent {
}
}

export default Component;
export default Component;
2 changes: 1 addition & 1 deletion test/js/samples/component-static-var/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function instance($$self, $$props, $$invalidate) {

function input_input_handler() {
z = this.value;
$$invalidate(0, z);
$$invalidate({ i: 0, ret: z });
}

return [z, input_input_handler];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function create_fragment(ctx) {
function instance($$self, $$props, $$invalidate) {
let $foo;
const foo = writable(0);
component_subscribe($$self, foo, value => $$invalidate(0, $foo = value));
component_subscribe($$self, foo, value => $$invalidate({ i: 0, ret: $foo = value }));
return [$foo, foo];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { count } from "./store.js";

function instance($$self, $$props, $$invalidate) {
let $count;
component_subscribe($$self, count, $$value => $$invalidate(1, $count = $$value));
component_subscribe($$self, count, $$value => $$invalidate({ i: 1, ret: $count = $$value }));

function increment() {
set_store_value(count, $count++, $count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ function create_fragment(ctx) {
function instance($$self, $$props, $$invalidate) {
let $foo,
$$unsubscribe_foo = noop,
$$subscribe_foo = () => ($$unsubscribe_foo(), $$unsubscribe_foo = subscribe(foo, $$value => $$invalidate(1, $foo = $$value)), foo);
$$subscribe_foo = () => ($$unsubscribe_foo(), $$unsubscribe_foo = subscribe(foo, $$value => $$invalidate({ i: 1, ret: $foo = $$value })), foo);

$$self.$$.on_destroy.push(() => $$unsubscribe_foo());
let foo = writable(0);
$$subscribe_foo();
const click_handler = () => $$subscribe_foo($$invalidate(0, foo = writable(0)));
const click_handler = () => $$subscribe_foo($$invalidate({ i: 0, ret: foo = writable(0) }));
return [foo, $foo, click_handler];
}

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/computed-collapsed-if/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function instance($$self, $$props, $$invalidate) {
}

$$self.$set = $$props => {
if ("x" in $$props) $$invalidate(0, x = $$props.x);
if ("x" in $$props) $$invalidate({ i: 0, ret: x = $$props.x });
};

return [x, a, b];
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/css-media-query/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ class Component extends SvelteComponent {
}
}

export default Component;
export default Component;
2 changes: 1 addition & 1 deletion test/js/samples/data-attribute/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function instance($$self, $$props, $$invalidate) {
let { bar } = $$props;

$$self.$set = $$props => {
if ("bar" in $$props) $$invalidate(0, bar = $$props.bar);
if ("bar" in $$props) $$invalidate({ i: 0, ret: bar = $$props.bar });
};

return [bar];
Expand Down
4 changes: 2 additions & 2 deletions test/js/samples/debug-empty/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ function instance($$self, $$props, $$invalidate) {
});

$$self.$set = $$props => {
if ("name" in $$props) $$invalidate(0, name = $$props.name);
if ("name" in $$props) $$invalidate({ i: 0, ret: name = $$props.name });
};

$$self.$capture_state = () => {
return { name };
};

$$self.$inject_state = $$props => {
if ("name" in $$props) $$invalidate(0, name = $$props.name);
if ("name" in $$props) $$invalidate({ i: 0, ret: name = $$props.name });
};

return [name];
Expand Down
16 changes: 8 additions & 8 deletions test/js/samples/debug-foo-bar-baz-things/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,21 @@ function instance($$self, $$props, $$invalidate) {
});

$$self.$set = $$props => {
if ("things" in $$props) $$invalidate(0, things = $$props.things);
if ("foo" in $$props) $$invalidate(1, foo = $$props.foo);
if ("bar" in $$props) $$invalidate(2, bar = $$props.bar);
if ("baz" in $$props) $$invalidate(3, baz = $$props.baz);
if ("things" in $$props) $$invalidate({ i: 0, ret: things = $$props.things });
if ("foo" in $$props) $$invalidate({ i: 1, ret: foo = $$props.foo });
if ("bar" in $$props) $$invalidate({ i: 2, ret: bar = $$props.bar });
if ("baz" in $$props) $$invalidate({ i: 3, ret: baz = $$props.baz });
};

$$self.$capture_state = () => {
return { things, foo, bar, baz };
};

$$self.$inject_state = $$props => {
if ("things" in $$props) $$invalidate(0, things = $$props.things);
if ("foo" in $$props) $$invalidate(1, foo = $$props.foo);
if ("bar" in $$props) $$invalidate(2, bar = $$props.bar);
if ("baz" in $$props) $$invalidate(3, baz = $$props.baz);
if ("things" in $$props) $$invalidate({ i: 0, ret: things = $$props.things });
if ("foo" in $$props) $$invalidate({ i: 1, ret: foo = $$props.foo });
if ("bar" in $$props) $$invalidate({ i: 2, ret: bar = $$props.bar });
if ("baz" in $$props) $$invalidate({ i: 3, ret: baz = $$props.baz });
};

return [things, foo, bar, baz];
Expand Down
8 changes: 4 additions & 4 deletions test/js/samples/debug-foo/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,17 @@ function instance($$self, $$props, $$invalidate) {
});

$$self.$set = $$props => {
if ("things" in $$props) $$invalidate(0, things = $$props.things);
if ("foo" in $$props) $$invalidate(1, foo = $$props.foo);
if ("things" in $$props) $$invalidate({ i: 0, ret: things = $$props.things });
if ("foo" in $$props) $$invalidate({ i: 1, ret: foo = $$props.foo });
};

$$self.$capture_state = () => {
return { things, foo };
};

$$self.$inject_state = $$props => {
if ("things" in $$props) $$invalidate(0, things = $$props.things);
if ("foo" in $$props) $$invalidate(1, foo = $$props.foo);
if ("things" in $$props) $$invalidate({ i: 0, ret: things = $$props.things });
if ("foo" in $$props) $$invalidate({ i: 1, ret: foo = $$props.foo });
};

return [things, foo];
Expand Down
4 changes: 2 additions & 2 deletions test/js/samples/debug-hoisted/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ function instance($$self) {
};

$$self.$inject_state = $$props => {
if ("obj" in $$props) $$invalidate(0, obj = $$props.obj);
if ("kobzol" in $$props) $$invalidate(1, kobzol = $$props.kobzol);
if ("obj" in $$props) $$invalidate({ i: 0, ret: obj = $$props.obj });
if ("kobzol" in $$props) $$invalidate({ i: 1, ret: kobzol = $$props.kobzol });
};

return [obj, kobzol];
Expand Down
5 changes: 4 additions & 1 deletion test/js/samples/deconflict-builtins/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ function instance($$self, $$props, $$invalidate) {
let { createElement } = $$props;

$$self.$set = $$props => {
if ("createElement" in $$props) $$invalidate(0, createElement = $$props.createElement);
if ("createElement" in $$props) $$invalidate({
i: 0,
ret: createElement = $$props.createElement
});
};

return [createElement];
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/deconflict-globals/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function instance($$self, $$props, $$invalidate) {
});

$$self.$set = $$props => {
if ("foo" in $$props) $$invalidate(0, foo = $$props.foo);
if ("foo" in $$props) $$invalidate({ i: 0, ret: foo = $$props.foo });
};

return [foo];
Expand Down
8 changes: 4 additions & 4 deletions test/js/samples/dev-warning-missing-data-computed/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,21 @@ function instance($$self, $$props, $$invalidate) {
});

$$self.$set = $$props => {
if ("foo" in $$props) $$invalidate(0, foo = $$props.foo);
if ("foo" in $$props) $$invalidate({ i: 0, ret: foo = $$props.foo });
};

$$self.$capture_state = () => {
return { foo, bar };
};

$$self.$inject_state = $$props => {
if ("foo" in $$props) $$invalidate(0, foo = $$props.foo);
if ("bar" in $$props) $$invalidate(1, bar = $$props.bar);
if ("foo" in $$props) $$invalidate({ i: 0, ret: foo = $$props.foo });
if ("bar" in $$props) $$invalidate({ i: 1, ret: bar = $$props.bar });
};

$$self.$$.update = () => {
if ($$self.$$.dirty & /*foo*/ 1) {
$: $$invalidate(1, bar = foo * 2);
$: $$invalidate({ i: 1, ret: bar = foo * 2 });
}
};

Expand Down
10 changes: 5 additions & 5 deletions test/js/samples/each-block-array-literal/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ function instance($$self, $$props, $$invalidate) {
let { e } = $$props;

$$self.$set = $$props => {
if ("a" in $$props) $$invalidate(0, a = $$props.a);
if ("b" in $$props) $$invalidate(1, b = $$props.b);
if ("c" in $$props) $$invalidate(2, c = $$props.c);
if ("d" in $$props) $$invalidate(3, d = $$props.d);
if ("e" in $$props) $$invalidate(4, e = $$props.e);
if ("a" in $$props) $$invalidate({ i: 0, ret: a = $$props.a });
if ("b" in $$props) $$invalidate({ i: 1, ret: b = $$props.b });
if ("c" in $$props) $$invalidate({ i: 2, ret: c = $$props.c });
if ("d" in $$props) $$invalidate({ i: 3, ret: d = $$props.d });
if ("e" in $$props) $$invalidate({ i: 4, ret: e = $$props.e });
};

return [a, b, c, d, e];
Expand Down
8 changes: 4 additions & 4 deletions test/js/samples/each-block-changed-check/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ function instance($$self, $$props, $$invalidate) {
let { foo } = $$props;

$$self.$set = $$props => {
if ("comments" in $$props) $$invalidate(0, comments = $$props.comments);
if ("elapsed" in $$props) $$invalidate(1, elapsed = $$props.elapsed);
if ("time" in $$props) $$invalidate(2, time = $$props.time);
if ("foo" in $$props) $$invalidate(3, foo = $$props.foo);
if ("comments" in $$props) $$invalidate({ i: 0, ret: comments = $$props.comments });
if ("elapsed" in $$props) $$invalidate({ i: 1, ret: elapsed = $$props.elapsed });
if ("time" in $$props) $$invalidate({ i: 2, ret: time = $$props.time });
if ("foo" in $$props) $$invalidate({ i: 3, ret: foo = $$props.foo });
};

return [comments, elapsed, time, foo];
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/each-block-keyed-animated/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function instance($$self, $$props, $$invalidate) {
let { things } = $$props;

$$self.$set = $$props => {
if ("things" in $$props) $$invalidate(0, things = $$props.things);
if ("things" in $$props) $$invalidate({ i: 0, ret: things = $$props.things });
};

return [things];
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/each-block-keyed/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function instance($$self, $$props, $$invalidate) {
let { things } = $$props;

$$self.$set = $$props => {
if ("things" in $$props) $$invalidate(0, things = $$props.things);
if ("things" in $$props) $$invalidate({ i: 0, ret: things = $$props.things });
};

return [things];
Expand Down
10 changes: 8 additions & 2 deletions test/js/samples/event-handler-dynamic/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,17 @@ function instance($$self, $$props, $$invalidate) {
let number = 0;

function updateHandler1() {
$$invalidate(0, clickHandler = () => $$invalidate(1, number = 1));
$$invalidate({
i: 0,
ret: clickHandler = () => $$invalidate({ i: 1, ret: number = 1 })
});
}

function updateHandler2() {
$$invalidate(0, clickHandler = () => $$invalidate(1, number = 2));
$$invalidate({
i: 0,
ret: clickHandler = () => $$invalidate({ i: 1, ret: number = 2 })
});
}

return [clickHandler, number, updateHandler1, updateHandler2];
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/if-block-no-update/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function instance($$self, $$props, $$invalidate) {
let { foo } = $$props;

$$self.$set = $$props => {
if ("foo" in $$props) $$invalidate(0, foo = $$props.foo);
if ("foo" in $$props) $$invalidate({ i: 0, ret: foo = $$props.foo });
};

return [foo];
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/if-block-simple/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function instance($$self, $$props, $$invalidate) {
let { foo } = $$props;

$$self.$set = $$props => {
if ("foo" in $$props) $$invalidate(0, foo = $$props.foo);
if ("foo" in $$props) $$invalidate({ i: 0, ret: foo = $$props.foo });
};

return [foo];
Expand Down
6 changes: 3 additions & 3 deletions test/js/samples/inline-style-optimized-multiple/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ function instance($$self, $$props, $$invalidate) {
let { y } = $$props;

$$self.$set = $$props => {
if ("color" in $$props) $$invalidate(0, color = $$props.color);
if ("x" in $$props) $$invalidate(1, x = $$props.x);
if ("y" in $$props) $$invalidate(2, y = $$props.y);
if ("color" in $$props) $$invalidate({ i: 0, ret: color = $$props.color });
if ("x" in $$props) $$invalidate({ i: 1, ret: x = $$props.x });
if ("y" in $$props) $$invalidate({ i: 2, ret: y = $$props.y });
};

return [color, x, y];
Expand Down
Loading

0 comments on commit 0d40cb6

Please sign in to comment.