ttvm 0.1.7

Runtime and compiler infrastructure for Rust
Documentation
pub mod mem;
pub mod byte;

pub use mem::*;
pub use byte::*;

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_mem() {
        fn test_new() {
            let mut mem = Mem::new(5);

            match mem.get(2) {
                Some(some) => assert_eq!(*some, 0x0),
                None => panic!("value of index (1) is 'None'")
            };

            *match mem.get_mut(3) {
                Some(some) => some,
                None => panic!("value of index (3) is 'None'")
            } = 0x1;

            match mem.get(3) {
                Some(some) => assert_eq!(*some, 0x1),
                None => panic!("value of index (3) is 'None'")
            };

            assert_eq!(mem.len(), 5);
            assert_eq!(mem.clone_into_vec(), vec![0x0, 0x0, 0x0, 0x1, 0x0]);
        }

        fn test_from() {
            let mut mem = Mem::from(vec![0x0, 0x0, 0x0, 0x0, 0x0]);

            match mem.get(2) {
                Some(some) => assert_eq!(*some, 0x0),
                None => panic!("value of index (1) is 'None'")
            };

            *match mem.get_mut(3) {
                Some(some) => some,
                None => panic!("value of index (3) is 'None'")
            } = 0x1;

            match mem.get(3) {
                Some(some) => assert_eq!(*some, 0x1),
                None => panic!("value of index (3) is 'None'")
            };

            assert_eq!(mem.len(), 5);
            assert_eq!(mem.clone_into_vec(), vec![0x0, 0x0, 0x0, 0x1, 0x0]);
        }

        test_new();
        test_from();
    }
}