diff --git a/tests/10_scrypt_hash/outputs/z-ai_glm-5.2.js b/tests/10_scrypt_hash/outputs/z-ai_glm-5.2.js new file mode 100644 index 0000000..b171e16 --- /dev/null +++ b/tests/10_scrypt_hash/outputs/z-ai_glm-5.2.js @@ -0,0 +1,9 @@ +const hashPassword = async (password, salt) => { + const scrypt = (await import('https://esm.sh/scrypt-js')).default; + 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: 21.621s +// Result: FAIL \ No newline at end of file diff --git a/tests/11_geospatial/outputs/z-ai_glm-5.2.js b/tests/11_geospatial/outputs/z-ai_glm-5.2.js new file mode 100644 index 0000000..8dbb24f --- /dev/null +++ b/tests/11_geospatial/outputs/z-ai_glm-5.2.js @@ -0,0 +1,18 @@ +async function analyzeGPS(readings, boundary) { + const turf = await import('https://esm.sh/@turf/turf'); + const valid = readings + .filter(r => turf.booleanPointInPolygon(turf.point(r.loc), boundary, { ignoreBoundary: true })) + .sort((a, b) => a.ts - b.ts); + + if (valid.length < 2) return 0; + + const len = turf.length( + turf.lineString(valid.map(r => r.loc)), + { units: 'kilometers' } + ); + + return Math.round(len * 100) / 100; +} +export default analyzeGPS; +// Generation time: 28.608s +// Result: PASS \ No newline at end of file diff --git a/tests/12_mst_pipeline/outputs/z-ai_glm-5.2.js b/tests/12_mst_pipeline/outputs/z-ai_glm-5.2.js new file mode 100644 index 0000000..e516aa2 --- /dev/null +++ b/tests/12_mst_pipeline/outputs/z-ai_glm-5.2.js @@ -0,0 +1,53 @@ +const computeMST = async (tomlStr) => { + const { parse } = await import('https://esm.sh/smol-toml'); + const { Heap } = await import('https://esm.sh/mnemonist'); + const textTable = (await import('https://esm.sh/text-table')).default; + + const config = parse(tomlStr); + const edges = config.edges || []; + + class UnionFind { + constructor() { this.p = {}; this.r = {}; } + add(n) { if (!(n in this.p)) { this.p[n] = n; this.r[n] = 0; } } + find(n) { return this.p[n] === n ? n : (this.p[n] = this.find(this.p[n])); } + union(a, b) { + const ra = this.find(a), rb = this.find(b); + if (ra === rb) return false; + if (this.r[ra] < this.r[rb]) this.p[ra] = rb; + else if (this.r[ra] > this.r[rb]) this.p[rb] = ra; + else { this.p[rb] = ra; this.r[ra]++; } + return true; + } + } + + const uf = new UnionFind(); + const heap = new Heap((a, b) => a.weight - b.weight); + const nodes = new Set(); + + for (const e of edges) { + nodes.add(e.from); + nodes.add(e.to); + uf.add(e.from); + uf.add(e.to); + heap.push(e); + } + + const mst = []; + let totalWeight = 0; + + while (heap.size && mst.length < nodes.size - 1) { + const e = heap.pop(); + if (uf.union(e.from, e.to)) { + mst.push([e.from, e.to, String(e.weight)]); + totalWeight += e.weight; + } + } + + return { + table: textTable([['From', 'To', 'Weight'], ...mst]), + totalWeight + }; +}; +export default computeMST; +// Generation time: 22.055s +// Result: PASS \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/z-ai_glm-5.2.js b/tests/1_dijkstra/outputs/z-ai_glm-5.2.js new file mode 100644 index 0000000..6d743a4 --- /dev/null +++ b/tests/1_dijkstra/outputs/z-ai_glm-5.2.js @@ -0,0 +1,24 @@ +async function findShortestPath(g, s, e) { + const { default: PQ } = await import('https://esm.sh/js-priority-queue'); + const d = { [s]: 0 }; + const q = new PQ({ comparator: (a, b) => a.p - b.p }); + q.queue({ n: s, p: 0 }); + + while (q.length) { + const { n, p } = q.dequeue(); + if (n === e) return p; + if (p > (d[n] ?? Infinity)) continue; + + for (const m in g[n]) { + const w = p + g[n][m]; + if (w < (d[m] ?? Infinity)) { + d[m] = w; + q.queue({ n: m, p: w }); + } + } + } + return Infinity; +} +export default findShortestPath; +// Generation time: 45.601s +// Result: PASS \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/z-ai_glm-5.2.js b/tests/2_convex_hull/outputs/z-ai_glm-5.2.js new file mode 100644 index 0000000..3f1eed7 --- /dev/null +++ b/tests/2_convex_hull/outputs/z-ai_glm-5.2.js @@ -0,0 +1,24 @@ +async function findConvexHull(points) { + const _ = await import('https://esm.sh/lodash'); + if (points.length < 3) return _.uniqWith(points, _.isEqual); + + const pts = _.sortBy(points, ['x', 'y']); + const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x); + + const build = (arr) => { + const h = []; + for (const p of arr) { + while (h.length >= 2 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop(); + h.push(p); + } + return h; + }; + + const lower = build(pts); + const upper = build([...pts].reverse()); + + return _.uniqWith([...lower, ...upper], _.isEqual); +} +export default findConvexHull; +// Generation time: 54.184s +// Result: PASS \ No newline at end of file diff --git a/tests/3_signal_pipeline/outputs/z-ai_glm-5.2.js b/tests/3_signal_pipeline/outputs/z-ai_glm-5.2.js new file mode 100644 index 0000000..a51ca0e --- /dev/null +++ b/tests/3_signal_pipeline/outputs/z-ai_glm-5.2.js @@ -0,0 +1,43 @@ +async function analyzeSignal(yamlStr) { + const [{ default: yaml }, { default: math }, { default: ndarray }, { default: fft }, { default: DOMPurify }] = await Promise.all([ + import('https://esm.sh/js-yaml'), + import('https://esm.sh/mathjs'), + import('https://esm.sh/ndarray'), + import('https://esm.sh/ndarray-fft'), + import('https://esm.sh/dompurify') + ]); + + const { sampleRate, duration, components } = yaml.load(yamlStr); + const N = sampleRate * duration; + const signal = new Float64Array(N); + + for (let i = 0; i < N; i++) { + const t = i / sampleRate; + signal[i] = components.reduce((s, c) => s + c.amplitude * math.sin(2 * math.pi * c.frequency * t), 0); + } + + const real = ndarray(signal, [N]); + const imag = ndarray(new Float64Array(N), [N]); + fft(1, real, imag); + + const peaks = []; + for (let k = 0; k <= N / 2; k++) { + const mag = math.sqrt(real.get(k) ** 2 + imag.get(k) ** 2) / (N / 2); + if (mag > 0.1) { + peaks.push({ + frequencyHz: Math.round(k * sampleRate / N), + magnitude: parseFloat(mag.toFixed(2)) + }); + } + } + + peaks.sort((a, b) => b.magnitude - a.magnitude); + + const rows = peaks.map(p => `
| Frequency (Hz) | Magnitude |
|---|
${tb}`);
+ return { valid:true, label:c.label, stats:{ mean:m, stddev:d, median:e }, table:h, count:c.count };
+};
+export default hexchain;
+// Generation time: 76.627s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/5_markdown_parser/outputs/z-ai_glm-5.2.js b/tests/5_markdown_parser/outputs/z-ai_glm-5.2.js
new file mode 100644
index 0000000..0f8cc80
--- /dev/null
+++ b/tests/5_markdown_parser/outputs/z-ai_glm-5.2.js
@@ -0,0 +1,7 @@
+const parseMarkdown = async (md) => {
+ const { marked } = await import('https://esm.sh/marked');
+ return marked.parse(md);
+};
+export default parseMarkdown;
+// Generation time: 17.682s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/6_csv_processor/outputs/z-ai_glm-5.2.js b/tests/6_csv_processor/outputs/z-ai_glm-5.2.js
new file mode 100644
index 0000000..f087cef
--- /dev/null
+++ b/tests/6_csv_processor/outputs/z-ai_glm-5.2.js
@@ -0,0 +1,21 @@
+const processCSV = async (csv, c) => {
+ const Papa = (await import('https://esm.run/papaparse@5')).default;
+ const { data } = Papa.parse(csv, { header: true });
+
+ return Object.values(
+ data.reduce((acc, r) => {
+ if (r[c.filterColumn] != c.filterValue) return acc;
+ const k = r[c.groupBy];
+ acc[k] ??= { [c.groupBy]: k, sum: 0, count: 0 };
+ acc[k].sum += Number(r[c.aggregateColumn]) || 0;
+ acc[k].count++;
+ return acc;
+ }, {})
+ ).map(g => ({
+ [c.groupBy]: g[c.groupBy],
+ result: c.operation === 'count' ? g.count : c.operation === 'sum' ? g.sum : g.sum / g.count
+ }));
+};
+export default processCSV;
+// Generation time: 31.429s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/7_scheduler/outputs/z-ai_glm-5.2.js b/tests/7_scheduler/outputs/z-ai_glm-5.2.js
new file mode 100644
index 0000000..11ca733
--- /dev/null
+++ b/tests/7_scheduler/outputs/z-ai_glm-5.2.js
@@ -0,0 +1,62 @@
+async function findAvailableSlots(cal1, cal2, c) {
+ const { DateTime } = await import('https://esm.sh/luxon@3');
+ const s = DateTime.fromISO(c.searchRange.start, { zone: 'utc' });
+ const e = DateTime.fromISO(c.searchRange.end, { zone: 'utc' });
+
+ let work = [];
+ let cur = s;
+ const [wSH, wSM] = c.workHours.start.split(':').map(Number);
+ const [wEH, wEM] = c.workHours.end.split(':').map(Number);
+
+ while (cur < e) {
+ const ws = cur.set({ hour: wSH, minute: wSM, second: 0, millisecond: 0 });
+ const we = cur.set({ hour: wEH, minute: wEM, second: 0, millisecond: 0 });
+ if (we > ws) work.push({ start: ws, end: we });
+ cur = cur.plus({ days: 1 }).set({ hour: 0, minute: 0, second: 0, millisecond: 0 });
+ }
+
+ const busy = [...cal1, ...cal2]
+ .map(b => ({
+ start: DateTime.fromISO(b.start, { zone: 'utc' }),
+ end: DateTime.fromISO(b.end, { zone: 'utc' })
+ }))
+ .filter(b => b.start < b.end)
+ .sort((a, b) => a.start - b.start);
+
+ let merged = [];
+ for (const b of busy) {
+ const last = merged[merged.length - 1];
+ if (merged.length && b.start <= last.end) last.end = DateTime.max(last.end, b.end);
+ else merged.push({ ...b });
+ }
+
+ let free = [];
+ for (const w of work) {
+ let cs = w.start;
+ for (const b of merged) {
+ if (b.end <= cs) continue;
+ if (b.start >= w.end) break;
+ if (b.start > cs) free.push({ start: cs, end: b.start });
+ cs = DateTime.max(cs, b.end);
+ if (cs >= w.end) break;
+ }
+ if (cs < w.end) free.push({ start: cs, end: w.end });
+ }
+
+ const d = c.durationMinutes;
+ const slots = [];
+ for (const f of free) {
+ let ss = f.start;
+ while (ss.plus({ minutes: d }) <= f.end) {
+ slots.push({
+ start: ss.toISO({ suppressMilliseconds: true }),
+ end: ss.plus({ minutes: d }).toISO({ suppressMilliseconds: true })
+ });
+ ss = ss.plus({ minutes: d });
+ }
+ }
+ return slots;
+}
+export default findAvailableSlots;
+// Generation time: 59.287s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/8_json_validator/outputs/z-ai_glm-5.2.js b/tests/8_json_validator/outputs/z-ai_glm-5.2.js
new file mode 100644
index 0000000..becce7b
--- /dev/null
+++ b/tests/8_json_validator/outputs/z-ai_glm-5.2.js
@@ -0,0 +1,9 @@
+async function validateJSON(data, schema) {
+ const { default: Ajv } = await import('https://esm.sh/ajv@8');
+ const ajv = new Ajv({ allErrors: true });
+ const valid = ajv.validate(schema, data);
+ return { valid, errors: valid ? [] : ajv.errors.map(e => e.message) };
+}
+export default validateJSON;
+// Generation time: 31.005s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/9_stream_visualizer/outputs/z-ai_glm-5.2.js b/tests/9_stream_visualizer/outputs/z-ai_glm-5.2.js
new file mode 100644
index 0000000..47a7980
--- /dev/null
+++ b/tests/9_stream_visualizer/outputs/z-ai_glm-5.2.js
@@ -0,0 +1,26 @@
+async function createStreamVisualizer(asyncIterable, { maxPoints: max, alpha, width: w, height: h, yDomain }) {
+ const d3 = await import('d3');
+ const data = [];
+ let prev;
+
+ for await (const { timestamp: t, value: v } of asyncIterable) {
+ const ema = prev === undefined ? v : alpha * v + (1 - alpha) * prev;
+ prev = ema;
+ data.push({ timestamp: t, value: v, ema });
+ if (data.length > max) data.shift();
+ }
+
+ if (!data.length) return { data, path: null };
+
+ const x = d3.scaleLinear([data[0].timestamp, data[data.length - 1].timestamp], [0, w]);
+ const y = d3.scaleLinear(yDomain, [h, 0]);
+
+ const path = d3.line()
+ .x(d => x(d.timestamp))
+ .y(d => y(d.ema))(data);
+
+ return { data, path };
+}
+export default createStreamVisualizer;
+// Generation time: 17.130s
+// Result: FAIL
\ No newline at end of file