Solution to #1: Make the capability summary print a question mark when the memory size is unknown #4
24
tests/acceptance/1/CRITERIA.json
Normal file
24
tests/acceptance/1/CRITERIA.json
Normal file
@@ -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"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
26
tests/acceptance/1/criteria.test.js
Normal file
26
tests/acceptance/1/criteria.test.js
Normal file
@@ -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.<name>(...)
|
||||
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')
|
||||
})
|
||||
@@ -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}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user