ondas 2.1.0

Read-only, format-independent waveform analysis library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
use super::*;
use crate::backends::{
    Reader,
    generated::{self, Counts, PAYLOAD, Probe},
};
use std::cell::Cell;
use std::collections::BTreeSet;

thread_local! {
    static TICK_WORK: Cell<(usize, usize, usize)> = const { Cell::new((0, 0, 0)) };
}

pub(super) fn setup_visits(n: usize) {
    TICK_WORK.with(|work| work.update(|(setup, compare, commit)| (setup + n, compare, commit)));
}

pub(super) fn comparison_visit() {
    TICK_WORK.with(|work| work.update(|(setup, compare, commit)| (setup, compare + 1, commit)));
}

pub(super) fn commit_visit() {
    TICK_WORK.with(|work| work.update(|(setup, compare, commit)| (setup, compare, commit + 1)));
}

fn tick_work() -> (usize, usize, usize) {
    TICK_WORK.with(Cell::get)
}

pub(super) fn probe(reader: &Reader) -> Option<Probe> {
    if let Reader::Generated(reader) = reader {
        Some(reader.probe.clone())
    } else {
        None
    }
}

// Observe real engine slots after every raw record, not an assumed bound.
pub(super) fn observe_pending(probe: &Option<Probe>, slots: &[Slot]) {
    let Some(probe) = probe else { return };
    let mut records = 0;
    let mut bytes = 0;
    for slot in slots {
        for value in slot
            .state
            .as_ref()
            .map(|state| &state.value)
            .into_iter()
            .chain(slot.pending.as_ref())
        {
            records += 1;
            bytes += match value {
                Value::Real(_) => 8,
                Value::String(value) => value.len(),
                _ => panic!("unexpected generated persistent class"),
            };
        }
        records += usize::from(slot.events > 0);
    }
    let mut counts = probe.lock().unwrap();
    counts.max_pending_records = counts.max_pending_records.max(records);
    counts.max_pending_bytes = counts.max_pending_bytes.max(bytes);
    counts.max_slots = counts.max_slots.max(slots.len());
}

fn fixture(ticks: u64, fail_at: Option<(u64, usize)>) -> (Waveform, Vec<Signal>, Probe) {
    let mut wave = Waveform::memory(
        vec![
            Encoding::Real,
            Encoding::Event,
            Encoding::String,
            Encoding::String,
        ],
        vec![],
        None,
    );
    let signals = wave.hierarchy().signals().collect::<Vec<_>>();
    let probe = Probe::default();
    wave.reader = Reader::Generated(generated::Reader {
        ticks,
        fail_at,
        probe: probe.clone(),
    });
    (wave, signals, probe)
}

fn counts(probe: &Probe) -> Counts {
    probe.lock().unwrap().clone()
}

#[cfg(feature = "wlf-lib")]
#[test]
#[ignore = "requires Questa and installed string fixture; run just conformance-wlf"]
fn wlf_last_completed_tick_precedes_late_string_error() {
    let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
        .join("fixtures/wlf/wlf0072-strings-and-names/waveform.wlf");
    for count in [1, 2048] {
        for bits_first in [false, true] {
            let mut wave = crate::open_with(&path, "wlf-lib").unwrap();
            let bits = wave.hierarchy().signal("top.ascending").unwrap();
            let text = wave.hierarchy().signal("top.message").unwrap();
            let mut selection = wave.select(&[bits, text]).unwrap();
            // Bypass base deduplication only to fill native batches with this
            // small published input. The SDK, worker and query path are real.
            selection.bases = vec![bits; count];
            selection
                .bases
                .insert(if bits_first { count } else { 0 }, text);
            for stop in [Some(3), None] {
                let mut candidates = Vec::new();
                let outcome = selection.query(
                    TimeRange::closed(Time::ZERO, Time::from_ticks(7)),
                    &[0, 1],
                    |ctx| {
                        candidates.push(ctx.time().ticks());
                        Ok(if stop == Some(ctx.time().ticks()) {
                            ControlFlow::Break(17)
                        } else {
                            ControlFlow::Continue(())
                        })
                    },
                );
                assert_eq!(candidates, [0, 1, 2, 3]);
                if stop.is_some() {
                    assert!(matches!(outcome, Ok(ControlFlow::Break(17))));
                } else {
                    assert!(matches!(
                        outcome,
                        Err(Error::NonAsciiString { format: crate::Format::Wlf, time, .. })
                            if time == Time::from_ticks(4)
                    ));
                }
            }
            let mut observed = Vec::new();
            let outcome = selection
                .query(
                    TimeRange::closed(Time::ZERO, Time::from_ticks(3)),
                    &[0, 1],
                    |ctx| {
                        let mut values = Vec::new();
                        let _ = ctx.visit_samples(ctx.time(), &[0, 1], |_, sample| {
                            let SampleRef::Value { value, .. } = sample else {
                                panic!("expected recorded values");
                            };
                            values.push(match value {
                                ValueRef::Bits(bits) => bits.to_string(),
                                ValueRef::String(text) => text.to_owned(),
                                _ => panic!("expected Bits or String"),
                            });
                            Ok(ControlFlow::<()>::Continue(()))
                        })?;
                        observed.push((ctx.time().ticks(), values));
                        Ok(ControlFlow::<()>::Continue(()))
                    },
                )
                .unwrap();
            assert_eq!(outcome, ControlFlow::Continue(()));
            let expected = [
                "",
                "hello",
                "quotes: \" backslash: \\ tab: \t newline: \n",
                "ab",
            ]
            .into_iter()
            .enumerate()
            .map(|(tick, text)| (tick as u64, vec!["10000001".to_owned(), text.to_owned()]))
            .collect::<Vec<_>>();
            assert_eq!(observed, expected);
        }
    }
}

