2024-05-13 13:37:53 +00:00
|
|
|
use crate::repl::tests::{fail_test, run_test, TestResult};
|
2021-12-25 19:39:42 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn int_in_inc_range() -> TestResult {
|
|
|
|
run_test(r#"1 in -4..9.42"#, "true")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn int_in_dec_range() -> TestResult {
|
2024-10-22 15:34:41 +00:00
|
|
|
run_test(r#"1 in 9..-4.42"#, "true")
|
2021-12-25 19:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn int_in_exclusive_range() -> TestResult {
|
|
|
|
run_test(r#"3 in 0..<3"#, "false")
|
|
|
|
}
|
|
|
|
|
2024-10-22 15:34:41 +00:00
|
|
|
#[test]
|
|
|
|
fn float_in_inc_range() -> TestResult {
|
|
|
|
run_test(r#"1.58 in -4.42..9"#, "true")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn float_in_dec_range() -> TestResult {
|
|
|
|
run_test(r#"1.42 in 9.42..-4.42"#, "true")
|
|
|
|
}
|
|
|
|
|
2021-12-25 19:39:42 +00:00
|
|
|
#[test]
|
|
|
|
fn non_number_in_range() -> TestResult {
|
2023-04-07 21:32:44 +00:00
|
|
|
fail_test(r#"'a' in 1..3"#, "subset comparison is not supported")
|
2021-12-25 19:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn float_not_in_inc_range() -> TestResult {
|
|
|
|
run_test(r#"1.4 not-in 2..9.42"#, "true")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn range_and_reduction() -> TestResult {
|
|
|
|
run_test(r#"1..6..36 | math sum"#, "148")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn zip_ranges() -> TestResult {
|
|
|
|
run_test(r#"1..3 | zip 4..6 | get 2.1"#, "6")
|
|
|
|
}
|
2024-10-22 15:34:41 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn int_in_stepped_range() -> TestResult {
|
|
|
|
run_test(r#"7 in 1..3..15"#, "true")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn int_in_unbounded_stepped_range() -> TestResult {
|
|
|
|
run_test(r#"1000001 in 1..3.."#, "true")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn int_not_in_unbounded_stepped_range() -> TestResult {
|
|
|
|
run_test(r#"2 in 1..3.."#, "false")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn float_in_stepped_range() -> TestResult {
|
|
|
|
run_test(r#"5.5 in 1..1.5..10"#, "true")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn float_in_unbounded_stepped_range() -> TestResult {
|
|
|
|
run_test(r#"100.5 in 1..1.5.."#, "true")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn float_not_in_unbounded_stepped_range() -> TestResult {
|
|
|
|
run_test(r#"2.1 in 1.2..3.."#, "false")
|
|
|
|
}
|