Compare commits

...

2 Commits

Author SHA1 Message Date
~karx 06c78ddf4d Add drone configuration 2021-02-07 19:48:03 +00:00
~karx 154cac779a Add test suite 2021-02-07 19:35:00 +00:00
3 changed files with 50 additions and 1 deletions

View File

@ -60,7 +60,7 @@ Read [this guide](https://git-send-email.io) for more information.
- [x] Better documentation
- [ ] Ability to explicitly print math output and assign math output to variables
- [x] Add support for comments (should be pretty easy)
- [ ] Unit testing and CI/CD
- [x] Unit testing and CI/CD
## License

22
drone.yml Normal file
View File

@ -0,0 +1,22 @@
kind: pipeline
type: docker
name: rust-latest
steps:
- name: test
image: rust:1.49.0
commands:
- cargo build --verbose
- cargo test --verbose
---
kind: pipeline
type: docker
name: rust-nightly
steps:
- name: test
image: rustlang/rust:nightly
commands:
- cargo build --verbose
- cargo test --verbose

View File

@ -128,3 +128,30 @@ fn main() {
let mut prog = Program::from_string(contents);
prog.run();
}
#[cfg(test)]
mod tests {
use super::*;
fn make_program(contents: &str) -> Program {
Program::from_string(contents.to_string())
}
#[test]
fn test_math() {
assert_eq!(eval::do_math("2-2".to_string(), '+'), 4);
}
#[test]
#[should_panic]
fn test_undefined_opcode() {
make_program("Hello\nWorld!").run();
}
#[test]
#[should_panic]
fn test_undefined_variable() {
make_program("p$v").run();
}
}