78 lines
3.2 KiB
Plaintext
78 lines
3.2 KiB
Plaintext
diff --git a/tests/acceptance/1/CRITERIA.json b/tests/acceptance/1/CRITERIA.json
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..7c03e1c662ee812513e95200e454ab03a6a581fb
|
|
--- /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 0000000000000000000000000000000000000000..dbe10de9f24e38c05982013a49bd4f2b60cd14e6
|
|
--- /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.<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')
|
|
+})
|
|
diff --git a/web/js/runtime/caps.js b/web/js/runtime/caps.js
|
|
index db6a3a700047089359db731cd85c76a6f769d338..bc53ce26460b75215ba5a15cf2052c5a4426ca88 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}`;
|
|
}
|