Move 'nth' into 'select' (#4385)

This commit is contained in:
JT
2022-02-09 09:59:40 -05:00
committed by GitHub
parent 43850bf20e
commit 5a1d81221f
18 changed files with 190 additions and 259 deletions

View File

@ -1,4 +1,4 @@
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::fs::Stub::{EmptyFile, FileWithContentToBeTrimmed};
use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline};
@ -126,3 +126,41 @@ fn ignores_duplicate_columns_selected() {
assert_eq!(actual.out, "first name last name");
}
#[test]
fn selects_a_row() {
Playground::setup("select_test_1", |dirs, sandbox| {
sandbox.with_files(vec![EmptyFile("notes.txt"), EmptyFile("arepas.txt")]);
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
ls
| sort-by name
| select 0
| get name.0
"#
));
assert_eq!(actual.out, "arepas.txt");
});
}
#[test]
fn selects_many_rows() {
Playground::setup("select_test_2", |dirs, sandbox| {
sandbox.with_files(vec![EmptyFile("notes.txt"), EmptyFile("arepas.txt")]);
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
ls
| get name
| select 1 0
| length
"#
));
assert_eq!(actual.out, "2");
});
}