Fix boolean tests and clean up code.

This commit is contained in:
Scott Olson 2016-03-17 06:39:29 -06:00
parent 0a8491b985
commit 6477a5c694
2 changed files with 5 additions and 5 deletions

View file

@ -210,9 +210,7 @@ impl Memory {
}
pub fn write_bool(&mut self, ptr: Pointer, b: bool) -> EvalResult<()> {
let bytes = try!(self.get_bytes_mut(ptr, 1));
bytes[0] = b as u8;
Ok(())
self.get_bytes_mut(ptr, 1).map(|bytes| bytes[0] = b as u8)
}
pub fn read_int(&self, ptr: Pointer, size: usize) -> EvalResult<i64> {

View file

@ -8,12 +8,14 @@ fn boolean() -> bool {
#[miri_run]
fn if_false() -> i64 {
if false { 1 } else { 0 }
let c = false;
if c { 1 } else { 0 }
}
#[miri_run]
fn if_true() -> i64 {
if true { 1 } else { 0 }
let c = true;
if c { 1 } else { 0 }
}
#[miri_run]