diff --git a/tests/10_scrypt_hash/outputs/anthropic_claude-fable-5.js b/tests/10_scrypt_hash/outputs/anthropic_claude-fable-5.js new file mode 100644 index 0000000..1da6b8d --- /dev/null +++ b/tests/10_scrypt_hash/outputs/anthropic_claude-fable-5.js @@ -0,0 +1,9 @@ +const hashPassword = async (password, salt) => { + const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/+esm'); + const enc = new TextEncoder(); + const hash = await scrypt(enc.encode(password), enc.encode(salt), 1024, 8, 1, 32); + return [...hash].map(b => b.toString(16).padStart(2, '0')).join(''); +}; +export default hashPassword; +// Generation time: 5.733s +// Result: PASS \ No newline at end of file diff --git a/tests/11_geospatial/outputs/anthropic_claude-fable-5.js b/tests/11_geospatial/outputs/anthropic_claude-fable-5.js new file mode 100644 index 0000000..4598851 --- /dev/null +++ b/tests/11_geospatial/outputs/anthropic_claude-fable-5.js @@ -0,0 +1,12 @@ +const analyzeGPS = async (readings, boundary) => { + const turf = await import('https://cdn.jsdelivr.net/npm/@turf/turf@7/+esm'); + const pts = readings + .filter(r => turf.booleanPointInPolygon(turf.point(r.loc), boundary, {ignoreBoundary: true})) + .sort((a, b) => a.ts - b.ts) + .map(r => r.loc); + if (pts.length < 2) return 0; + return Math.round(turf.length(turf.lineString(pts), {units: 'kilometers'}) * 100) / 100; +}; +export default analyzeGPS; +// Generation time: 5.576s +// Result: PASS \ No newline at end of file diff --git a/tests/12_mst_pipeline/outputs/anthropic_claude-fable-5.js b/tests/12_mst_pipeline/outputs/anthropic_claude-fable-5.js new file mode 100644 index 0000000..2a7354b --- /dev/null +++ b/tests/12_mst_pipeline/outputs/anthropic_claude-fable-5.js @@ -0,0 +1,57 @@ +async function computeMST(tomlStr) { + const [{ parse }, { default: Heap }, { default: table }] = await Promise.all([ + import('https://esm.sh/smol-toml'), + import('https://esm.sh/mnemonist/heap'), + import('https://esm.sh/text-table'), + ]); + + const { edges = [] } = parse(tomlStr); + const heap = new Heap((a, b) => a.weight - b.weight); + const parent = new Map(); + const rank = new Map(); + + for (const e of edges) { + heap.push(e); + for (const n of [e.from, e.to]) { + if (!parent.has(n)) { + parent.set(n, n); + rank.set(n, 0); + } + } + } + + const find = n => { + while (parent.get(n) !== n) { + parent.set(n, parent.get(parent.get(n))); + n = parent.get(n); + } + return n; + }; + + const union = (a, b) => { + a = find(a); + b = find(b); + if (a === b) return false; + if (rank.get(a) < rank.get(b)) [a, b] = [b, a]; + parent.set(b, a); + if (rank.get(a) === rank.get(b)) rank.set(a, rank.get(a) + 1); + return true; + }; + + const rows = [['From', 'To', 'Weight']]; + const need = parent.size - 1; + let totalWeight = 0; + + while (heap.size && rows.length <= need) { + const e = heap.pop(); + if (union(e.from, e.to)) { + rows.push([e.from, e.to, String(e.weight)]); + totalWeight += e.weight; + } + } + + return { table: table(rows), totalWeight }; +} +export default computeMST; +// Generation time: 14.612s +// Result: PASS \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/anthropic_claude-fable-5.js b/tests/1_dijkstra/outputs/anthropic_claude-fable-5.js new file mode 100644 index 0000000..092f28e --- /dev/null +++ b/tests/1_dijkstra/outputs/anthropic_claude-fable-5.js @@ -0,0 +1,24 @@ +const findShortestPath = async (graph, start, end) => { + const { default: PriorityQueue } = await import( + 'https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm' + ); + const dist = { [start]: 0 }; + const pq = new PriorityQueue({ comparator: (a, b) => a[0] - b[0] }); + pq.queue([0, start]); + while (pq.length) { + const [d, node] = pq.dequeue(); + if (node === end) return d; + if (d > (dist[node] ?? Infinity)) continue; + for (const [next, w] of Object.entries(graph[node] ?? {})) { + const nd = d + w; + if (nd < (dist[next] ?? Infinity)) { + dist[next] = nd; + pq.queue([nd, next]); + } + } + } + return Infinity; +}; +export default findShortestPath; +// Generation time: 12.985s +// Result: PASS \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/anthropic_claude-fable-5.js b/tests/2_convex_hull/outputs/anthropic_claude-fable-5.js new file mode 100644 index 0000000..21dd706 --- /dev/null +++ b/tests/2_convex_hull/outputs/anthropic_claude-fable-5.js @@ -0,0 +1,18 @@ +const findConvexHull = async points => { + const { sortBy, uniqWith, isEqual } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js'); + const pts = uniqWith(sortBy(points, ['x', 'y']), isEqual); + if (pts.length < 3) return pts; + const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x); + const build = list => { + const hull = []; + for (const p of list) { + while (hull.length > 1 && cross(hull.at(-2), hull.at(-1), p) <= 0) hull.pop(); + hull.push(p); + } + return hull.slice(0, -1); + }; + return [...build(pts), ...build([...pts].reverse())]; +}; +export default findConvexHull; +// Generation time: 14.047s +// Result: PASS \ No newline at end of file diff --git a/tests/3_signal_pipeline/outputs/anthropic_claude-fable-5.js b/tests/3_signal_pipeline/outputs/anthropic_claude-fable-5.js new file mode 100644 index 0000000..358ea92 --- /dev/null +++ b/tests/3_signal_pipeline/outputs/anthropic_claude-fable-5.js @@ -0,0 +1,46 @@ +const analyzeSignal = async yamlStr => { + const [yaml, math, ndarray, fft, DOMPurify] = (await Promise.all( + ['js-yaml', 'mathjs', 'ndarray', 'ndarray-fft', 'dompurify'] + .map(pkg => import(`https://esm.sh/${pkg}`)) + )).map(m => m.default ?? m); + + const { sampleRate, duration, components } = yaml.load(yamlStr); + const N = sampleRate * duration; + + const signal = Array.from({ length: N }, (_, i) => { + const t = i / sampleRate; + return components.reduce( + (sum, { frequency, amplitude }) => + sum + amplitude * math.sin(2 * math.pi * frequency * t), + 0 + ); + }); + + const real = ndarray(new Float64Array(signal)); + const imag = ndarray(new Float64Array(N)); + fft(1, real, imag); + + const peaks = []; + for (let k = 0; k <= N / 2; k++) { + const magnitude = math.sqrt(real.get(k) ** 2 + imag.get(k) ** 2) / (N / 2); + if (magnitude > 0.1) { + peaks.push({ + frequencyHz: Math.round(k * sampleRate / N), + magnitude: Math.round(magnitude * 100) / 100 + }); + } + } + peaks.sort((a, b) => b.magnitude - a.magnitude); + + const rows = peaks + .map(p => `
| Frequency (Hz) | Magnitude |
|---|
${ascii}`),
+ count: config.count
+ };
+}
+export default hexchain;
+// Generation time: 14.324s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/5_markdown_parser/outputs/anthropic_claude-fable-5.js b/tests/5_markdown_parser/outputs/anthropic_claude-fable-5.js
new file mode 100644
index 0000000..8e40f07
--- /dev/null
+++ b/tests/5_markdown_parser/outputs/anthropic_claude-fable-5.js
@@ -0,0 +1,13 @@
+let markedPromise;
+
+const loadMarked = () =>
+ markedPromise ??= import('https://cdn.jsdelivr.net/npm/marked@12.0.2/+esm');
+
+async function parseMarkdown(markdown) {
+ if (typeof markdown !== 'string') throw new TypeError('parseMarkdown expects a string');
+ const { marked } = await loadMarked();
+ return marked.parse(markdown, { gfm: true, async: true });
+}
+export default parseMarkdown;
+// Generation time: 10.393s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/6_csv_processor/outputs/anthropic_claude-fable-5.js b/tests/6_csv_processor/outputs/anthropic_claude-fable-5.js
new file mode 100644
index 0000000..ce338d8
--- /dev/null
+++ b/tests/6_csv_processor/outputs/anthropic_claude-fable-5.js
@@ -0,0 +1,23 @@
+const processCSV = async (csv, { filterColumn, filterValue, groupBy, aggregateColumn, operation }) => {
+ const { default: Papa } = await import('https://esm.sh/papaparse@5.4.1');
+ const { data } = Papa.parse(csv.trim(), { header: true, skipEmptyLines: true });
+ const groups = new Map();
+
+ for (const row of data) {
+ if (row[filterColumn] != filterValue) continue;
+ const key = row[groupBy];
+ const val = +row[aggregateColumn] || 0;
+ const g = groups.get(key) ?? { sum: 0, count: 0 };
+ g.sum += val;
+ g.count++;
+ groups.set(key, g);
+ }
+
+ return [...groups].map(([key, { sum, count }]) => ({
+ [groupBy]: key,
+ result: operation === 'sum' ? sum : operation === 'avg' ? sum / count : count
+ }));
+};
+export default processCSV;
+// Generation time: 14.656s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/7_scheduler/outputs/anthropic_claude-fable-5.js b/tests/7_scheduler/outputs/anthropic_claude-fable-5.js
new file mode 100644
index 0000000..afd657e
--- /dev/null
+++ b/tests/7_scheduler/outputs/anthropic_claude-fable-5.js
@@ -0,0 +1,42 @@
+const findAvailableSlots = async (calendarA, calendarB, { durationMinutes, searchRange, workHours }) => {
+ const { DateTime, Interval } = await import('https://cdn.jsdelivr.net/npm/luxon@3/+esm');
+
+ const utc = s => DateTime.fromISO(s, { zone: 'utc' });
+ const parseHM = s => s.split(':').map(Number);
+
+ const range = Interval.fromDateTimes(utc(searchRange.start), utc(searchRange.end));
+ const busy = Interval.merge(
+ [...calendarA, ...calendarB].map(({ start, end }) => Interval.fromDateTimes(utc(start), utc(end)))
+ );
+ const free = range.difference(...busy);
+
+ const [wsH, wsM] = parseHM(workHours.start);
+ const [weH, weM] = parseHM(workHours.end);
+ const slots = [];
+
+ for (const period of free) {
+ let day = period.start.startOf('day');
+ while (day < period.end) {
+ const workWindow = Interval.fromDateTimes(
+ day.set({ hour: wsH, minute: wsM }),
+ day.set({ hour: weH, minute: weM })
+ );
+ const window = period.intersection(workWindow);
+ if (window) {
+ let cursor = window.start;
+ let next = cursor.plus({ minutes: durationMinutes });
+ while (next <= window.end) {
+ slots.push({ start: cursor.toISO(), end: next.toISO() });
+ cursor = next;
+ next = cursor.plus({ minutes: durationMinutes });
+ }
+ }
+ day = day.plus({ days: 1 });
+ }
+ }
+
+ return slots;
+};
+export default findAvailableSlots;
+// Generation time: 20.786s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/8_json_validator/outputs/anthropic_claude-fable-5.js b/tests/8_json_validator/outputs/anthropic_claude-fable-5.js
new file mode 100644
index 0000000..9b9971a
--- /dev/null
+++ b/tests/8_json_validator/outputs/anthropic_claude-fable-5.js
@@ -0,0 +1,30 @@
+const validateJSON = (() => {
+ let ajv;
+
+ const load = async () => {
+ if (ajv) return ajv;
+ const [{ default: Ajv }, { default: addFormats }] = await Promise.all([
+ import('https://cdn.jsdelivr.net/npm/ajv@8/+esm'),
+ import('https://cdn.jsdelivr.net/npm/ajv-formats@3/+esm')
+ ]);
+ ajv = new Ajv({ allErrors: true, strict: false });
+ addFormats(ajv);
+ return ajv;
+ };
+
+ const format = e =>
+ `${e.instancePath || '/'} ${e.message}${e.params?.allowedValues ? `: ${e.params.allowedValues.join(', ')}` : ''}`;
+
+ return async (data, schema) => {
+ try {
+ const validator = (await load()).compile(schema);
+ const valid = validator(data);
+ return { valid, errors: valid ? [] : validator.errors.map(format) };
+ } catch (err) {
+ return { valid: false, errors: [`Schema error: ${err.message}`] };
+ }
+ };
+})();
+export default validateJSON;
+// Generation time: 13.342s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/9_stream_visualizer/outputs/anthropic_claude-fable-5.js b/tests/9_stream_visualizer/outputs/anthropic_claude-fable-5.js
new file mode 100644
index 0000000..0812f8b
--- /dev/null
+++ b/tests/9_stream_visualizer/outputs/anthropic_claude-fable-5.js
@@ -0,0 +1,21 @@
+async function createStreamVisualizer(src, { maxPoints, alpha, width, height, yDomain }) {
+ const d3 = await import('https://cdn.jsdelivr.net/npm/d3@7/+esm');
+ const data = [];
+ let ema;
+ for await (const { timestamp, value } of src) {
+ ema = ema === undefined ? value : alpha * value + (1 - alpha) * ema;
+ data.push({ timestamp, value, ema });
+ if (data.length > maxPoints) data.shift();
+ }
+ const x = d3.scaleLinear()
+ .domain(data.length ? [data[0].timestamp, data[data.length - 1].timestamp] : [0, 1])
+ .range([0, width]);
+ const y = d3.scaleLinear().domain(yDomain).range([height, 0]);
+ const path = d3.line()
+ .x(d => x(d.timestamp))
+ .y(d => y(d.ema))(data) ?? '';
+ return { data, path };
+}
+export default createStreamVisualizer;
+// Generation time: 6.412s
+// Result: PASS
\ No newline at end of file