mirror of
https://github.com/nushell/nushell.git
synced 2024-12-23 15:39:06 +01:00
c4dca5fe03
This PR should close #7147 # Description Merged src/tests into /tests to produce a single binary. ![image](https://github.com/nushell/nushell/assets/94604837/84726469-d447-4619-b6d1-2d1415d0f42e) # User-Facing Changes No user facing changes # Tests + Formatting Moved tests. Tollkit check pr pass. # After Submitting --------- Co-authored-by: Ian Manske <ian.manske@pm.me>
78 lines
1.5 KiB
Rust
78 lines
1.5 KiB
Rust
use crate::repl::tests::{run_test, TestResult};
|
|
|
|
#[test]
|
|
fn if_test1() -> TestResult {
|
|
run_test("if true { 10 } else { 20 } ", "10")
|
|
}
|
|
|
|
#[test]
|
|
fn if_test2() -> TestResult {
|
|
run_test("if false { 10 } else { 20 } ", "20")
|
|
}
|
|
|
|
#[test]
|
|
fn simple_if() -> TestResult {
|
|
run_test("if true { 10 } ", "10")
|
|
}
|
|
|
|
#[test]
|
|
fn simple_if2() -> TestResult {
|
|
run_test("if false { 10 } ", "")
|
|
}
|
|
|
|
#[test]
|
|
fn if_cond() -> TestResult {
|
|
run_test("if 2 < 3 { 3 } ", "3")
|
|
}
|
|
|
|
#[test]
|
|
fn if_cond2() -> TestResult {
|
|
run_test("if 2 > 3 { 3 } ", "")
|
|
}
|
|
|
|
#[test]
|
|
fn if_cond3() -> TestResult {
|
|
run_test("if 2 < 3 { 5 } else { 4 } ", "5")
|
|
}
|
|
|
|
#[test]
|
|
fn if_cond4() -> TestResult {
|
|
run_test("if 2 > 3 { 5 } else { 4 } ", "4")
|
|
}
|
|
|
|
#[test]
|
|
fn if_elseif1() -> TestResult {
|
|
run_test("if 2 > 3 { 5 } else if 6 < 7 { 4 } ", "4")
|
|
}
|
|
|
|
#[test]
|
|
fn if_elseif2() -> TestResult {
|
|
run_test("if 2 < 3 { 5 } else if 6 < 7 { 4 } else { 8 } ", "5")
|
|
}
|
|
|
|
#[test]
|
|
fn if_elseif3() -> TestResult {
|
|
run_test("if 2 > 3 { 5 } else if 6 > 7 { 4 } else { 8 } ", "8")
|
|
}
|
|
|
|
#[test]
|
|
fn if_elseif4() -> TestResult {
|
|
run_test("if 2 > 3 { 5 } else if 6 < 7 { 4 } else { 8 } ", "4")
|
|
}
|
|
|
|
#[test]
|
|
fn mutation_in_else() -> TestResult {
|
|
run_test(
|
|
"mut x = 100; if 2 > 3 { $x = 200 } else { $x = 300 }; $x ",
|
|
"300",
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn mutation_in_else2() -> TestResult {
|
|
run_test(
|
|
"mut x = 100; if 2 > 3 { $x = 200 } else if true { $x = 400 } else { $x = 300 }; $x ",
|
|
"400",
|
|
)
|
|
}
|