Rename count to length (#3166)

* update docs to refer to length instead of count

* rename count to length

* change all occurrences of 'count' to 'length' in tests

* format length command
This commit is contained in:
John-Goff
2021-03-13 16:46:40 -05:00
committed by GitHub
parent 6cf8df8685
commit c13fe83784
38 changed files with 109 additions and 107 deletions

View File

@ -33,7 +33,7 @@ fn cal_friday_the_thirteenths_in_2015() {
let actual = nu!(
cwd: ".", pipeline(
r#"
cal --full-year 2015 | default friday 0 | where friday == 13 | count
cal --full-year 2015 | default friday 0 | where friday == 13 | length
"#
));
@ -45,7 +45,7 @@ fn cal_rows_in_2020() {
let actual = nu!(
cwd: ".", pipeline(
r#"
cal --full-year 2020 | count
cal --full-year 2020 | length
"#
));

View File

@ -25,7 +25,7 @@ fn discards_rows_where_given_column_is_empty() {
open los_tres_amigos.json
| get amigos
| compact rusty_luck
| count
| length
"#
));
@ -41,7 +41,7 @@ fn discards_empty_rows_by_default() {
echo "[1,2,3,14,null]"
| from json
| compact
| count
| length
"#
));

View File

@ -26,7 +26,7 @@ fn adds_row_data_if_column_missing() {
| get amigos
| default rusty_luck 1
| where rusty_luck == 1
| count
| length
"#
));

View File

@ -13,7 +13,7 @@ fn columns() {
]
| drop column
| get
| count
| length
"#)
);
@ -62,7 +62,7 @@ fn rows() {
#[test]
fn more_rows_than_table_has() {
let actual = nu!(cwd: ".", "date | drop 50 | count");
let actual = nu!(cwd: ".", "date | drop 50 | length");
assert_eq!(actual.out, "0");
}

View File

@ -13,7 +13,7 @@ fn reports_emptiness() {
| get are_empty
| empty? check
| where check
| count
| length
"#
));

View File

@ -17,7 +17,7 @@ fn gets_first_rows_by_amount() {
r#"
ls
| first 3
| count
| length
"#
));
@ -40,7 +40,7 @@ fn gets_all_rows_if_amount_higher_than_all_rows() {
r#"
ls
| first 99
| count
| length
"#
));
@ -58,7 +58,7 @@ fn gets_first_row_when_no_amount_given() {
r#"
ls
| first
| count
| length
"#
));

View File

@ -71,7 +71,7 @@ fn flatten_row_column_explicitly() {
let actual = nu!(
cwd: dirs.test(),
"open katz.json | flatten people | where name == Andres | count"
"open katz.json | flatten people | where name == Andres | length"
);
assert_eq!(actual.out, "1");
@ -105,7 +105,7 @@ fn flatten_row_columns_having_same_column_names_flats_separately() {
let actual = nu!(
cwd: dirs.test(),
"open katz.json | flatten | flatten people city | get city_name | count"
"open katz.json | flatten | flatten people city | get city_name | length"
);
assert_eq!(actual.out, "4");
@ -139,7 +139,7 @@ fn flatten_table_columns_explicitly() {
let actual = nu!(
cwd: dirs.test(),
"open katz.json | flatten city | where people.name == Katz | count"
"open katz.json | flatten city | where people.name == Katz | length"
);
assert_eq!(actual.out, "2");

View File

@ -89,7 +89,7 @@ fn column_paths_are_either_double_quoted_or_regular_unquoted_words_separated_by_
r#"
open sample.toml
| get package."9999"
| count
| length
"#
));

View File

@ -21,7 +21,7 @@ fn groups() {
open los_tres_caballeros.csv
| group-by rusty_at
| get "10/11/2013"
| count
| length
"#
));

View File

