add env var emulation test, and fix it complaining about leaks

This commit is contained in:
Ralf Jung 2018-10-16 12:44:04 +02:00
parent b84f7e2029
commit 348f782085
2 changed files with 18 additions and 0 deletions

View File

@ -215,11 +215,22 @@ pub enum MiriMemoryKind {
}
impl Into<MemoryKind<MiriMemoryKind>> for MiriMemoryKind {
#[inline(always)]
fn into(self) -> MemoryKind<MiriMemoryKind> {
MemoryKind::Machine(self)
}
}
impl MayLeak for MiriMemoryKind {
#[inline(always)]
fn may_leak(self) -> bool {
use MiriMemoryKind::*;
match self {
Rust | C => false,
Env | MutStatic => true,
}
}
}
#[derive(Clone, PartialEq, Eq)]
pub struct Evaluator<'tcx> {

7
tests/run-pass/env.rs Normal file
View File

@ -0,0 +1,7 @@
use std::env;
fn main() {
assert_eq!(env::var("MIRI_TEST"), Err(env::VarError::NotPresent));
env::set_var("MIRI_TEST", "the answer");
assert_eq!(env::var("MIRI_TEST"), Ok("the answer".to_owned()));
}