Fix input and output of substances being backwards

This commit is contained in:
Tiffany Bennett 2016-10-14 18:48:45 -04:00
parent 7c8fa3dc1d
commit 55e9ab9f8d
3 changed files with 12 additions and 12 deletions

View file

@ -368,7 +368,7 @@ pub fn parse(mut iter: &mut Iter) -> Defs {
break
},
};
let input_name = match iter.next().unwrap() {
let output_name = match iter.next().unwrap() {
Token::Ident(ref s) if s == "const" => {
let input_name = match iter.next().unwrap() {
Token::Ident(name) => name,
@ -395,7 +395,7 @@ pub fn parse(mut iter: &mut Iter) -> Defs {
break
},
};
let input = parse_mul(iter);
let output = parse_mul(iter);
match iter.next().unwrap() {
Token::Slash => (),
x => {
@ -403,14 +403,14 @@ pub fn parse(mut iter: &mut Iter) -> Defs {
break
}
}
let output_name = match iter.next().unwrap() {
let input_name = match iter.next().unwrap() {
Token::Ident(name) => name,
x => {
println!("Expected property input name, got {:?}", x);
break
},
};
let output = parse_mul(iter);
let input = parse_mul(iter);
props.push(Property {
name: name,
input: input,

View file

@ -377,18 +377,18 @@ impl<'a, 'b> Add<&'b Substance> for &'a Substance {
prop1.output_name != prop2.output_name ||
prop1.input.unit != prop2.input.unit ||
prop1.output.unit != prop2.output.unit ||
prop1.output != mol ||
prop2.output != mol
prop1.input != mol ||
prop2.input != mol
{
return None
}
Some((k.clone(), Property {
input: (
&(&self.amount * &prop1.input).unwrap() +
&(&other.amount * &prop2.input).unwrap()
output: (
&(&self.amount * &prop1.output).unwrap() +
&(&other.amount * &prop2.output).unwrap()
).expect("Add"),
input_name: prop1.input_name.clone(),
output: mol,
input: mol,
output_name: prop1.output_name.clone(),
doc: None,
}))

View file

@ -163,7 +163,7 @@ fn test_typos() {
#[test]
fn test_convert_from_substances() {
test("density of water",
"0.001 meter^3 / kilogram (specific_volume)");
"1000 kilogram / meter^3 (density)");
test("mass of ml water",
"1 gram (mass)");
test("volume of g water",
@ -191,7 +191,7 @@ fn test_convert_to_substances() {
fn test_substance_add() {
test("air",
"air: Average molecular weight of air. \
molar_mass = approx. 28.96790 gram -> 1 mole");
molar_mass = 1 mole -> approx. 28.96790 gram");
}
#[test]