aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorIvan Tham <[email protected]>2022-01-05 04:01:48 +0000
committerGitHub <[email protected]>2022-01-05 04:01:48 +0000
commit9fa2823b3916184dbfbb9c704ab34ae79c0c1038 (patch)
tree597a3ac1bad860fa62737faa58aeb71184c249be /src/main.rs
parent3f52f6f2ce8408350fcdc180d416e63dd627d93f (diff)
parent3f0f8d9f0f910b4c9477297049d4a508eacc3734 (diff)
Merge pull request #51 from Ma27/exp-and-round
Add functions `exp()`, `exp2()` & `round()`; fix minor readline issues
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 75c33bb..e6a865e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -259,4 +259,35 @@ mod tests {
259 let evaled = eval_math_expression("9 + _ ", Some(0f64)).unwrap(); 259 let evaled = eval_math_expression("9 + _ ", Some(0f64)).unwrap();
260 assert_eq!(9., evaled); 260 assert_eq!(9., evaled);
261 } 261 }
262 #[test]
263 fn eval_const_multiplication() {
264 let evaled = eval_math_expression("e2", None).unwrap();
265 assert_eq!(5.4365636569, evaled);
266 }
267 #[test]
268 fn eval_round() {
269 let evaled = eval_math_expression("round(0.5)+round(2.4)", None).unwrap();
270 assert_eq!(3., evaled);
271 }
272 #[test]
273 fn eval_exp2() {
274 assert_eq!(
275 256.,
276 eval_math_expression("exp2(8)", None).unwrap()
277 );
278 }
279 #[test]
280 fn eval_exp() {
281 assert_eq!(
282 20.0855369232 as f64,
283 eval_math_expression("exp(3)", None).unwrap()
284 );
285 }
286 #[test]
287 fn eval_e_times_n() {
288 assert_eq!(
289 0. as f64,
290 eval_math_expression("e0", None).unwrap()
291 );
292 }
262} 293}