Compare commits
2 Commits
80f4556786
...
06c78ddf4d
Author | SHA1 | Date |
---|---|---|
~karx | 06c78ddf4d | |
~karx | 154cac779a |
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
27
src/main.rs
27
src/main.rs
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue