output: remove view; group tests

This commit is contained in:
🪞👃🪞 2025-05-21 14:10:53 +03:00
parent daef8dfa9e
commit a4a1066f18
4 changed files with 237 additions and 135 deletions

View file

@ -1,63 +1,15 @@
#![feature(step_trait)]
#![feature(type_alias_impl_trait)]
#![feature(impl_trait_in_assoc_type)]
//#![feature(impl_trait_in_fn_trait_return)]
pub(crate) use tengri_core::*;
pub(crate) use std::marker::PhantomData;
#[cfg(feature = "dsl")] pub(crate) use ::tengri_dsl::*;
mod space; pub use self::space::*;
mod ops; pub use self::ops::*;
mod output; pub use self::output::*;
pub(crate) use tengri_core::*;
pub(crate) use std::marker::PhantomData;
#[cfg(feature = "dsl")] pub(crate) use ::tengri_dsl::*;
#[cfg(feature = "dsl")] mod view;
#[cfg(feature = "dsl")] pub use self::view::*;
#[cfg(test)] use proptest_derive::Arbitrary;
#[cfg(test)] #[test] fn test_stub_output () -> Usually<()> {
use crate::*;
struct TestOutput([u16;4]);
impl Output for TestOutput {
type Unit = u16;
type Size = [u16;2];
type Area = [u16;4];
fn area (&self) -> [u16;4] {
self.0
}
fn area_mut (&mut self) -> &mut [u16;4] {
&mut self.0
}
fn place (&mut self, _: [u16;4], _: &impl Render<TestOutput>) {
()
}
}
impl Content<TestOutput> for String {
fn render (&self, to: &mut TestOutput) {
to.area_mut().set_w(self.len() as u16);
}
}
Ok(())
}
#[cfg(test)] #[test] fn test_space () {
use crate::*;
assert_eq!(Area::center(&[10u16, 10, 20, 20]), [20, 20]);
}
#[cfg(test)] #[test] fn test_iter_map () {
struct Foo;
impl<T: Output> Content<T> for Foo {}
fn make_map <T: Output, U: Content<T> + Send + Sync> (data: &Vec<U>) -> impl Content<T> {
Map::new(||data.iter(), |foo, index|{})
}
let data = vec![Foo, Foo, Foo];
//let map = make_map(&data);
}
#[cfg(test)] mod test {
use crate::*;
use proptest_derive::Arbitrary;
use proptest::{prelude::*, option::of};
proptest! {
@ -187,4 +139,44 @@ pub(crate) use std::marker::PhantomData;
}
}
#[test] fn test_stub_output () -> Usually<()> {
use crate::*;
struct TestOutput([u16;4]);
impl Output for TestOutput {
type Unit = u16;
type Size = [u16;2];
type Area = [u16;4];
fn area (&self) -> [u16;4] {
self.0
}
fn area_mut (&mut self) -> &mut [u16;4] {
&mut self.0
}
fn place (&mut self, _: [u16;4], _: &impl Render<TestOutput>) {
()
}
}
impl Content<TestOutput> for String {
fn render (&self, to: &mut TestOutput) {
to.area_mut().set_w(self.len() as u16);
}
}
Ok(())
}
#[test] fn test_space () {
use crate::*;
assert_eq!(Area::center(&[10u16, 10, 20, 20]), [20, 20]);
}
#[test] fn test_iter_map () {
struct Foo;
impl<T: Output> Content<T> for Foo {}
fn make_map <T: Output, U: Content<T> + Send + Sync> (data: &Vec<U>) -> impl Content<T> {
Map::new(||data.iter(), |foo, index|{})
}
let data = vec![Foo, Foo, Foo];
//let map = make_map(&data);
}
}