Mercurial > python-compiler.rs
comparison src/tests/utils.rs @ 94:e0368bea06a6
Refactor tests a little bit so it's easier to add more.
author | Bastien Orivel <eijebong@bananium.fr> |
---|---|
date | Tue, 14 Jun 2016 18:39:48 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
93:c06d12a81637 | 94:e0368bea06a6 |
---|---|
1 use std::fs::File; | |
2 use std::io::Read; | |
3 | |
4 pub fn read_file(filename: &str) -> String{ | |
5 let mut file = match File::open(filename) { | |
6 Ok(file) => file, | |
7 Err(err) => { | |
8 panic!(format!("Can't find {}: {}", filename, err)); | |
9 } | |
10 }; | |
11 let mut content = String::new(); | |
12 file.read_to_string(&mut content).unwrap(); | |
13 content | |
14 } |