mirror of https://github.com/sveltejs/svelte
parent
8b2ad778f1
commit
3eb16eba24
@ -1,20 +1,20 @@
|
|||||||
export default {
|
export default {
|
||||||
html: `
|
html: `
|
||||||
<p>4, 12, 60</p>
|
<p>4, 12, 60</p>
|
||||||
`,
|
`,
|
||||||
|
|
||||||
async test({ component, target, assert }) {
|
async test({ component, target, assert }) {
|
||||||
component.permutation = [2, 3, 1];
|
component.permutation = [2, 3, 1];
|
||||||
await (component.promise1 = Promise.resolve({length: 1, width: 2, height: 3}));
|
await (component.promise1 = Promise.resolve({length: 1, width: 2, height: 3}));
|
||||||
try {
|
try {
|
||||||
await (component.promise2 = Promise.reject({length: 97, width: 98, height: 99}));
|
await (component.promise2 = Promise.reject({length: 97, width: 98, height: 99}));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// nothing
|
// nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.htmlEqual(target.innerHTML, `
|
assert.htmlEqual(target.innerHTML, `
|
||||||
<p>2, 11, 2</p>
|
<p>2, 11, 2</p>
|
||||||
<p>9506, 28811, 98</p>
|
<p>9506, 28811, 98</p>
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
<script>
|
<script>
|
||||||
export let promise1 = {length: 5, width: 3, height: 4};
|
export let promise1 = {length: 5, width: 3, height: 4};
|
||||||
export let promise2 = {length: 12, width: 5, height: 13};
|
export let promise2 = {length: 12, width: 5, height: 13};
|
||||||
export let permutation = [1, 2, 3];
|
export let permutation = [1, 2, 3];
|
||||||
|
|
||||||
function calculate(length, width, height) {
|
function calculate(length, width, height) {
|
||||||
return {
|
return {
|
||||||
'1-Dimensions': [length, width, height],
|
'1-Dimensions': [length, width, height],
|
||||||
'2-Dimensions': [length * width, width * height, length * height],
|
'2-Dimensions': [length * width, width * height, length * height],
|
||||||
'3-Dimensions': [length * width * height, length + width + height, length * width + width * height + length * height]
|
'3-Dimensions': [length * width * height, length + width + height, length * width + width * height + length * height]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#await promise1 then { length, width, height }}
|
{#await promise1 then { length, width, height }}
|
||||||
{@const [a, b, c] = permutation}
|
{@const [a, b, c] = permutation}
|
||||||
{@const { [`${a}-Dimensions`]: { [c - 1]: first }, [`${b}-Dimensions`]: { [b - 1]: second }, [`${c}-Dimensions`]: { [a - 1]: third } } = calculate(length, width, height) }
|
{@const { [`${a}-Dimensions`]: { [c - 1]: first }, [`${b}-Dimensions`]: { [b - 1]: second }, [`${c}-Dimensions`]: { [a - 1]: third } } = calculate(length, width, height) }
|
||||||
<p>{first}, {second}, {third}</p>
|
<p>{first}, {second}, {third}</p>
|
||||||
{/await}
|
{/await}
|
||||||
|
|
||||||
{#await promise2 catch { length, width, height }}
|
{#await promise2 catch { length, width, height }}
|
||||||
{@const [a, b, c] = permutation}
|
{@const [a, b, c] = permutation}
|
||||||
{@const { [`${a}-Dimensions`]: { [c - 1]: first }, [`${b}-Dimensions`]: { [b - 1]: second }, [`${c}-Dimensions`]: { [a - 1]: third } } = calculate(length, width, height) }
|
{@const { [`${a}-Dimensions`]: { [c - 1]: first }, [`${b}-Dimensions`]: { [b - 1]: second }, [`${c}-Dimensions`]: { [a - 1]: third } } = calculate(length, width, height) }
|
||||||
<p>{first}, {second}, {third}</p>
|
<p>{first}, {second}, {third}</p>
|
||||||
{/await}
|
{/await}
|
||||||
|
|||||||
Loading…
Reference in new issue