#[test]
fn sparse_active_finalization_visits_only_touched_slots() {
    let mut text = String::new();
    for i in 0..64 {
        text.push_str(&format!(
            "$var wire {} v{i} n{i} $end ",
            if i == 0 { 2 } else { 1 }
        ));
    }
    text.push_str("$var event 1 e trigger $end $enddefinitions $end #0 ");
    for i in 0..64 {
        text.push_str(&format!("{}v{i} ", if i == 0 { "b00 " } else { "0" }));
    }
    text.push_str("#1 b01 v0 #2 b00 v0 b01 v0 1e 1e #3 1v63 ");
    let mut wave =
        crate::open_bytes_with("sparse.vcd", text.into_bytes().into(), "vcd-native").unwrap();
    let signals = (0..64)
        .map(|i| wave.hierarchy().signal(&format!("n{i}")).unwrap())
        .collect::<Vec<_>>();
    let event = wave.hierarchy().signal("trigger").unwrap();
    let mut selected = vec![signals[0], signals[0].slice(0, 0).unwrap(), signals[0]];
    selected.extend_from_slice(&signals[1..]);
    selected.push(event);
    let event_index = selected.len() - 1;
    let quiet_index = event_index - 1;
    let mut selection = wave.select(&selected).unwrap();
    TICK_WORK.with(|work| work.set((0, 0, 0)));
    let mut changes = Vec::new();
    let _ = selection
        .scan_each(TimeRange::all(), |index, record| {
            if let ScanRef::Change { time, value, .. } = record {
                changes.push((
                    index,
                    time.ticks(),
                    matches!(value, ValueRef::Event { occurrences: 2 }),
                ));
            }
            ControlFlow::<()>::Continue(())
        })
        .unwrap();
    assert_eq!(
        tick_work(),
        (66, 71, 71),
        "setup, compare and commit visits"
    );
    assert!(changes.contains(&(event_index, 2, true)));
    assert!(changes.contains(&(quiet_index, 3, false)));
    assert!(
        !changes
            .iter()
            .any(|&(index, tick, _)| tick == 2 && index < 3)
    );
    let samples = selection.samples(Time::from_ticks(3)).unwrap();
    assert!(matches!(
        samples[event_index],
        Sample::Event { occurrences: 0, .. }
    ));
    assert!(
        matches!(samples[quiet_index], Sample::Value { changed_at: Some(t), .. } if t == Time::from_ticks(3))
    );
    assert_eq!(format!("{:?}", samples[0]), format!("{:?}", samples[2]));
    let mut previous_events = 0;
    let _ = selection
        .query(
            TimeRange::point(Time::from_ticks(3)),
            &[quiet_index],
            |ctx| {
                ctx.visit_samples(Time::from_ticks(2), &[event_index], |_, sample| {
                    let SampleRef::Event { occurrences, .. } = sample else {
                        panic!("previous event")
                    };
                    previous_events = occurrences;
                    Ok(ControlFlow::<()>::Continue(()))
                })
            },
        )
        .unwrap();
    assert_eq!(previous_events, 2);
}

