Fix tests
This commit is contained in:
parent
f9bf69d253
commit
a15c1b4464
|
@ -58,7 +58,7 @@ struct LocalVariable {
|
|||
}
|
||||
|
||||
type LocalCache = @mut HashMap<~str, @~[u8]>;
|
||||
fn tls_key(_k: @LocalCache) {}
|
||||
fn tls_key(_k: LocalCache) {}
|
||||
|
||||
impl Program {
|
||||
pub fn new() -> Program {
|
||||
|
@ -132,7 +132,7 @@ impl Program {
|
|||
");
|
||||
|
||||
let key: sys::Closure = unsafe {
|
||||
let tls_key: &'static fn(@LocalCache) = tls_key;
|
||||
let tls_key: &'static fn(LocalCache) = tls_key;
|
||||
cast::transmute(tls_key)
|
||||
};
|
||||
// First, get a handle to the tls map which stores all the local
|
||||
|
@ -144,7 +144,7 @@ impl Program {
|
|||
let key = ::std::sys::Closure{ code: %? as *(),
|
||||
env: ::std::ptr::null() };
|
||||
let key = ::std::cast::transmute(key);
|
||||
*::std::local_data::get(key, |k| k.map(|&x| *x)).unwrap()
|
||||
::std::local_data::get(key, |k| k.map(|&x| *x)).unwrap()
|
||||
};\n", key.code as uint));
|
||||
|
||||
// Using this __tls_map handle, deserialize each variable binding that
|
||||
|
@ -227,7 +227,7 @@ impl Program {
|
|||
map.insert(copy *name, @copy value.data);
|
||||
}
|
||||
unsafe {
|
||||
local_data::set(tls_key, @map);
|
||||
local_data::set(tls_key, map);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ fn test_tls_pop() {
|
|||
unsafe {
|
||||
fn my_key(_x: @~str) { }
|
||||
set(my_key, @~"weasel");
|
||||
assert!(*(pop(my_key, |k| k.map(|&k| *k)).get()) == ~"weasel");
|
||||
assert!(*(pop(my_key).get()) == ~"weasel");
|
||||
// Pop must remove the data from the map.
|
||||
assert!(pop(my_key).is_none());
|
||||
}
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
// Testing that we can't store a borrowed pointer it task-local storage
|
||||
|
||||
use std::local_data::*;
|
||||
use std::local_data;
|
||||
|
||||
fn key(_x: @&int) { }
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
local_data_set(key, @&0); //~ ERROR does not fulfill `'static`
|
||||
local_data::set(key, @&0); //~ ERROR does not fulfill `'static`
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue