Commit 1b750c3f authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

Update compilation tests to account for the new `mut` changes

parent df62aeed57b8
//! Compilation tests: they only test if the compilation fails, not the
//! macro output
use log;
use micro_timer::timed;
#[test]
fn check_name_conflict() {
#[timed]
fn thing(_value: usize) -> usize {
let timer = 10;
timer
}
assert_eq!(thing(1), 10 as usize);
}
#[test]
fn test_mut() {
#[timed]
fn thing(mut value: usize) {
value = 5;
}
thing(1);
}
#[test]
fn test_ref_mut() {
#[timed]
fn thing(value: &mut String) {
value.push('a');
}
let mut a = String::new();
thing(&mut a);
assert_eq!("a", a);
}
#[test]
fn test_fn_mut() {
#[timed]
fn thing(value: &mut String) {
value.push('a');
}
let mut a = String::new();
thing(&mut a);
assert_eq!("a", a);
}
#[test]
fn test_mut_struct() {
#[timed]
fn thing(value: Thing) -> &mut String {
value.value
}
let mut s = String::new();
struct Thing<'a> {
value: &'a mut String,
}
thing(Thing { value: &mut s });
}
#[test]
fn test_mut_pointer() {
#[timed]
fn thing(value: *mut u8) {
unsafe { *value != 0u8 };
}
let mut s = String::new();
thing(s.as_mut_ptr());
}
use log;
use micro_timer::timed;
use std::time::Duration;
#[test]
fn check() {
#[timed]
fn thing(_value: usize) -> usize {
let timer = 10;
std::thread::sleep(Duration::from_millis(10));
timer
}
assert_eq!(thing(1), 10 as usize);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment