Translate Types and Utilities parity tests
Some checks failed
Rust API gates / api-gates (push) Has been cancelled

This commit is contained in:
2026-08-08 13:58:25 +02:00
parent 39ee61525a
commit 1c0dfdc35c
19 changed files with 3482 additions and 3318 deletions

View File

@@ -1,9 +1,11 @@
//! Shared deterministic fixtures used by translated compatibility tests.
use std::collections::BTreeMap;
use std::future::Future;
use std::io;
use std::path::{Component, Path, PathBuf};
use std::sync::{Arc, Mutex};
use std::task::{Context, Poll, Wake, Waker};
use std::time::Duration;
/// Fails a not-yet-translated upstream test while retaining parity metadata.
@@ -25,6 +27,27 @@ pub fn pending(
)
}
/// Runs one test future without choosing an async runtime for the library.
pub fn block_on<F: Future>(future: F) -> F::Output {
struct ThreadWake(std::thread::Thread);
impl Wake for ThreadWake {
fn wake(self: Arc<Self>) {
self.0.unpark();
}
}
let waker = Waker::from(Arc::new(ThreadWake(std::thread::current())));
let mut context = Context::from_waker(&waker);
let mut future = std::pin::pin!(future);
loop {
match future.as_mut().poll(&mut context) {
Poll::Ready(output) => return output,
Poll::Pending => std::thread::park(),
}
}
}
/// Asserts equality within the exact absolute tolerance carried by an upstream test.
///
/// # Panics
@@ -250,6 +273,7 @@ mod tests {
#[test]
fn deterministic_harness_covers_clock_network_and_bytes() {
assert_eq!(block_on(std::future::ready(7)), 7);
assert_close(1.001, 1.0, 0.01);
assert_bytes_eq(&decode_hex("00 ff 2A").unwrap(), &[0, 255, 42]);
assert!(decode_hex("é").is_err());