#[test]
fn generated_stream_bounds_and_deferred_caller_work_do_not_grow_with_history() {
    let mut footprints = Vec::new();
    for ticks in [4, 64, 4096] {
        let (mut wave, signals, probe) = fixture(ticks, None);
        let selected = [signals[0], signals[1], signals[2], signals[2]];
        let mut selection = wave.select(&selected).unwrap();
        let mut candidates = 0;
        let mut subset_requests = 0;
        let mut deliveries = 0;
        let mut owned_payload = Vec::new();
        let _ = selection
            .query(TimeRange::from(Time::from_ticks(1)), &[0], |ctx| {
                candidates += 1;
                let tick = ctx.time().ticks();
                assert_eq!(tick, candidates);
                assert_eq!(ctx.previous_events.len(), 3);
                let before_counts = counts(&probe);
                assert_eq!(before_counts.starts, 1);
                let before = Time::from_ticks(tick.checked_sub(1).unwrap());
                for time in [before, ctx.time(), before] {
                    subset_requests += 1;
                    let mut delivered = Vec::new();
                    let _ = ctx.visit_samples(time, &[0, 1], |index, sample| {
                        delivered.push(index);
                        deliveries += 1;
                        match (index, sample) {
                            (
                                0,
                                SampleRef::Value {
                                    value: ValueRef::Real(value),
                                    ..
                                },
                            ) => assert_eq!(value, time.ticks() as f64),
                            (1, SampleRef::Event { occurrences: 2, .. }) => (),
                            _ => panic!("unexpected or unrequested sample"),
                        }
                        Ok(ControlFlow::<()>::Continue(()))
                    })?;
                    assert_eq!(delivered, [0, 1]);
                }
                if tick == ticks - 1 {
                    let mut delivered = Vec::new();
                    let _ = ctx.visit_samples(ctx.time(), &[3, 2], |index, sample| {
                        delivered.push(index);
                        let SampleRef::Value {
                            value: ValueRef::String(value),
                            ..
                        } = sample
                        else {
                            panic!("payload class")
                        };
                        // This is caller-owned output, distinct from fallback state copies.
                        owned_payload.push(value.to_owned());
                        Ok(ControlFlow::<()>::Continue(()))
                    })?;
                    assert_eq!(delivered, [3, 2]);
                } else {
                    assert!(owned_payload.is_empty());
                }
                let after_counts = counts(&probe);
                assert_eq!(after_counts.starts, before_counts.starts);
                assert_eq!(after_counts.advances, before_counts.advances);
                Ok(ControlFlow::<()>::Continue(()))
            })
            .unwrap();
        assert_eq!(candidates, ticks - 1);
        assert_eq!(subset_requests, 3 * (ticks - 1));
        assert_eq!(deliveries, 6 * (ticks - 1));
        let observed = counts(&probe);
        assert_eq!(observed.requested_bases, [0, 1, 2]);
        assert_eq!(observed.advances, 4 * ticks);
        assert_eq!(observed.payload_decodes, ticks); // sequential fallback is permitted
        assert_eq!(observed.unused_decodes, 0);
        assert_eq!(
            (observed.starts, observed.releases, observed.active),
            (1, 1, 0)
        );
        assert_eq!(observed.max_slots, 3);
        assert_eq!(observed.max_pending_records, 5);
        assert_eq!(observed.max_pending_bytes, 2 * (8 + PAYLOAD.len()));
        footprints.push((observed.max_pending_records, observed.max_pending_bytes));
        drop(wave);
        assert_eq!(counts(&probe).reader_drops, 1);
        assert_eq!(owned_payload, [PAYLOAD, PAYLOAD]);
    }
    assert!(footprints.windows(2).all(|pair| pair[0] == pair[1]));
}

#[test]
fn early_break_has_a_logical_advance_budget_and_releases_the_read_lease() {
    let (mut wave, signals, probe) = fixture(u64::MAX, None);
    probe.lock().unwrap().advance_budget = Some(5); // four records + one lookahead
    let mut selection = wave.select(&signals[..3]).unwrap();
    let token = String::from("owned break token").into_boxed_str();
    let address = token.as_ptr();
    let mut token = Some(token);
    let mut delivered = Vec::new();
    let result = selection
        .query(TimeRange::all(), &[0], |ctx| {
            assert_eq!(ctx.time(), Time::ZERO);
            assert_eq!(counts(&probe).advances, 5);
            ctx.visit_samples(ctx.time(), &[2, 0], |index, _| {
                delivered.push(index);
                Ok(ControlFlow::Break(token.take().unwrap()))
            })
        })
        .unwrap();
    let ControlFlow::Break(token) = result else {
        panic!("lost break")
    };
    assert_eq!(token.as_ptr(), address);
    assert_eq!(&*token, "owned break token");
    assert_eq!(delivered, [2]);
    let observed = counts(&probe);
    assert_eq!(
        (observed.starts, observed.releases, observed.active),
        (1, 1, 0)
    );
    probe.lock().unwrap().advance_budget = None;
    let mut fresh = 0;
    let _ = selection
        .query(TimeRange::point(Time::ZERO), &[0], |ctx| {
            fresh += 1;
            assert_eq!(ctx.time(), Time::ZERO);
            Ok(ControlFlow::<()>::Continue(()))
        })
        .unwrap();
    assert_eq!(fresh, 1);
    assert_eq!((counts(&probe).starts, counts(&probe).releases), (2, 2));
    drop(wave);
    assert_eq!(counts(&probe).reader_drops, 1);
}

