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

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more