66 lines
1.6 KiB
Plaintext
66 lines
1.6 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`disjoint_union.js 1`] = `
|
|
/* @flow */
|
|
|
|
type Shape =
|
|
{type: 'rectangle', width: number, height: number} |
|
|
{type: 'circle', radius: number};
|
|
|
|
function area(shape: Shape): number {
|
|
if (shape.type === 'square') { // TODO: this should be an error
|
|
return shape.width * shape.height;
|
|
} else if (shape.type === 'circle') {
|
|
return Math.PI * Math.pow(shape.radius, 2);
|
|
}
|
|
throw "unreachable"; // TODO: this shouldn't be needed
|
|
}
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/* @flow */
|
|
|
|
type Shape =
|
|
| { type: "rectangle", width: number, height: number }
|
|
| { type: "circle", radius: number };
|
|
|
|
function area(shape: Shape): number {
|
|
if (shape.type === "square") {
|
|
// TODO: this should be an error
|
|
return shape.width * shape.height;
|
|
} else if (shape.type === "circle") {
|
|
return Math.PI * Math.pow(shape.radius, 2);
|
|
}
|
|
throw "unreachable"; // TODO: this shouldn't be needed
|
|
}
|
|
|
|
`;
|
|
|
|
exports[`enum.js 1`] = `
|
|
// @flow
|
|
|
|
type Binary = 0 | 1;
|
|
|
|
function stringifyBinary(binary: Binary): string {
|
|
if (binary === 0) {
|
|
return 'zero';
|
|
} else if (binary === 2) { // oops
|
|
return 'one';
|
|
}
|
|
throw "unreachable"; // TODO: this shouldn't be needed
|
|
}
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// @flow
|
|
|
|
type Binary = 0 | 1;
|
|
|
|
function stringifyBinary(binary: Binary): string {
|
|
if (binary === 0) {
|
|
return "zero";
|
|
} else if (binary === 2) {
|
|
// oops
|
|
return "one";
|
|
}
|
|
throw "unreachable"; // TODO: this shouldn't be needed
|
|
}
|
|
|
|
`;
|