VEHwang's picture
Upload CoCogni4D-Bench (questions, media, scripts, render records, code) (part 4)
9d57416 verified
Raw History Blame Contribute Delete
1.33 kB
import assert from 'node:assert/strict';
import test from 'node:test';
import fs from 'node:fs';
import {intentAt} from '../src/lookup.ts';
import type {Intent} from '../src/contract.ts';
test('真实换目标链按Python给的目标阶段查表;提前显示最终目标会失败', {skip: !process.env.CONSOLE_GENERATION_FIXTURE}, () => {
const fixture = JSON.parse(fs.readFileSync(process.env.CONSOLE_GENERATION_FIXTURE!, 'utf8'));
assert.equal(fixture.schema, 'segment-view/3');
const row: Intent = fixture.intents[0];
assert(row.target_stages.length >= 2);
let checked = 0;
for (const stage of row.target_stages) {
if (stage.end_s <= stage.start_s) continue;
const time = (stage.start_s + stage.end_s) / 2;
assert.deepEqual(intentAt([row], time)?.target, stage.target);
checked++;
}
assert(checked >= 2);
const first = row.target_stages[0];
assert.notDeepEqual(first.target, row.target, '真实夹具应有不同的原目标和末目标');
const wrong = {...row, target_stages: [{start_s: row.start_s, end_s: row.end_s, target: row.target}]};
assert.throws(() => assert.deepEqual(intentAt([wrong], (first.start_s + first.end_s) / 2)?.target, first.target));
console.log(JSON.stringify({artifact_sha256: fixture.artifact_sha256, checked, negative_control_rejected: true}));
});