aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.rs10
-rw-r--r--tests/order-of-operations.tdy9
2 files changed, 19 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index e6265f8..f599011 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -20,5 +20,15 @@ fn run_file(path: &Path) -> Result<(), vm::VMError> {
let block = compiler::compile("main", path, tokens); // path -> str might fail
vm::run_block(block)
}
+
+#[cfg(test)]
+mod tests {
+ use super::run_file;
+ use std::path::Path;
+
+ #[test]
+ fn order_of_operations() {
+ let file = Path::new("tests/order-of-operations.tdy");
+ assert!(run_file(&file).is_ok());
}
}
diff --git a/tests/order-of-operations.tdy b/tests/order-of-operations.tdy
new file mode 100644
index 0000000..f739ccb
--- /dev/null
+++ b/tests/order-of-operations.tdy
@@ -0,0 +1,9 @@
+1 + 1 * 2 <=> 3
+1 * 2 + 3 <=> 5
+5 <=> 1 * 2 + 3
+(1 + 2) * 3 <=> 9
+//-
+-1 + 2 <=> 1
+-(1 + 2) <=> -3
+1 + -1 <=> 0
+2 * -1 <=> -2