Skip to content

Commit e158aaa

Browse files
author
梶塚太智
authored
Merge pull request #19 from rensatopc/main
print version
2 parents 8bd969a + 1c285ec commit e158aaa

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

src/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use sys_info::{cpu_num, cpu_speed, hostname, mem_info, os_release, os_type};
1717
mod test;
1818

1919
fn main() {
20-
let matches = App::new("Stack")
21-
.version("1.12")
20+
let app = App::new("Stack")
21+
.version("1.12.0")
2222
.author("Stack Programming Community")
2323
.about("The powerful script language designed with a stack oriented approach for efficient execution. ")
2424
.arg(Arg::new("script")
@@ -29,7 +29,8 @@ fn main() {
2929
.arg(Arg::new("debug")
3030
.short('d')
3131
.long("debug")
32-
.help("Enables debug mode"))
32+
.help("Enables debug mode"));
33+
let matches = app.clone()
3334
.get_matches();
3435

3536
if let Some(script) = matches.value_of("script") {
@@ -55,6 +56,7 @@ fn main() {
5556
} else {
5657
// Show a title
5758
println!("Stack Programming Language");
59+
println!("Version {}", {app.get_version().unwrap_or("unknown")});
5860
let mut executor = Executor::new(Mode::Debug);
5961
// REPL Execution
6062
loop {

src/test.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,29 @@ fn control_while() {
100100
10f64
101101
);
102102
}
103+
104+
#[test]
105+
fn equal_true() {
106+
let mut executor = Executor::new(Mode::Script);
107+
108+
assert_eq!(
109+
{
110+
executor.evaluate_program("1 1 add 2 equal".to_string());
111+
executor.pop_stack().get_bool()
112+
},
113+
true
114+
);
115+
}
116+
117+
#[test]
118+
fn equal_false() {
119+
let mut executor = Executor::new(Mode::Script);
120+
121+
assert_eq!(
122+
{
123+
executor.evaluate_program("1 1 mul 999 equal".to_string());
124+
executor.pop_stack().get_bool()
125+
},
126+
false
127+
);
128+
}

0 commit comments

Comments
 (0)