#[test]
fn generated_source_failures_never_publish_an_unfinished_tick() {
    for fail_at in [(0, 0), (0, 2), (2, 2)] {
        for indexed in [false, true] {
            let (mut wave, signals, probe) = fixture(5, Some(fail_at));
            let mut selection = wave.select(&signals[..3]).unwrap();
            let mut published = BTreeSet::new();
            let result = if indexed {
                selection.scan_each(TimeRange::all(), |index, record| {
                    let ScanRef::Change { time, value, .. } = record else {
                        panic!("no entering state at zero")
                    };
                    published.insert(time.ticks());
                    if index == 1 {
                        assert!(matches!(value, ValueRef::Event { occurrences: 2 }));
                    }
                    ControlFlow::<()>::Continue(())
                })
            } else {
                selection.query(TimeRange::all(), &[0, 1], |ctx| {
                    published.insert(ctx.time().ticks());
                    ctx.visit_samples(ctx.time(), &[1], |_, sample| {
                        assert!(matches!(sample, SampleRef::Event { occurrences: 2, .. }));
                        Ok(ControlFlow::<()>::Continue(()))
                    })
                })
            };
            assert!(
                matches!(result,Err(Error::Backend {backend,operation:"read",message}) if backend=="generated" && message=="injected source failure")
            );
            assert_eq!(published, (0..fail_at.0).collect());
            let observed = counts(&probe);
            assert_eq!(
                (observed.starts, observed.releases, observed.active),
                (1, 1, 0)
            );
            let Reader::Generated(reader) = &mut selection.waveform.reader else {
                unreachable!()
            };
            reader.fail_at = None;
            let mut fresh = 0;
            let _ = selection
                .query(TimeRange::point(Time::ZERO), &[0], |ctx| {
                    fresh += 1;
                    ctx.visit_samples(ctx.time(), &[0], |_, sample| {
                        assert!(matches!(
                            sample,
                            SampleRef::Value {
                                value: ValueRef::Real(0.0),
                                changed_at: None,
                                ..
                            }
                        ));
                        Ok(ControlFlow::<()>::Continue(()))
                    })
                })
                .unwrap();
            assert_eq!(fresh, 1);
            assert_eq!((counts(&probe).starts, counts(&probe).releases), (2, 2));
            drop(wave);
            assert_eq!(counts(&probe).reader_drops, 1);
        }
    }
}

#[test]
fn selective_consumer_errors_preserve_prior_delivery_and_unused_channels_stay_unvalidated() {
    let (mut wave, signals, probe) = fixture(5, Some((0, 4)));
    let mut selection = wave.select(&signals[..3]).unwrap();
    let mut earlier = Vec::new();
    let mut subset = Vec::new();
    let mut successful_operand = None;
    let result = selection.query(TimeRange::all(), &[0], |ctx| {
        if ctx.time().ticks() < 2 {
            earlier.push(ctx.time().ticks());
            return Ok(ControlFlow::<()>::Continue(()));
        }
        ctx.visit_samples(ctx.time(), &[0, 2, 1], |index, sample| {
            subset.push(index);
            if index == 2 {
                return Err(Error::Backend {
                    backend: "consumer".into(),
                    operation: "selective read",
                    message: "sentinel".into(),
                });
            }
            let SampleRef::Value {
                value: ValueRef::Real(value),
                ..
            } = sample
            else {
                panic!("operand")
            };
            successful_operand = Some(value);
            Ok(ControlFlow::<()>::Continue(()))
        })
    });
    assert!(
        matches!(result,Err(Error::Backend {backend,operation:"selective read",message}) if backend=="consumer" && message=="sentinel")
    );
    assert_eq!(earlier, [0, 1]);
    assert_eq!(subset, [0, 2]);
    assert_eq!(successful_operand, Some(2.0));
    assert_eq!((counts(&probe).releases, counts(&probe).active), (1, 0));
    let mut fresh = 0;
    let _ = selection
        .query(TimeRange::all(), &[0], |_| {
            fresh += 1;
            Ok(ControlFlow::<()>::Continue(()))
        })
        .unwrap();
    assert_eq!(fresh, 5);
    assert_eq!(counts(&probe).unused_decodes, 0);
    let mut selection = wave.select(&[signals[3]]).unwrap();
    let result = selection.query(TimeRange::all(), &[0], |_| -> Result<ControlFlow<()>> {
        panic!("selected invalid channel must fail")
    });
    assert!(
        matches!(result,Err(Error::Backend {backend,operation:"read",..}) if backend=="generated")
    );
    let observed = counts(&probe);
    assert_eq!(observed.requested_bases, [3]);
    assert_eq!(
        (observed.starts, observed.releases, observed.active),
        (3, 3, 0)
    );
    drop(wave);
    assert_eq!(counts(&probe).reader_drops, 1);
}

