Add test for store val and exported unreactive val

pull/5926/head
J Delaney 6 years ago
parent 4fd93a1094
commit fd20fd5c45

@ -1,6 +1,7 @@
/* generated by Svelte vX.Y.Z */ /* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
component_subscribe,
detach, detach,
element, element,
init, init,
@ -8,9 +9,12 @@ import {
noop, noop,
safe_not_equal, safe_not_equal,
space, space,
subscribe,
toggle_class toggle_class
} from "svelte/internal"; } from "svelte/internal";
import { reactiveStoreVal, unreactiveExport } from "./store";
function create_fragment(ctx) { function create_fragment(ctx) {
let div0; let div0;
let t0; let t0;
@ -23,6 +27,12 @@ function create_fragment(ctx) {
let div4; let div4;
let t4; let t4;
let div5; let div5;
let t5;
let div6;
let t6;
let div7;
let t7;
let div8;
return { return {
c() { c() {
@ -37,12 +47,21 @@ function create_fragment(ctx) {
div4 = element("div"); div4 = element("div");
t4 = space(); t4 = space();
div5 = element("div"); div5 = element("div");
t5 = space();
div6 = element("div");
t6 = space();
div7 = element("div");
t7 = space();
div8 = element("div");
toggle_class(div0, "update1", reactiveModuleVar); toggle_class(div0, "update1", reactiveModuleVar);
toggle_class(div1, "update2", /*reactiveConst*/ ctx[0].x); toggle_class(div1, "update2", /*reactiveConst*/ ctx[0].x);
toggle_class(div2, "update3", nonReactiveGlobal && /*reactiveConst*/ ctx[0].x); toggle_class(div2, "update3", nonReactiveGlobal && /*reactiveConst*/ ctx[0].x);
toggle_class(div3, "static1", nonReactiveModuleVar); toggle_class(div3, "update4", /*$reactiveStoreVal*/ ctx[2]);
toggle_class(div4, "static1", nonReactiveGlobal); toggle_class(div4, "update5", /*$reactiveDeclaration*/ ctx[3]);
toggle_class(div5, "static1", nonReactiveModuleVar && nonReactiveGlobal); toggle_class(div5, "static1", nonReactiveModuleVar);
toggle_class(div6, "static2", nonReactiveGlobal);
toggle_class(div7, "static3", nonReactiveModuleVar && nonReactiveGlobal);
toggle_class(div8, "static4", unreactiveExport);
}, },
m(target, anchor) { m(target, anchor) {
insert(target, div0, anchor); insert(target, div0, anchor);
@ -56,6 +75,12 @@ function create_fragment(ctx) {
insert(target, div4, anchor); insert(target, div4, anchor);
insert(target, t4, anchor); insert(target, t4, anchor);
insert(target, div5, anchor); insert(target, div5, anchor);
insert(target, t5, anchor);
insert(target, div6, anchor);
insert(target, t6, anchor);
insert(target, div7, anchor);
insert(target, t7, anchor);
insert(target, div8, anchor);
}, },
p(ctx, [dirty]) { p(ctx, [dirty]) {
if (dirty & /*reactiveModuleVar*/ 0) { if (dirty & /*reactiveModuleVar*/ 0) {
@ -69,6 +94,14 @@ function create_fragment(ctx) {
if (dirty & /*nonReactiveGlobal, reactiveConst*/ 1) { if (dirty & /*nonReactiveGlobal, reactiveConst*/ 1) {
toggle_class(div2, "update3", nonReactiveGlobal && /*reactiveConst*/ ctx[0].x); toggle_class(div2, "update3", nonReactiveGlobal && /*reactiveConst*/ ctx[0].x);
} }
if (dirty & /*$reactiveStoreVal*/ 4) {
toggle_class(div3, "update4", /*$reactiveStoreVal*/ ctx[2]);
}
if (dirty & /*$reactiveDeclaration*/ 8) {
toggle_class(div4, "update5", /*$reactiveDeclaration*/ ctx[3]);
}
}, },
i: noop, i: noop,
o: noop, o: noop,
@ -84,6 +117,12 @@ function create_fragment(ctx) {
if (detaching) detach(div4); if (detaching) detach(div4);
if (detaching) detach(t4); if (detaching) detach(t4);
if (detaching) detach(div5); if (detaching) detach(div5);
if (detaching) detach(t5);
if (detaching) detach(div6);
if (detaching) detach(t6);
if (detaching) detach(div7);
if (detaching) detach(t7);
if (detaching) detach(div8);
} }
}; };
} }
@ -92,6 +131,15 @@ let nonReactiveModuleVar = Math.random();
let reactiveModuleVar = Math.random(); let reactiveModuleVar = Math.random();
function instance($$self, $$props, $$invalidate) { function instance($$self, $$props, $$invalidate) {
let reactiveDeclaration;
let $reactiveStoreVal;
let $reactiveDeclaration,
$$unsubscribe_reactiveDeclaration = noop,
$$subscribe_reactiveDeclaration = () => ($$unsubscribe_reactiveDeclaration(), $$unsubscribe_reactiveDeclaration = subscribe(reactiveDeclaration, $$value => $$invalidate(3, $reactiveDeclaration = $$value)), reactiveDeclaration);
component_subscribe($$self, reactiveStoreVal, $$value => $$invalidate(2, $reactiveStoreVal = $$value));
$$self.$$.on_destroy.push(() => $$unsubscribe_reactiveDeclaration());
nonReactiveGlobal = Math.random(); nonReactiveGlobal = Math.random();
const reactiveConst = { x: Math.random() }; const reactiveConst = { x: Math.random() };
reactiveModuleVar += 1; reactiveModuleVar += 1;
@ -100,7 +148,13 @@ function instance($$self, $$props, $$invalidate) {
reactiveConst.x += 1; reactiveConst.x += 1;
} }
return [reactiveConst]; $$self.$$.update = () => {
if ($$self.$$.dirty & /*reactiveModuleVar*/ 0) {
$: $$subscribe_reactiveDeclaration($$invalidate(1, reactiveDeclaration = reactiveModuleVar * 2));
}
};
return [reactiveConst, reactiveDeclaration, $reactiveStoreVal, $reactiveDeclaration];
} }
class Component extends SvelteComponent { class Component extends SvelteComponent {

@ -4,9 +4,13 @@
</script> </script>
<script> <script>
import { reactiveStoreVal, unreactiveExport } from './store';
nonReactiveGlobal = Math.random(); nonReactiveGlobal = Math.random();
const reactiveConst = {x: Math.random()}; const reactiveConst = {x: Math.random()};
$: reactiveDeclaration = reactiveModuleVar * 2;
reactiveModuleVar += 1; reactiveModuleVar += 1;
if (Math.random()) { if (Math.random()) {
reactiveConst.x += 1; reactiveConst.x += 1;
@ -17,8 +21,11 @@
<div class:update1={reactiveModuleVar}></div> <div class:update1={reactiveModuleVar}></div>
<div class:update2={reactiveConst.x}></div> <div class:update2={reactiveConst.x}></div>
<div class:update3={nonReactiveGlobal && reactiveConst.x}></div> <div class:update3={nonReactiveGlobal && reactiveConst.x}></div>
<div class:update4={$reactiveStoreVal}></div>
<div class:update5={$reactiveDeclaration}></div>
<!--These shouldn't get updates because they're purely non-reactive--> <!--These shouldn't get updates because they're purely non-reactive-->
<div class:static1={nonReactiveModuleVar}></div> <div class:static1={nonReactiveModuleVar}></div>
<div class:static1={nonReactiveGlobal}></div> <div class:static2={nonReactiveGlobal}></div>
<div class:static1={nonReactiveModuleVar && nonReactiveGlobal}></div> <div class:static3={nonReactiveModuleVar && nonReactiveGlobal}></div>
<div class:static4={unreactiveExport}></div>

@ -0,0 +1,4 @@
import { writable } from '../../../../store';
export const reactiveStoreVal = writable(0);
export let unreactiveExport = true;
Loading…
Cancel
Save