functionalscript
Version:
FunctionalScript is a purely functional subset of JavaScript
80 lines (79 loc) • 2.72 kB
JavaScript
import { htmlToString } from "./module.f.js";
export default {
empty: () => {
const r = htmlToString(['html']);
if (r !== '<html></html>') {
throw `empty: ${r}`;
}
},
empty2: () => {
const r = htmlToString(['html']);
if (r !== '<html></html>') {
throw r;
}
},
void: () => {
const r = htmlToString(['area']);
if (r !== '<area>') {
throw r;
}
},
some: () => {
const x = ['div', {}, '<div>&</div>', ['a', { href: 'hello"' }]];
const s = htmlToString(x);
if (s !== '<div><div>&amp;</div><a href="hello""></a></div>') {
throw s;
}
},
some2: () => {
const x = ['div', '<div>&</div>', ['a', { href: 'hello"' }]];
const s = htmlToString(x);
if (s !== '<div><div>&amp;</div><a href="hello""></a></div>') {
throw s;
}
},
someVoid: () => {
const x = ['div', ['br', { id: '5' }], '<div>&</div>', ['a', { href: 'hello"' }]];
const s = htmlToString(x);
if (s !== '<div><br id="5"><div>&amp;</div><a href="hello""></a></div>') {
throw s;
}
},
raw: {
script: () => {
const x = ['script', { id: 'a<' }, 'const a = ', 'a<b>c'];
const s = htmlToString(x);
if (s !== '<script id="a<">const a = a<b>c</script>') {
throw s;
}
},
scriptEsc: () => {
const x = ['script', { id: 'a<' }, '<', '/script>'];
const s = htmlToString(x);
if (s !== '<script id="a<"><\\/script></script>') {
throw s;
}
},
style: () => {
const x = ['style', { id: 'a<' }, 'const a = ', 'a<b>c'];
const s = htmlToString(x);
if (s !== '<style id="a<">const a = a<b>c</style>') {
throw s;
}
},
styleEsc: () => {
const x = ['style', { id: 'a<' }, '</', 'stYle>'];
const s = htmlToString(x);
if (s !== '<style id="a<"><\\/stYle></style>') {
throw s;
}
},
noRaw: () => {
const x = ['div', { id: 'a<' }, 'const a = ', 'a<b>c'];
const s = htmlToString(x);
if (s !== '<div id="a<">const a = a<b>c</div>') {
throw s;
}
},
}
};