Add bool tests · RustPython/RustPython@7b345d0 · GitHub
Skip to content

Commit 7b345d0

Browse files
committed
Add bool tests
1 parent d8875cb commit 7b345d0

4 files changed

Lines changed: 57 additions & 1 deletion

File tree

jit/src/lib.rs

Lines changed: 19 additions & 1 deletion

jit/tests/bool_tests.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#[test]
2+
fn test_return() {
3+
let return_ = jit_function! { return_(a: bool) -> bool => r##"
4+
def return_(a: bool):
5+
return a
6+
"## };
7+
8+
assert_eq!(return_(true), Ok(true));
9+
assert_eq!(return_(false), Ok(false));
10+
}
11+
12+
#[test]
13+
fn test_const() {
14+
let const_true = jit_function! { const_true(a: i64) -> bool => r##"
15+
def const_true(a: int):
16+
return True
17+
"## };
18+
assert_eq!(const_true(0), Ok(true));
19+
20+
let const_false = jit_function! { const_false(a: i64) -> bool => r##"
21+
def const_false(a: int):
22+
return False
23+
"## };
24+
assert_eq!(const_false(0), Ok(false));
25+
}
26+
27+
#[test]
28+
fn test_not() {
29+
let not_ = jit_function! { not_(a: bool) -> bool => r##"
30+
def not_(a: bool):
31+
return not a
32+
"## };
33+
34+
assert_eq!(not_(true), Ok(false));
35+
assert_eq!(not_(false), Ok(true));
36+
}

jit/tests/common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ impl Function {
1818
Some(StackValue::String(annotation)) => match annotation.as_str() {
1919
"int" => JitType::Int,
2020
"float" => JitType::Float,
21+
"bool" => JitType::Bool,
2122
_ => panic!("Unrecognised jit type"),
2223
},
2324
_ => panic!("Argument have annotation"),

jit/tests/lib.rs

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)