rust/test/std.rs

46 lines
926 B
Rust
Raw Normal View History

2016-03-21 05:18:30 -05:00
#![feature(custom_attribute, box_syntax)]
#![allow(dead_code, unused_attributes)]
2016-04-06 05:20:35 -05:00
use std::cell::{Cell, RefCell};
use std::rc::Rc;
use std::sync::Arc;
2016-03-21 05:18:30 -05:00
#[miri_run]
2016-04-06 05:20:35 -05:00
fn rc_cell() -> Rc<Cell<i32>> {
2016-03-21 05:18:30 -05:00
let r = Rc::new(Cell::new(42));
let x = r.get();
r.set(x + x);
2016-04-06 05:20:35 -05:00
r
2016-03-21 05:18:30 -05:00
}
2016-03-21 19:53:39 -05:00
// TODO(tsion): borrow code needs to evaluate string statics via Lvalue::Static
2016-04-06 05:20:35 -05:00
// TODO(tsion): also requires destructors to run for the second borrow to work
2016-03-21 19:53:39 -05:00
// #[miri_run]
// fn rc_refcell() -> i32 {
// let r = Rc::new(RefCell::new(42));
// *r.borrow_mut() += 10;
// let x = *r.borrow();
// x
// }
2016-03-21 05:18:30 -05:00
#[miri_run]
2016-04-06 05:20:35 -05:00
fn arc() -> Arc<i32> {
2016-03-21 05:18:30 -05:00
let a = Arc::new(42);
2016-04-06 05:20:35 -05:00
a
}
struct Loop(Rc<RefCell<Option<Loop>>>);
#[miri_run]
fn rc_reference_cycle() -> Loop {
let a = Rc::new(RefCell::new(None));
let b = a.clone();
*a.borrow_mut() = Some(Loop(b));
Loop(a)
2016-03-21 05:18:30 -05:00
}
2016-03-21 05:37:28 -05:00
#[miri_run]
fn true_assert() {
assert_eq!(1, 1);
}