#[test]
fn explicit_times_use_one_read_with_bounded_working_values() {
    let mut footprints = Vec::new();
    for ticks in [4, 64, 4096] {
        let (mut wave, signals, probe) = fixture(ticks, None);
        let selected = [signals[0], signals[1], signals[2], signals[2]];
        let times = [ticks - 1, 0, ticks - 1, ticks / 2].map(Time::from_ticks);
        let rows = wave.samples_at(&selected, &times).unwrap();
        assert_eq!(rows.len(), times.len());
        for ((time, row), expected_time) in rows.iter().zip(times) {
            assert_eq!(*time, expected_time);
            assert!(
                matches!(row[0], Sample::Value { value: Value::Real(value), .. } if value == time.ticks() as f64)
            );
            assert!(matches!(row[1], Sample::Event { occurrences: 2, .. }));
            for sample in &row[2..] {
                assert!(
                    matches!(sample, Sample::Value { value: Value::String(value), .. } if value.as_ref() == PAYLOAD)
                );
            }
        }
        let observed = counts(&probe);
        assert_eq!(
            (observed.starts, observed.releases, observed.active),
            (1, 1, 0)
        );
        assert_eq!(observed.advances, 4 * ticks);
        assert_eq!(observed.max_slots, 3);
        assert_eq!(observed.max_pending_records, 5);
        assert_eq!(observed.max_pending_bytes, 2 * (8 + PAYLOAD.len()));
        footprints.push((observed.max_pending_records, observed.max_pending_bytes));
        // Empty dimensions do not start another reader session.
        assert!(wave.samples_at(&selected, &[]).unwrap().is_empty());
        assert!(
            wave.samples_at(&[], &times)
                .unwrap()
                .iter()
                .all(|r| r.1.is_empty())
        );
        assert_eq!(counts(&probe).starts, 1);
    }
    assert!(footprints.windows(2).all(|pair| pair[0] == pair[1]));
}

#[test]
fn selected_payload_failure_precedes_late_or_absent_matches_and_aborts_batch() {
    for accept_at in [Some(8), None] {
        // Position 3 is the selected string payload, after the tick's driver.
        let (mut wave, signals, probe) = fixture(10, Some((3, 3)));
        let selected = [signals[0], signals[2]];
        let mut candidates = Vec::new();
        let mut matches = 0;
        let error = wave
            .select(&selected)
            .unwrap()
            .query(TimeRange::all(), &[0], |ctx| {
                candidates.push(ctx.time().ticks());
                if accept_at == Some(ctx.time().ticks()) {
                    matches += 1;
                    return ctx.visit_samples(ctx.time(), &[1], |_, _| {
                        Ok(ControlFlow::<()>::Continue(()))
                    });
                }
                Ok(ControlFlow::Continue(()))
            })
            .unwrap_err();
        assert!(
            matches!(error, Error::Backend { ref backend, operation: "read", .. } if backend == "generated")
        );
        assert_eq!(candidates, [0, 1, 2]);
        assert_eq!(matches, 0);
        // Earlier batch rows can be built, but none are returned on failure.
        let batch = wave.samples_at(&selected, &[Time::ZERO, Time::from_ticks(8)]);
        assert!(matches!(
            batch,
            Err(Error::Backend {
                operation: "read",
                ..
            })
        ));
        assert_eq!(counts(&probe).active, 0);
        let Reader::Generated(reader) = &mut wave.reader else {
            unreachable!()
        };
        reader.fail_at = None;
        assert_eq!(
            wave.samples_at(&selected, &[Time::from_ticks(8)])
                .unwrap()
                .len(),
            1
        );
        assert_eq!(counts(&probe).starts, 3);
    }
}