box.rs 572 B

12345678910111213141516171819202122232425262728293031
  1. extern crate ralloc;
  2. mod util;
  3. #[inline(never)]
  4. fn alloc_box() -> Box<u32> {
  5. Box::new(0xDEADBEAF)
  6. }
  7. #[test]
  8. fn simple_box() {
  9. util::multiply(|| {
  10. let mut a = Box::new(1);
  11. let mut b = Box::new(2);
  12. let mut c = Box::new(3);
  13. assert_eq!(*a, 1);
  14. assert_eq!(*b, 2);
  15. assert_eq!(*c, 3);
  16. assert_eq!(*alloc_box(), 0xDEADBEAF);
  17. util::acid(|| {
  18. *a = 0;
  19. *b = 0;
  20. *c = 0;
  21. });
  22. assert_eq!(*a, 0);
  23. assert_eq!(*b, 0);
  24. assert_eq!(*c, 0);
  25. });
  26. }