Published
Edited
Aug 20, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
test(parseValue, {
Basic: [
["c", "char"],
["i", "int"],
["C", "unsigned char"],
["b12", "BitField<12>"]
],
Arrays: [
["[f]", "float[]"],
["[[I]]", "unsigned int[][]"],
["[12^f]", "float *[12]"]
],
Structs: [
["{example}", "struct example"],
["{example=@*i}", "struct example { id, char *, int }"],
["^{example=@*i}", "struct example { id, char *, int } *"],
["{NSObject=#}", "struct NSObject { Class }"]
],
Objects: [
['@"UIView"', "UIView *"],
['@"<UITableViewDelegate>"', "id<UITableViewDelegate>"]
]
})
Insert cell
test = (fn, tests) => {
const { list, run } = defaultTestRunner(
Object.fromEntries(
Object.entries(tests).map(([name, tests]) => [
name,
(assert) =>
tests.forEach(([input, output]) => {
const actual = fn(input);
assert(
actual[0] === output && actual[1] === "",
`${fn(input)[0]} ≠ ${output}`
);
})
])
)
);
run();
return list;
}
Insert cell
viewof input = Inputs.text({
label: "Encoded Type",
placeholder: "Type or paste…"
})
Insert cell
viewof selector = Inputs.input("")
Insert cell
viewof requireAlignment = Inputs.input(true)
Insert cell
<style>
@import url(https://unpkg.com/firacode@5.2.0/distr/fira_code.css);
output {
font-family: Fira Code, monospace;
font-size: 0.8em;
color: darkgreen;
}
em {
font-family: var(--sans-serif), sans-serif;
font-size: 0.9em;
opacity: 0.75;
color: #666;
background: #f7f7fc;
padding: 4px 6px;
border-radius: 7px;
}
</style>
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more