@ -1,11 +1,11 @@
use nu_test_support::{nu, pipeline};
#[test]
fn help_commands_count() {
fn help_commands_length() {
let actual = nu!(
cwd: ".", pipeline(
r#"
help commands | count
help commands | length
"#
));
@ -16,11 +16,11 @@ fn help_commands_count() {
}
#[test]
fn help_generate_docs_count() {
fn help_generate_docs_length() {
let actual = nu!(
cwd: ".", pipeline(
r#"
help generate_docs | flatten | count
help generate_docs | flatten | length
"#
));

View File

@ -27,7 +27,7 @@ fn gets_last_rows_by_amount() {
r#"
ls
| last 3
| count
| length
"#
));
@ -45,7 +45,7 @@ fn gets_last_row_when_no_amount_given() {
r#"
ls
| last
| count
| length
"#
));
@ -58,7 +58,7 @@ fn requests_more_rows_than_table_has() {
let actual = nu!(
cwd: ".", pipeline(
r#"
date | last 50 | count
date | last 50 | length
"#
));

View File

@ -1,11 +1,11 @@
use nu_test_support::{nu, pipeline};
#[test]
fn count_columns_in_cal_table() {
fn length_columns_in_cal_table() {
let actual = nu!(
cwd: ".", pipeline(
r#"
cal | count -c
cal | length -c
"#
));
@ -13,11 +13,11 @@ fn count_columns_in_cal_table() {
}
#[test]
fn count_columns_no_rows() {
fn length_columns_no_rows() {
let actual = nu!(
cwd: ".", pipeline(
r#"
echo [] | count -c
echo [] | length -c
"#
));

View File

@ -42,7 +42,7 @@ fn lines_multi_value_split() {
open sample-simple.json
| get first second
| lines
| count
| length
"#
));

View File

@ -15,7 +15,7 @@ fn lists_regular_files() {
cwd: dirs.test(), pipeline(
r#"
ls
| count
| length
"#
));
@ -37,7 +37,7 @@ fn lists_regular_files_using_asterisk_wildcard() {
cwd: dirs.test(), pipeline(
r#"
ls *.txt
| count
| length
"#
));
@ -59,7 +59,7 @@ fn lists_regular_files_using_question_mark_wildcard() {
cwd: dirs.test(), pipeline(
r#"
ls *.??.txt
| count
| length
"#
));
@ -88,7 +88,7 @@ fn lists_all_files_in_directories_from_stream() {
r#"
echo dir_a dir_b
| each { ls $it }
| count
| length
"#
));
@ -105,7 +105,7 @@ fn does_not_fail_if_glob_matches_empty_directory() {
cwd: dirs.test(), pipeline(
r#"
ls dir_a
| count
| length
"#
));
@ -142,7 +142,7 @@ fn list_files_from_two_parents_up_using_multiple_dots() {
let actual = nu!(
cwd: dirs.test().join("foo/bar"),
r#"
ls ... | count
ls ... | length
"#
);
@ -165,7 +165,7 @@ fn lists_hidden_file_when_explicitly_specified() {
cwd: dirs.test(), pipeline(
r#"
ls .testdotfile
| count
| length
"#
));
@ -199,7 +199,7 @@ fn lists_all_hidden_files_when_glob_contains_dot() {
cwd: dirs.test(), pipeline(
r#"
ls **/.*
| count
| length
"#
));
@ -236,7 +236,7 @@ fn lists_all_hidden_files_when_glob_does_not_contain_dot() {
cwd: dirs.test(), pipeline(
r#"
ls **/*
| count
| length
"#
));
@ -259,7 +259,7 @@ fn lists_files_including_starting_with_dot() {
cwd: dirs.test(), pipeline(
r#"
ls -a
| count
| length
"#
));

View File

@ -70,7 +70,7 @@ fn show_created_paths() {
pipeline(
r#"
mkdir -s dir_1 dir_2 dir_3
| count
| length
"#
));

View File

@ -5,7 +5,6 @@ mod autoenv_untrust;
mod cal;
mod cd;
mod compact;
mod count;
mod cp;
mod def;
mod default;
@ -28,6 +27,7 @@ mod insert;
mod into_int;
mod keep;
mod last;
mod length;
mod lines;
mod ls;
mod math;

View File

@ -28,7 +28,7 @@ fn selects_many_rows() {
ls
| get name
| nth 1 0
| count
| length
"#
));

View File

@ -5,7 +5,7 @@ fn rolls_4_roll() {
let actual = nu!(
cwd: ".", pipeline(
r#"
random dice -d 4 -s 10 | count
random dice -d 4 -s 10 | length
"#
));

View File

@ -36,7 +36,7 @@ fn selects_some_rows() {
ls
| get name
| range 1..2
| count
| length
"#
));

View File

@ -23,7 +23,7 @@ fn changes_the_column_name() {
| wrap name
| rename mosqueteros
| get mosqueteros
| count
| length
"#
));
@ -53,7 +53,7 @@ fn keeps_remaining_original_names_given_less_new_names_than_total_original_names
| default hit "arepa!"
| rename mosqueteros
| get hit
| count
| length
"#
));

View File

@ -76,7 +76,7 @@ fn allows_if_given_unknown_column_name_is_missing() {
[Yehuda Katz 10/11/2013 A]
]
| select rrusty_at first_name
| count
| length
"#
));

View File

@ -22,7 +22,7 @@ fn splits() {
| group-by rusty_at
| split-by type
| get A."10/11/2013"
| count
| length
"#
));

View File

@ -19,7 +19,7 @@ fn to_row() {
| lines
| str trim
| split row ","
| count
| length
"#
));

View File

@ -22,7 +22,7 @@ fn removes_duplicate_rows() {
r#"
open los_tres_caballeros.csv
| uniq
| count
| length
"#
));
@ -52,7 +52,7 @@ fn uniq_values() {
open los_tres_caballeros.csv
| select type
| uniq
| count
| length
"#
));
@ -117,7 +117,7 @@ fn nested_json_structures() {
r#"
open nested_json_structures.json
| uniq
| count
| length
"#
));
@ -133,7 +133,7 @@ fn uniq_when_keys_out_of_order() {
echo '[{"a": "a", "b": [1,2,3]},{"b": [1,2,3], "a": "a"}]'
| from json
| uniq
| count
| length
"#
));

View File

@ -145,7 +145,7 @@ fn contains_operator() {
| where table_name == strings
| get table_values
| where x =~ ell
| count
| length
"#
));
@ -158,7 +158,7 @@ fn contains_operator() {
| where table_name == strings
| get table_values
| where x !~ ell
| count
| length
"#
));

View File

@ -44,11 +44,11 @@ fn correct_precedence_alias_def_custom() {
fn multiple_reports_for_alias_def_custom() {
let actual = nu!(
cwd: ".",
"def ls [] {echo def}; alias ls = echo alias; which -a ls | count"
"def ls [] {echo def}; alias ls = echo alias; which -a ls | length"
);
let count: i32 = actual.out.parse().unwrap();
assert!(count >= 3);
let length: i32 = actual.out.parse().unwrap();
assert!(length >= 3);
}
// `get_aliases_with_name` and `get_custom_commands_with_name` don't return the correct count of
@ -61,11 +61,11 @@ fn multiple_reports_for_alias_def_custom() {
fn multiple_reports_of_multiple_alias() {
let actual = nu!(
cwd: ".",
"alias xaz = echo alias1; def helper [] {alias xaz = echo alias2; which -a xaz}; helper | count"
"alias xaz = echo alias1; def helper [] {alias xaz = echo alias2; which -a xaz}; helper | length"
);
let count: i32 = actual.out.parse().unwrap();
assert_eq!(count, 2);
let length: i32 = actual.out.parse().unwrap();
assert_eq!(length, 2);
}
#[ignore]
@ -73,11 +73,11 @@ fn multiple_reports_of_multiple_alias() {
fn multiple_reports_of_multiple_defs() {
let actual = nu!(
cwd: ".",
"def xaz [] {echo def1}; def helper [] { def xaz [] { echo def2 }; which -a xaz }; helper | count"
"def xaz [] {echo def1}; def helper [] { def xaz [] { echo def2 }; which -a xaz }; helper | length"
);
let count: i32 = actual.out.parse().unwrap();
assert_eq!(count, 2);
let length: i32 = actual.out.parse().unwrap();
assert_eq!(length, 2);
}
//Fails due to ParserScope::add_definition
@ -88,9 +88,9 @@ fn multiple_reports_of_multiple_defs() {
fn def_only_seen_once() {
let actual = nu!(
cwd: ".",
"def xaz [] {echo def1}; which -a xaz | count"
"def xaz [] {echo def1}; which -a xaz | length"
);
//count is 2. One custom_command (def) one built in ("wrongly" added)
let count: i32 = actual.out.parse().unwrap();
assert_eq!(count, 1);
//length is 2. One custom_command (def) one built in ("wrongly" added)
let length: i32 = actual.out.parse().unwrap();
assert_eq!(length, 1);
}

View File

@ -93,7 +93,7 @@ fn infers_types() {
r#"
open los_cuatro_mosqueteros.csv
| where rusty_luck > 0
| count
| length
"#
));
@ -120,7 +120,7 @@ fn from_csv_text_to_table() {
open los_tres_caballeros.txt
| from csv
| get rusty_luck
| count
| length
"#
));
@ -147,7 +147,7 @@ fn from_csv_text_with_separator_to_table() {
open los_tres_caballeros.txt
| from csv --separator ';'
| get rusty_luck
| count
| length
"#
));
@ -174,7 +174,7 @@ fn from_csv_text_with_tab_separator_to_table() {
open los_tres_caballeros.txt
| from csv --separator '\t'
| get rusty_luck
| count
| length
"#
));
@ -200,7 +200,7 @@ fn from_csv_text_skipping_headers_to_table() {
open los_tres_amigos.txt
| from csv --noheaders
| get Column3
| count
| length
"#
));

View File

@ -48,7 +48,7 @@ fn infers_types() {
r#"
open calendar.ics
| get events
| count
| length
"#
));

View File

@ -36,7 +36,7 @@ fn from_json_text_to_table() {
let actual = nu!(
cwd: dirs.test(),
"open katz.txt | from json | get katz | get rusty_luck | count "
"open katz.txt | from json | get katz | get rusty_luck | length "
);
assert_eq!(actual.out, "4");

View File

@ -97,7 +97,7 @@ fn from_tsv_text_to_table() {
open los_tres_amigos.txt
| from tsv
| get rusty_luck
| count
| length
"#
));
@ -123,7 +123,7 @@ fn from_tsv_text_skipping_headers_to_table() {
open los_tres_amigos.txt
| from tsv --noheaders
| get Column3
| count
| length
"#
));

View File

@ -35,7 +35,7 @@ fn infers_types() {
cwd: dirs.test(), pipeline(
r#"
open contacts.vcf
| count
| length
"#
));