make first behave same way as last: always return list when with number argument (#6616)

* make `first` behave same way as `last`

* better behaviour

* fix tests

* add tests
This commit is contained in:
pwygab
2022-09-29 06:08:17 +08:00
committed by GitHub
parent dd578926c3
commit 32fbcf39cc
12 changed files with 44 additions and 16 deletions

View File

@ -6,7 +6,7 @@ use nu_test_support::{nu, pipeline};
fn table_to_csv_text_and_from_csv_text_back_into_table() {
let actual = nu!(
cwd: "tests/fixtures/formats",
"open caco3_plastics.csv | to csv | from csv | first 1 | get origin "
"open caco3_plastics.csv | to csv | from csv | first | get origin "
);
assert_eq!(actual.out, "SPAIN");

View File

@ -6,7 +6,7 @@ use nu_test_support::{nu, pipeline};
fn table_to_tsv_text_and_from_tsv_text_back_into_table() {
let actual = nu!(
cwd: "tests/fixtures/formats",
"open caco3_plastics.tsv | to tsv | from tsv | first 1 | get origin"
"open caco3_plastics.tsv | to tsv | from tsv | first | get origin"
);
assert_eq!(actual.out, "SPAIN");
@ -16,7 +16,7 @@ fn table_to_tsv_text_and_from_tsv_text_back_into_table() {
fn table_to_tsv_text_and_from_tsv_text_back_into_table_using_csv_separator() {
let actual = nu!(
cwd: "tests/fixtures/formats",
r"open caco3_plastics.tsv | to tsv | from csv --separator '\t' | first 1 | get origin"
r"open caco3_plastics.tsv | to tsv | from csv --separator '\t' | first | get origin"
);
assert_eq!(actual.out, "SPAIN");