diff --git a/crates/types/src/compound/list.rs b/crates/types/src/compound/list.rs index e781c36..68ab8de 100644 --- a/crates/types/src/compound/list.rs +++ b/crates/types/src/compound/list.rs @@ -206,6 +206,49 @@ mod test { use crate::compound::peano::{P1, P2}; use core::cell::Cell; + #[test] + fn test_into_list() { + let list = (5u32, 4i32, 3f32).into_list(); + + assert_eq!(list.get::(), &5u32); + assert_eq!(list.get::(), &4i32); + assert_eq!(list.get::(), &3f32); + } + + #[test] + fn test_list_default() { + let defaulted = List::<(i32, f32, u32)>::default(); + let explicit = (0i32, 0f32, 0u32).into_list(); + + assert!(defaulted == explicit); + } + + #[test] + fn get() { + let list = (5u32, 4i32, 3f32).into_list(); + assert_eq!(list.get::(), &5u32); + assert_eq!(list.get::(), &4i32); + assert_eq!(list.get::(), &3f32); + } + + #[test] + fn set() { + let mut list = List::<(u32, i32, f32)>::default(); + + list.set::(5u32); + + assert_eq!(list.get::(), &5u32); + assert_eq!(list.get::(), &0i32); + assert_eq!(list.get::(), &0f32); + + list.set::(3f32); + list.set::(4i32); + + assert_eq!(list.get::(), &5u32); + assert_eq!(list.get::(), &4i32); + assert_eq!(list.get::(), &3f32); + } + #[derive(Default)] struct ApplyAccumulator { delayed0: Cell, @@ -227,7 +270,7 @@ mod test { #[test] fn test_apply_single() { - let list = Node::new_terminal(5u32); + let list = (5u32,).into_list(); let acc = ApplyAccumulator::default(); list.apply_all(&acc); @@ -272,8 +315,7 @@ mod test { #[test] fn test_apply_2() { - let list = Node::new_terminal(V0(5u32)) - .prepend(V1(4f32)); + let list = (V1(4f32), V0(5u32)).into_list(); let acc = ApplyAccumulator::default(); list.apply_all(&acc); @@ -284,9 +326,7 @@ mod test { #[test] fn test_apply_3() { - let list = Node::new_terminal(V0(5u32)) - .prepend(V1(4f32)) - .prepend(V0(2u32)); + let list = (V0(2u32), V1(4f32), V0(5u32)).into_list(); let acc = ApplyAccumulator::default(); list.apply_all(&acc); @@ -297,9 +337,7 @@ mod test { #[test] fn test_apply_at() { - let list = Node::new_terminal(V0(5u32)) - .prepend(V1(4f32)) - .prepend(V0(2u32)); + let list = (V0(2u32), V1(4f32), V0(5u32)).into_list(); let acc = ApplyAccumulator::default(); list.apply_at(0, &acc); @@ -327,59 +365,10 @@ mod test { } } - let list = Node::new_terminal(V0(5u32)) - .prepend(V1(4f32)) - .prepend(V0(2u32)); + let list = (V0(2u32), V1(4f32), V0(5u32)).into_list(); assert_eq!(list.apply_at(0, ApplyAtRetOp), V0(2u32).to_flat()); assert_eq!(list.apply_at(1, ApplyAtRetOp), V1(4f32).to_flat()); assert_eq!(list.apply_at(2, ApplyAtRetOp), V0(5u32).to_flat()); } - - #[test] - fn get() { - let list = Node::new_terminal(3f32) - .prepend(4i32) - .prepend(5u32); - assert_eq!(list.get::(), &5u32); - assert_eq!(list.get::(), &4i32); - assert_eq!(list.get::(), &3f32); - } - - #[test] - fn set() { - let mut list = List::<(u32, i32, f32)>::default(); - - list.set::(5u32); - - assert_eq!(list.get::(), &5u32); - assert_eq!(list.get::(), &0i32); - assert_eq!(list.get::(), &0f32); - - list.set::(3f32); - list.set::(4i32); - - assert_eq!(list.get::(), &5u32); - assert_eq!(list.get::(), &4i32); - assert_eq!(list.get::(), &3f32); - } - - #[test] - fn test_list_default() { - let type_level = List::<(i32, f32, u32)>::default(); - let value_level = Node::new_terminal(0u32) - .prepend(0f32) - .prepend(0i32); - - assert!(type_level == value_level); - } - - #[test] - fn test_into_list() { - let list = (5u32, 4i32, 3f32).into_list(); - - assert_eq!(list.get::(), &5u32); - assert_eq!(list.get::(), &4i32); - assert_eq!(list.get::(), &3f32); - } }