rust/tests/run-pass/std.rs

42 lines
804 B
Rust
Raw Normal View History

2016-03-21 05:18:30 -05:00
#![feature(custom_attribute, box_syntax)]
#![allow(dead_code, unused_attributes)]
use std::cell::Cell;
2016-04-06 05:20:35 -05:00
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
}
2016-03-21 05:37:28 -05:00
#[miri_run]
fn true_assert() {
assert_eq!(1, 1);
}
2016-04-22 03:34:14 -05:00
2016-04-22 07:38:46 -05:00
#[miri_run]
fn main() {
assert_eq!(*arc(), 42);
assert_eq!(rc_cell().get(), 84);
}