Solution 0xefacf4f7864fc9d7fe853b2773f3274179396b5563dc0d992b891e41f6c232bc
Some checks failed
elffuss/validation The automatic validation rejected the solution

T2T-Item: 0xefacf4f7864fc9d7fe853b2773f3274179396b5563dc0d992b891e41f6c232bc
T2T-Issue: 0xc061cbad52bed8ff95a90bbe778649684057e759d44b433dc318f7ba7fae0636
This commit is contained in:
2026-10-05 17:19:45 +00:00
committed by elffuss-bot
parent 249c846850
commit 75299cbe41
3 changed files with 49 additions and 3 deletions

View File

@@ -0,0 +1,18 @@
{
"schema": "elffuss-t2t/criteria@2",
"issue": 4,
"criteria": [
{
"index": 1,
"tests": [
"tests/acceptance/4/criteria.test.js::criterion 1"
]
},
{
"index": 2,
"tests": [
"tests/acceptance/4/criteria.test.js::criterion 2"
]
}
]
}

View File

@@ -0,0 +1,28 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import * as mod from '../../../core/providers/onnx.js' // the code under test: call it as mod.<name>(...)
const source = readFileSync(new URL('../../../core/providers/onnx.js', import.meta.url), 'utf8') // the text of core/providers/onnx.js, for a criterion about how the file is written
test('criterion 1', () => {
// The `chat` function of core/providers/onnx.js declares a fourth parameter named `signal` with default `null`.
const chat = mod.chat(1, 2, 3, null)
assert.strictEqual(chat.signal, null)
})
test('criterion 2', () => {
// With an aborted `signal`, `chat` never calls `onToken`, and with no `signal` it still calls `onToken` for every token.
const mockOnToken = assert.fn()
const chatWithSignal = mod.chat(1, 2, 3, { abort: true }, mockOnToken)
const chatWithoutSignal = mod.chat(1, 2, 3, undefined, mockOnToken)
// Test with aborted signal
const resultWithSignal = chatWithSignal()
assert.strictEqual(resultWithSignal, undefined)
assert.strictEqual(mockOnToken.callCount, 0)
// Test without signal
const resultWithoutSignal = chatWithoutSignal()
assert.strictEqual(resultWithoutSignal, undefined)
assert.strictEqual(mockOnToken.callCount, 1)
})