Spaces:
Sleeping
Sleeping
Download scripts/test_mic_loop.mjs from jasonmdong/notepilot: direct link, hf CLI and curl.
- Browser
- Download file 1.72 kB
-
https://huggingface.co/spaces/jasonmdong/notepilot/resolve/main/scripts/test_mic_loop.mjs
- Command line
-
hf download hf://spaces/jasonmdong/notepilot/scripts/test_mic_loop.mjs
-
curl -L -o test_mic_loop.mjs https://huggingface.co/spaces/jasonmdong/notepilot/resolve/main/scripts/test_mic_loop.mjs
1.72 kB
| import assert from 'node:assert/strict'; | |
| import { nextAttempt, notePilotTarget, retryAlreadyCommitted, summariseRun } from './mic_loop_support.mjs'; | |
| assert.equal(notePilotTarget([{type:'page',url:'http://127.0.0.1:8001/other'}, | |
| {type:'page',url:'http://localhost:8000/test/score',id:'correct'}]).id, 'correct'); | |
| let result = nextAttempt(1, 1, 6, 6); | |
| assert.equal(result.index, 2); | |
| assert.equal(result.gaveUp, true); | |
| result = nextAttempt(result.index, 1, result.attempt, 6); | |
| assert.equal(result.index, 2, 'a lagging follower must not rewind us to the event we gave up'); | |
| assert.equal(result.attempt, 1); | |
| assert.equal(nextAttempt(2, 4, 1, 6).index, 4); | |
| assert.equal(retryAlreadyCommitted(0, 0), false); | |
| assert.equal(retryAlreadyCommitted(0, 1), true, 'a late commit cancels the queued retry'); | |
| const resultSummary = summariseRun({events:[ | |
| {type:'input.testEvent',index:0,pitches:[39,53],attempt:0,t:100}, | |
| {type:'follow.advance',toIndex:0,t:300,accepted:true}, | |
| {type:'input.testEvent',index:1,pitches:[55],attempt:0,t:1000}, | |
| {type:'input.testEvent',index:1,pitches:[55],attempt:1,t:1500}, | |
| {type:'follow.advance',toIndex:1,t:1750,accepted:true}, | |
| {type:'follow.advance',toIndex:2,t:1900,accepted:true}, | |
| {type:'input.testEvent',index:2,pitches:[56],attempt:0,t:2000}, | |
| ]}); | |
| assert.equal(resultSummary.attemptedEvents, 3); | |
| assert.equal(resultSummary.detectedWithin450ms, 2, 'one committed chord is one hit'); | |
| assert.equal(resultSummary.retries, 1); | |
| assert.equal(resultSummary.commitsWithoutPriorAttempt.length, 1, 'future attempts cannot justify an early advance'); | |
| assert.deepEqual(resultSummary.undetected, [2]); | |
| console.log('PASS: target selection, bounded retries, chord/event scoring and early-advance audit'); | |