Fixed parser documentation and interpreter units tests.

This commit is contained in:
PaddiM8 2020-06-18 17:06:21 +02:00
parent 47d5a2bee2
commit 2413ad080f
2 changed files with 4 additions and 3 deletions

View File

@ -438,7 +438,7 @@ mod tests {
symbol_table.insert(var_decl("x", literal("1")));
let mut context = Context::new(&mut symbol_table, "rad", PRECISION);
assert_eq!(context.interpret(vec![stmt]).unwrap().unwrap(), 1);
assert_eq!(context.interpret(vec![stmt]).unwrap().unwrap().0, 1);
}
#[test]
@ -475,7 +475,7 @@ mod tests {
));
let mut context = Context::new(&mut symbol_table, "rad", PRECISION);
assert_eq!(context.interpret(vec![stmt]).unwrap().unwrap(), 3);
assert_eq!(context.interpret(vec![stmt]).unwrap().unwrap().0, 3);
}
#[test]

View File

@ -15,7 +15,8 @@ pub const DEFAULT_ANGLE_UNIT: &'static str = "rad";
/// use kalk::parser;
/// let mut parser_context = parser::Context::new();
/// let precision = 53;
/// assert_eq!(parser::eval(&mut parser_context, "5*3", precision).unwrap().unwrap(), 15);
/// let (result, unit) = parser::eval(&mut parser_context, "5*3", precision).unwrap().unwrap();
/// assert_eq!(result, 15);
/// ```
pub struct Context {
tokens: Vec<Token>,