MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / growing

Function growing

cranelift/entity/src/list.rs:834–868  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

832
833 #[test]
834 fn growing() {
835 let pool = &mut ListPool::<Inst>::new();
836 let mut list = EntityList::<Inst>::default();
837
838 let i1 = Inst::new(1);
839 let i2 = Inst::new(2);
840 let i3 = Inst::new(3);
841 let i4 = Inst::new(4);
842
843 // This is not supposed to change the list.
844 list.grow_at(0, 0, pool);
845 assert_eq!(list.len(pool), 0);
846 assert!(list.is_empty());
847
848 list.grow_at(0, 2, pool);
849 assert_eq!(list.len(pool), 2);
850
851 list.as_mut_slice(pool).copy_from_slice(&[i2, i3]);
852
853 list.grow_at(1, 0, pool);
854 assert_eq!(list.as_slice(pool), &[i2, i3]);
855
856 list.grow_at(1, 1, pool);
857 list.as_mut_slice(pool)[1] = i1;
858 assert_eq!(list.as_slice(pool), &[i2, i1, i3]);
859
860 // Append nothing at the end.
861 list.grow_at(3, 0, pool);
862 assert_eq!(list.as_slice(pool), &[i2, i1, i3]);
863
864 // Append something at the end.
865 list.grow_at(3, 1, pool);
866 list.as_mut_slice(pool)[3] = i4;
867 assert_eq!(list.as_slice(pool), &[i2, i1, i3, i4]);
868 }
869
870 #[test]
871 fn deep_clone() {

Callers

nothing calls this directly

Calls 4

grow_atMethod · 0.80
newFunction · 0.50
copy_from_sliceMethod · 0.45
as_mut_sliceMethod · 0.45

Tested by

no test coverage detected