terrified to start testing
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
use std::num::NonZero;
|
||||
use std::rc::Rc;
|
||||
|
||||
use orchid_base::{is, mk_errv};
|
||||
use orchid_extension::ForeignAtom;
|
||||
use orchid_extension::expr::Expr;
|
||||
use orchid_extension::func_atom::get_arg;
|
||||
use orchid_extension::gen_expr::new_atom;
|
||||
use orchid_extension::stream_reqs::ReadLimit;
|
||||
use orchid_extension::gen_expr::{call, new_atom};
|
||||
use orchid_extension::std_reqs::ReadLimit;
|
||||
use orchid_extension::tree::{GenMember, comments, fun, prefix};
|
||||
use orchid_extension::{Expr, ForeignAtom, get_arg};
|
||||
|
||||
use crate::Int;
|
||||
use crate::std::binary::binary_atom::BlobAtom;
|
||||
use crate::std::stream::stream_cmds::ReadStreamCmd;
|
||||
|
||||
pub fn gen_stream_lib() -> Vec<GenMember> {
|
||||
@@ -30,7 +32,16 @@ pub fn gen_stream_lib() -> Vec<GenMember> {
|
||||
Ok(new_atom(ReadStreamCmd { hand, succ, fail, limit: ReadLimit::Delimiter(end) }))
|
||||
}),
|
||||
fun(true, "read_bytes", async |hand: ForeignAtom, count: Int, succ: Expr, fail: Expr| {
|
||||
Int(todo!())
|
||||
match count.0.try_into().map(NonZero::new) {
|
||||
Ok(Some(nzlen)) =>
|
||||
Ok(new_atom(ReadStreamCmd { hand, succ, fail, limit: ReadLimit::Length(nzlen) })),
|
||||
Ok(None) => Ok(call(succ, new_atom(BlobAtom(Rc::default()))).await),
|
||||
Err(_) => Err(mk_errv(
|
||||
is("Length cannot be negative").await,
|
||||
format!("{} is negative and cannot be used as a length", count.0),
|
||||
[get_arg(1).pos().await],
|
||||
)),
|
||||
}
|
||||
}),
|
||||
]),
|
||||
)])
|
||||
|
||||
Reference in New Issue
Block a user