mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 02:24:58 +02:00
Merged tests to produce a single binary (#12826)
This PR should close #7147 # Description Merged src/tests into /tests to produce a single binary.  # 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>
This commit is contained in:
committed by
GitHub
parent
c70c43aae9
commit
c4dca5fe03
142
tests/repl/test_commandline.rs
Normal file
142
tests/repl/test_commandline.rs
Normal file
@ -0,0 +1,142 @@
|
||||
use crate::repl::tests::{fail_test, run_test, TestResult};
|
||||
|
||||
#[test]
|
||||
fn commandline_test_get_empty() -> TestResult {
|
||||
run_test("commandline", "")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commandline_test_append() -> TestResult {
|
||||
run_test(
|
||||
"commandline edit --replace '0👩❤️👩2'\n\
|
||||
commandline set-cursor 2\n\
|
||||
commandline edit --append 'ab'\n\
|
||||
print (commandline)\n\
|
||||
commandline get-cursor",
|
||||
"0👩❤️👩2ab\n\
|
||||
2",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commandline_test_insert() -> TestResult {
|
||||
run_test(
|
||||
"commandline edit --replace '0👩❤️👩2'\n\
|
||||
commandline set-cursor 2\n\
|
||||
commandline edit --insert 'ab'\n\
|
||||
print (commandline)\n\
|
||||
commandline get-cursor",
|
||||
"0👩❤️👩ab2\n\
|
||||
4",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commandline_test_replace() -> TestResult {
|
||||
run_test(
|
||||
"commandline edit --replace '0👩❤️👩2'\n\
|
||||
commandline edit --replace 'ab'\n\
|
||||
print (commandline)\n\
|
||||
commandline get-cursor",
|
||||
"ab\n\
|
||||
2",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commandline_test_cursor() -> TestResult {
|
||||
run_test(
|
||||
"commandline edit --replace '0👩❤️👩2'\n\
|
||||
commandline set-cursor 1\n\
|
||||
commandline edit --insert 'x'\n\
|
||||
commandline",
|
||||
"0x👩❤️👩2",
|
||||
)?;
|
||||
run_test(
|
||||
"commandline edit --replace '0👩❤️👩2'\n\
|
||||
commandline set-cursor 2\n\
|
||||
commandline edit --insert 'x'\n\
|
||||
commandline",
|
||||
"0👩❤️👩x2",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commandline_test_cursor_show_pos_begin() -> TestResult {
|
||||
run_test(
|
||||
"commandline edit --replace '0👩❤️👩'\n\
|
||||
commandline set-cursor 0\n\
|
||||
commandline get-cursor",
|
||||
"0",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commandline_test_cursor_show_pos_end() -> TestResult {
|
||||
run_test(
|
||||
"commandline edit --replace '0👩❤️👩'\n\
|
||||
commandline set-cursor 2\n\
|
||||
commandline get-cursor",
|
||||
"2",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commandline_test_cursor_show_pos_mid() -> TestResult {
|
||||
run_test(
|
||||
"commandline edit --replace '0👩❤️👩2'\n\
|
||||
commandline set-cursor 1\n\
|
||||
commandline get-cursor",
|
||||
"1",
|
||||
)?;
|
||||
run_test(
|
||||
"commandline edit --replace '0👩❤️👩2'\n\
|
||||
commandline set-cursor 2\n\
|
||||
commandline get-cursor",
|
||||
"2",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commandline_test_cursor_too_small() -> TestResult {
|
||||
run_test(
|
||||
"commandline edit --replace '123456'\n\
|
||||
commandline set-cursor -1\n\
|
||||
commandline edit --insert '0'\n\
|
||||
commandline",
|
||||
"0123456",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commandline_test_cursor_too_large() -> TestResult {
|
||||
run_test(
|
||||
"commandline edit --replace '123456'\n\
|
||||
commandline set-cursor 10\n\
|
||||
commandline edit --insert '0'\n\
|
||||
commandline",
|
||||
"1234560",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commandline_test_cursor_invalid() -> TestResult {
|
||||
fail_test(
|
||||
"commandline edit --replace '123456'\n\
|
||||
commandline set-cursor 'abc'",
|
||||
"expected int",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commandline_test_cursor_end() -> TestResult {
|
||||
run_test(
|
||||
"commandline edit --insert '🤔🤔'; commandline set-cursor --end; commandline get-cursor",
|
||||
"2", // 2 graphemes
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commandline_test_cursor_type() -> TestResult {
|
||||
run_test("commandline get-cursor | describe", "int")
|
||||
}
|
Reference in New Issue
Block a user