From 739dfd8df42a48580747e88a59f4021885e9a6cc Mon Sep 17 00:00:00 2001 From: e0425bed061809c5ce17450fe47dc970090a0938 Date: Fri, 2 Oct 2026 06:42:01 +0000 Subject: [PATCH] Solution 0x107bc3cf77e98b93fee725ee9f6ebf92cf7d1b1f3c4ac7c47ace317610ccde95 T2T-Item: 0x107bc3cf77e98b93fee725ee9f6ebf92cf7d1b1f3c4ac7c47ace317610ccde95 T2T-Issue: 0x74d315a963e864fb89a00de904bbf1b82abb5325c6102bedaea0ce1545593480 --- tests/acceptance/1/CRITERIA.json | 24 ++++++++++++++++++++++++ tests/acceptance/1/criteria.test.js | 26 ++++++++++++++++++++++++++ web/js/runtime/caps.js | 6 ++---- 3 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 tests/acceptance/1/CRITERIA.json create mode 100644 tests/acceptance/1/criteria.test.js diff --git a/tests/acceptance/1/CRITERIA.json b/tests/acceptance/1/CRITERIA.json new file mode 100644 index 0000000..7c03e1c --- /dev/null +++ b/tests/acceptance/1/CRITERIA.json @@ -0,0 +1,24 @@ +{ + "schema": "elffuss-t2t/criteria@2", + "issue": 1, + "criteria": [ + { + "index": 1, + "tests": [ + "tests/acceptance/1/criteria.test.js::criterion 1" + ] + }, + { + "index": 2, + "tests": [ + "tests/acceptance/1/criteria.test.js::criterion 2" + ] + }, + { + "index": 3, + "tests": [ + "tests/acceptance/1/criteria.test.js::criterion 3" + ] + } + ] +} diff --git a/tests/acceptance/1/criteria.test.js b/tests/acceptance/1/criteria.test.js new file mode 100644 index 0000000..dbe10de --- /dev/null +++ b/tests/acceptance/1/criteria.test.js @@ -0,0 +1,26 @@ +import { test } from 'node:test' +import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' +import * as mod from '../../../web/js/runtime/caps.js' // the code under test: call it as mod.(...) +const source = readFileSync(new URL('../../../web/js/runtime/caps.js', import.meta.url), 'utf8') // the text of web/js/runtime/caps.js, for a criterion about how the file is written + +test('criterion 1', () => { + // `summarize` of a capability object whose `memGB` field is missing returns a string that does not contain `undefined`. + const cap = { name: 'test' } + const summary = mod.summarize(cap) + assert.assert.notInclude(summary, 'undefined') +}) + +test('criterion 2', () => { + // `summarize` of a capability object whose `memGB` field is missing returns a string that contains `~?GB RAM`. + const cap = { name: 'test' } + const summary = mod.summarize(cap) + assert.assert.include(summary, '~?GB RAM') +}) + +test('criterion 3', () => { + // `summarize` of a capability object whose `memGB` is a number returns a string that contains that number immediately followed by `GB RAM`. + const cap = { name: 'test', memGB: 4 } + const summary = mod.summarize(cap) + assert.assert.include(summary, '4GB RAM') +}) diff --git a/web/js/runtime/caps.js b/web/js/runtime/caps.js index db6a3a7..bc53ce2 100644 --- a/web/js/runtime/caps.js +++ b/web/js/runtime/caps.js @@ -105,8 +105,6 @@ export async function probe() { export function summarize(c) { const p = c.platform.iOS ? 'iOS' : c.platform.android ? 'Android' : c.platform.mac ? 'Mac' : c.platform.mobile ? 'móvil' : 'escritorio'; - const g = c.gpu - ? `WebGPU · buffer≤${(c.limits.maxBufferSize / GiB).toFixed(1)}GiB · binding≤${(c.limits.maxStorageBufferBindingSize / MiB) | 0}MiB` - : `sin GPU (${c.error || '—'})`; - return `${p} · ~${c.memGB}GB RAM · presupuesto ${c.budgetGiB}GiB · ${g}`; + const g = c.gpu ? `WebGPU · buffer≤${(c.limits.maxBufferSize / GiB).toFixed(1)}GiB · binding≤${(c.limits.maxStorageBufferBindingSize / MiB) | 0}MiB` : `sin GPU (${c.error || '—'})`; + return `${p} · ~${c.memGB !== undefined ? c.memGB : '?'}GB RAM · presupuesto ${c.budgetGiB}GiB · ${g}`; } -- 2.49.1