All sorts of test scaffolding works now

This commit is contained in:
2025-02-20 18:06:44 +01:00
parent 9d744550c1
commit 9e7648bc72
41 changed files with 1230 additions and 436 deletions

View File

@@ -2,7 +2,7 @@ use orchid_api_derive::{Coding, Hierarchy};
use crate::ExtHostNotif;
#[derive(Clone, Debug, Coding)]
#[derive(Clone, Debug, Coding, PartialEq, Eq, Hash)]
pub enum LogStrategy {
StdErr,
File(String),

View File

@@ -33,17 +33,22 @@ use crate::{atom, expr, interner, lexer, logging, macros, parser, system, tree,
static HOST_INTRO: &[u8] = b"Orchid host, binary API v0\n";
pub struct HostHeader {
pub log_strategy: logging::LogStrategy,
pub msg_logs: logging::LogStrategy,
}
impl Decode for HostHeader {
async fn decode<R: Read + ?Sized>(mut read: Pin<&mut R>) -> Self {
read_exact(read.as_mut(), HOST_INTRO).await;
Self { log_strategy: logging::LogStrategy::decode(read).await }
Self {
log_strategy: logging::LogStrategy::decode(read.as_mut()).await,
msg_logs: logging::LogStrategy::decode(read.as_mut()).await,
}
}
}
impl Encode for HostHeader {
async fn encode<W: Write + ?Sized>(&self, mut write: Pin<&mut W>) {
write_exact(write.as_mut(), HOST_INTRO).await;
self.log_strategy.encode(write).await
self.log_strategy.encode(write.as_mut()).await;
self.msg_logs.encode(write.as_mut()).await
}
}
@@ -159,7 +164,10 @@ mod tests {
#[test]
fn host_header_enc() {
spin_on(async {
let hh = HostHeader { log_strategy: logging::LogStrategy::File("SomeFile".to_string()) };
let hh = HostHeader {
log_strategy: logging::LogStrategy::File("SomeFile".to_string()),
msg_logs: logging::LogStrategy::File("SomeFile".to_string()),
};
let mut enc = &enc_vec(&hh).await[..];
eprintln!("Encoded to {enc:?}");
HostHeader::decode(Pin::new(&mut enc)).await;

View File

@@ -32,6 +32,8 @@ pub enum Token {
LambdaHead(Vec<TokenTree>),
/// A name segment or an operator.
Name(TStr),
/// An absolute name
Reference(TStrv),
/// ::
NS,
/// Line break.