diff --git a/tests/10_scrypt_hash/outputs/google_gemini-3.1-flash-lite.js b/tests/10_scrypt_hash/outputs/google_gemini-3.1-flash-lite.js new file mode 100644 index 0000000..4ec8e2d --- /dev/null +++ b/tests/10_scrypt_hash/outputs/google_gemini-3.1-flash-lite.js @@ -0,0 +1,15 @@ +async function hashPassword(password, salt) { + const { scrypt } = await import('https://esm.run/scrypt-js'); + const enc = new TextEncoder(); + + const key = await scrypt( + enc.encode(password), + enc.encode(salt), + 1024, 8, 1, 32 + ); + + return [...key].map(b => b.toString(16).padStart(2, '0')).join(''); +} +export default hashPassword; +// Generation time: 1.123s +// Result: PASS \ No newline at end of file diff --git a/tests/11_geospatial/outputs/google_gemini-3.1-flash-lite.js b/tests/11_geospatial/outputs/google_gemini-3.1-flash-lite.js new file mode 100644 index 0000000..fe37a4f --- /dev/null +++ b/tests/11_geospatial/outputs/google_gemini-3.1-flash-lite.js @@ -0,0 +1,16 @@ +async function analyzeGPS(readings, boundary) { + const { booleanPointInPolygon, lineString, length } = await import('https://cdn.skypack.dev/@turf/turf'); + + const valid = readings + .filter(r => booleanPointInPolygon(r.loc, boundary)) + .sort((a, b) => a.ts - b.ts); + + if (valid.length < 2) return 0; + + const dist = length(lineString(valid.map(r => r.loc)), { units: 'kilometers' }); + + return +dist.toFixed(2); +} +export default analyzeGPS; +// Generation time: 1.005s +// Result: PASS \ No newline at end of file diff --git a/tests/12_mst_pipeline/outputs/google_gemini-3.1-flash-lite.js b/tests/12_mst_pipeline/outputs/google_gemini-3.1-flash-lite.js new file mode 100644 index 0000000..bc11aca --- /dev/null +++ b/tests/12_mst_pipeline/outputs/google_gemini-3.1-flash-lite.js @@ -0,0 +1,49 @@ +async function computeMST(tomlStr) { + const [{ parse }, { Heap }, { default: table }] = await Promise.all([ + import("https://cdn.skypack.dev/smol-toml"), + import("https://cdn.skypack.dev/mnemonist/heap"), + import("https://cdn.skypack.dev/text-table") + ]); + + const { edges } = parse(tomlStr), nodes = new Set(); + const heap = new Heap((a, b) => a.weight - b.weight); + + edges.forEach(e => { + heap.push(e); + nodes.add(e.from); + nodes.add(e.to); + }); + + const parent = new Map(), rank = new Map(); + nodes.forEach(n => parent.set(n, n) || rank.set(n, 0)); + + const find = i => { + while (parent.get(i) !== i) { + parent.set(i, parent.get(parent.get(i))); + i = parent.get(i); + } + return i; + }; + + const mst = [['From', 'To', 'Weight']], nCount = nodes.size; + let totalWeight = 0; + + while (heap.size() > 0 && mst.length < nCount) { + const { from, to, weight } = heap.pop(); + let rootU = find(from), rootV = find(to); + + if (rootU !== rootV) { + if (rank.get(rootU) < rank.get(rootV)) [rootU, rootV] = [rootV, rootU]; + parent.set(rootV, rootU); + if (rank.get(rootU) === rank.get(rootV)) rank.set(rootU, rank.get(rootU) + 1); + + mst.push([from, to, String(weight)]); + totalWeight += weight; + } + } + + return { table: table(mst), totalWeight }; +} +export default computeMST; +// Generation time: 2.142s +// Result: FAIL \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/google_gemini-3.1-flash-lite.js b/tests/1_dijkstra/outputs/google_gemini-3.1-flash-lite.js new file mode 100644 index 0000000..25f7337 --- /dev/null +++ b/tests/1_dijkstra/outputs/google_gemini-3.1-flash-lite.js @@ -0,0 +1,29 @@ +async function findShortestPath(graph, start, end) { + const { PriorityQueue } = await import('https://cdn.skypack.dev/js-priority-queue'); + const dist = { [start]: 0 }; + const pq = new PriorityQueue({ + comparator: (a, b) => a.w - b.w + }); + + pq.queue({ n: start, w: 0 }); + + while (pq.length) { + const { n, w } = pq.dequeue(); + + if (n === end) return w; + if (w > (dist[n] ?? Infinity)) continue; + + for (const [neighbor, weight] of Object.entries(graph[n] || {})) { + const newDist = w + weight; + if (newDist < (dist[neighbor] ?? Infinity)) { + dist[neighbor] = newDist; + pq.queue({ n: neighbor, w: newDist }); + } + } + } + + return Infinity; +} +export default findShortestPath; +// Generation time: 1.539s +// Result: FAIL \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/google_gemini-3.1-flash-lite.js b/tests/2_convex_hull/outputs/google_gemini-3.1-flash-lite.js new file mode 100644 index 0000000..51ec4d7 --- /dev/null +++ b/tests/2_convex_hull/outputs/google_gemini-3.1-flash-lite.js @@ -0,0 +1,30 @@ +async function findConvexHull(pts) { + const { sortBy, uniqWith, isEqual } = await import('https://cdn.skypack.dev/lodash'); + + const sorted = sortBy(uniqWith(pts, isEqual), ['x', 'y']); + if (sorted.length <= 2) return sorted; + + const crossProduct = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x); + + const build = (arr) => { + const hull = []; + for (const p of arr) { + while (hull.length >= 2 && crossProduct(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) { + hull.pop(); + } + hull.push(p); + } + return hull; + }; + + const lower = build(sorted); + const upper = build([...sorted].reverse()); + + lower.pop(); + upper.pop(); + + return lower.concat(upper); +} +export default findConvexHull; +// Generation time: 1.515s +// Result: PASS \ No newline at end of file diff --git a/tests/3_signal_pipeline/outputs/google_gemini-3.1-flash-lite.js b/tests/3_signal_pipeline/outputs/google_gemini-3.1-flash-lite.js new file mode 100644 index 0000000..6083bdd --- /dev/null +++ b/tests/3_signal_pipeline/outputs/google_gemini-3.1-flash-lite.js @@ -0,0 +1,40 @@ +async function analyzeSignal(yamlStr) { + const [yaml, math, { default: ndarray }, fft, { sanitize }] = 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 cfg = yaml.load(yamlStr); + const N = cfg.sampleRate * cfg.duration; + const real = ndarray(new Float64Array(N)); + const imag = ndarray(new Float64Array(N)); + + for (let i = 0; i < N; i++) { + const t = i / cfg.sampleRate; + const v = cfg.components.reduce((acc, c) => + acc + c.amplitude * math.sin(2 * math.pi * c.frequency * t), 0); + real.set(i, v); + } + + 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 * cfg.sampleRate / N), magnitude: +mag.toFixed(2) }); + } + + peaks.sort((a, b) => b.magnitude - a.magnitude); + + let html = ''; + peaks.forEach(p => html += ``); + html += '
Frequency (Hz)Magnitude
${p.frequencyHz}${p.magnitude}
'; + + return { peaks, html: sanitize(html), signalLength: N }; +} +export default analyzeSignal; +// Generation time: 1.769s +// Result: FAIL \ No newline at end of file diff --git a/tests/4_hexchain_pipeline/outputs/google_gemini-3.1-flash-lite.js b/tests/4_hexchain_pipeline/outputs/google_gemini-3.1-flash-lite.js new file mode 100644 index 0000000..f186802 --- /dev/null +++ b/tests/4_hexchain_pipeline/outputs/google_gemini-3.1-flash-lite.js @@ -0,0 +1,54 @@ +async function hexchain(tomlStr) { + const [ + { parse }, + { default: seedrandom }, + { mean, standardDeviation, median }, + { default: Ajv }, + { default: table }, + { DOMPurify } + ] = await Promise.all([ + import('https://esm.sh/smol-toml'), + import('https://esm.sh/seedrandom'), + import('https://esm.sh/simple-statistics'), + import('https://esm.sh/ajv'), + import('https://esm.sh/text-table'), + import('https://esm.sh/dompurify') + ]); + + const config = parse(tomlStr); + const ajv = new Ajv(); + const validate = ajv.compile({ + type: 'object', + required: ['seed', 'count', 'label'], + properties: { + seed: { type: 'string' }, + count: { type: 'integer', minimum: 1, maximum: 10000 }, + label: { type: 'string', minLength: 1 } + } + }); + + if (!validate(config)) return { valid: false, errors: ajv.errorsText(validate.errors) }; + + const rng = new seedrandom(config.seed); + const nums = Array.from({ length: config.count }, rng); + const round = n => +(n.toFixed(6)); + const stats = { mean: round(mean(nums)), stddev: round(standardDeviation(nums)), median: round(median(nums)) }; + + const tbl = table([ + ['Stat', 'Value'], + ['mean', String(stats.mean)], + ['stddev', String(stats.stddev)], + ['median', String(stats.median)] + ]); + + return { + valid: true, + label: config.label, + stats, + table: DOMPurify.sanitize(`
${tbl}
`), + count: config.count + }; +} +export default hexchain; +// Generation time: 1.959s +// Result: FAIL \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/google_gemini-3.1-flash-lite.js b/tests/5_markdown_parser/outputs/google_gemini-3.1-flash-lite.js new file mode 100644 index 0000000..c1227a8 --- /dev/null +++ b/tests/5_markdown_parser/outputs/google_gemini-3.1-flash-lite.js @@ -0,0 +1,13 @@ +async function parseMarkdown(md) { + const { marked } = await import("https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js"); + + marked.setOptions({ + gfm: true, + breaks: true + }); + + return marked.parse(md); +} +export default parseMarkdown; +// Generation time: 0.838s +// Result: PASS \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/google_gemini-3.1-flash-lite.js b/tests/6_csv_processor/outputs/google_gemini-3.1-flash-lite.js new file mode 100644 index 0000000..9eb6ade --- /dev/null +++ b/tests/6_csv_processor/outputs/google_gemini-3.1-flash-lite.js @@ -0,0 +1,24 @@ +async function processCSV(csv, { filterColumn, filterValue, groupBy, aggregateColumn, operation }) { + const { parse } = await import('https://cdn.skypack.dev/papaparse'); + const { data } = parse(csv, { header: true, dynamicTyping: true }); + + const groups = data + .filter(r => r[filterColumn] == filterValue) + .reduce((acc, r) => { + const key = r[groupBy]; + const val = Number(r[aggregateColumn]) || 0; + acc[key] ??= { sum: 0, count: 0 }; + acc[key].sum += val; + acc[key].count += 1; + return acc; + }, {}); + + return Object.entries(groups).map(([k, v]) => ({ + [groupBy]: k, + result: operation === 'sum' ? v.sum : + operation === 'avg' ? v.sum / v.count : v.count + })); +} +export default processCSV; +// Generation time: 1.360s +// Result: PASS \ No newline at end of file diff --git a/tests/7_scheduler/outputs/google_gemini-3.1-flash-lite.js b/tests/7_scheduler/outputs/google_gemini-3.1-flash-lite.js new file mode 100644 index 0000000..24eefdb --- /dev/null +++ b/tests/7_scheduler/outputs/google_gemini-3.1-flash-lite.js @@ -0,0 +1,41 @@ +async function findAvailableSlots(cal1, cal2, { durationMinutes, searchRange, workHours }) { + const { DateTime, Interval } = await import('https://cdn.skypack.dev/luxon'); + + const toUTC = (iso) => DateTime.fromISO(iso, { zone: 'utc' }); + const parseTime = (t, d) => DateTime.fromISO(`${d.toISODate()}T${t}:00Z`, { zone: 'utc' }); + + const busy = [...cal1, ...cal2].map(s => Interval.fromDateTimes(toUTC(s.start), toUTC(s.end))); + const merged = Interval.merge(busy); + + const start = toUTC(searchRange.start); + const end = toUTC(searchRange.end); + const slots = []; + + let current = start; + while (current < end) { + let day = current.startOf('day'); + let workStart = parseTime(workHours.start, day); + let workEnd = parseTime(workHours.end, day); + + let windowStart = current > workStart ? current : workStart; + let windowEnd = workEnd; + + for (let s = windowStart; s.plus({ minutes: durationMinutes }) <= windowEnd; ) { + let slotEnd = s.plus({ minutes: durationMinutes }); + let interval = Interval.fromDateTimes(s, slotEnd); + + if (!merged.some(b => b.overlaps(interval))) { + slots.push({ start: s.toISO(), end: slotEnd.toISO() }); + s = slotEnd; + } else { + s = s.plus({ minutes: 1 }); + } + } + current = day.plus({ days: 1 }); + } + + return slots; +} +export default findAvailableSlots; +// Generation time: 2.010s +// Result: PASS \ No newline at end of file diff --git a/tests/8_json_validator/outputs/google_gemini-3.1-flash-lite.js b/tests/8_json_validator/outputs/google_gemini-3.1-flash-lite.js new file mode 100644 index 0000000..7210d5b --- /dev/null +++ b/tests/8_json_validator/outputs/google_gemini-3.1-flash-lite.js @@ -0,0 +1,18 @@ +async function validateJSON(data, schema) { + const { default: Ajv } = await import('https://esm.sh/ajv@8.12.0'); + const { default: addFormats } = await import('https://esm.sh/ajv-formats@2.1.1'); + + const ajv = new (Ajv)({ allErrors: true }); + addFormats(ajv); + + const validate = ajv.compile(schema); + const valid = validate(data); + + return { + valid, + errors: valid ? [] : validate.errors.map(e => `${e.instancePath} ${e.message}`) + }; +} +export default validateJSON; +// Generation time: 1.038s +// Result: PASS \ No newline at end of file diff --git a/tests/9_stream_visualizer/outputs/google_gemini-3.1-flash-lite.js b/tests/9_stream_visualizer/outputs/google_gemini-3.1-flash-lite.js new file mode 100644 index 0000000..0c9b12a --- /dev/null +++ b/tests/9_stream_visualizer/outputs/google_gemini-3.1-flash-lite.js @@ -0,0 +1,20 @@ +async function createStreamVisualizer(it, { maxPoints, alpha, width, height, yDomain }) { + const [{ scaleLinear, line, extent }] = await Promise.all([import('https://cdn.skypack.dev/d3')]); + const data = []; + let prevEma; + + for await (const { timestamp, value } of it) { + prevEma = prevEma === undefined ? value : alpha * value + (1 - alpha) * prevEma; + data.push({ timestamp, value, ema: prevEma }); + if (data.length > maxPoints) data.shift(); + } + + const x = scaleLinear().domain(extent(data, d => d.timestamp)).range([0, width]); + const y = scaleLinear().domain(yDomain).range([height, 0]); + const path = line().x(d => x(d.timestamp)).y(d => y(d.ema))(data); + + return { data, path }; +} +export default createStreamVisualizer; +// Generation time: 1.461s +// Result: PASS \ No newline at end of file