aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorDavid Tolnay <[email protected]>2020-10-12 05:37:15 +0100
committerGitHub <[email protected]>2020-10-12 05:37:15 +0100
commit7118506a2a51a3261087d69a57a1c3f185175829 (patch)
treeb32f4f94a2b4ba7edf1bcc882d17e06da874cc6f /src/main.rs
parentff3ac137eda1f20bbdc339bd758301d3082f6636 (diff)
Accept `**` operator as exponentiation (#39)
* Accept `**` operator as exponentiation * Add test of exponentiation
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 2a2cf9d..bc22ce2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -227,6 +227,11 @@ mod tests {
227 assert_eq!(32., evaled); 227 assert_eq!(32., evaled);
228 } 228 }
229 #[test] 229 #[test]
230 fn exponentiation() {
231 let evaled = eval_math_expression("2 ** 2 ** 3", None).unwrap();
232 assert_eq!(256., evaled); // 2^(2^3), not (2^2)^3
233 }
234 #[test]
230 fn floating_ops() { 235 fn floating_ops() {
231 let evaled = eval_math_expression("1.2816 + 1 + 1.2816/1.2", Some(0f64)).unwrap(); 236 let evaled = eval_math_expression("1.2816 + 1 + 1.2816/1.2", Some(0f64)).unwrap();
232 assert_eq!(3.3496, evaled); 237 assert_eq!(3.3496, evaled);