mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Remove old nushell/merge engine-q
This commit is contained in:
@ -1,24 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
use nu_test_support::pipeline as input;
|
||||
use nu_test_support::playground::{says, Playground};
|
||||
|
||||
use hamcrest2::assert_that;
|
||||
use hamcrest2::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn checks_all_rows_are_true() {
|
||||
Playground::setup("all_test_1", |_, nu| {
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
echo [ "Andrés", "Andrés", "Andrés" ]
|
||||
| all? $it == "Andrés"
|
||||
"#
|
||||
)),
|
||||
says().stdout("true")
|
||||
);
|
||||
})
|
||||
=======
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
@ -32,23 +11,10 @@ fn checks_all_rows_are_true() {
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checks_all_rows_are_false_with_param() {
|
||||
<<<<<<< HEAD
|
||||
Playground::setup("all_test_1", |_, nu| {
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
[1, 2, 3, 4] | all? { |a| $a >= 5 }
|
||||
"#
|
||||
)),
|
||||
says().stdout("false")
|
||||
);
|
||||
})
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
@ -57,23 +23,10 @@ fn checks_all_rows_are_false_with_param() {
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "false");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checks_all_rows_are_true_with_param() {
|
||||
<<<<<<< HEAD
|
||||
Playground::setup("all_test_1", |_, nu| {
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
[1, 2, 3, 4] | all? { |a| $a < 5 }
|
||||
"#
|
||||
)),
|
||||
says().stdout("true")
|
||||
);
|
||||
})
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
@ -82,21 +35,13 @@ fn checks_all_rows_are_true_with_param() {
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checks_all_columns_of_a_table_is_true() {
|
||||
<<<<<<< HEAD
|
||||
Playground::setup("any_test_1", |_, nu| {
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
echo [
|
||||
[ first_name, last_name, rusty_at, likes ];
|
||||
[ Andrés, Robalino, 10/11/2013, 1 ]
|
||||
@ -105,16 +50,8 @@ fn checks_all_columns_of_a_table_is_true() {
|
||||
[ Yehuda, Katz, 10/11/2013, 1 ]
|
||||
]
|
||||
| all? likes > 0
|
||||
<<<<<<< HEAD
|
||||
"#
|
||||
)),
|
||||
says().stdout("true")
|
||||
);
|
||||
})
|
||||
=======
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
@ -1,24 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
use nu_test_support::pipeline as input;
|
||||
use nu_test_support::playground::{says, Playground};
|
||||
|
||||
use hamcrest2::assert_that;
|
||||
use hamcrest2::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn checks_any_row_is_true() {
|
||||
Playground::setup("any_test_1", |_, nu| {
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
echo [ "Ecuador", "USA", "New Zealand" ]
|
||||
| any? $it == "New Zealand"
|
||||
"#
|
||||
)),
|
||||
says().stdout("true")
|
||||
);
|
||||
})
|
||||
=======
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
@ -32,21 +11,13 @@ fn checks_any_row_is_true() {
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checks_any_column_of_a_table_is_true() {
|
||||
<<<<<<< HEAD
|
||||
Playground::setup("any_test_1", |_, nu| {
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
echo [
|
||||
[ first_name, last_name, rusty_at, likes ];
|
||||
[ Andrés, Robalino, 10/11/2013, 1 ]
|
||||
@ -55,16 +26,8 @@ fn checks_any_column_of_a_table_is_true() {
|
||||
[ Yehuda, Katz, 10/11/2013, 1 ]
|
||||
]
|
||||
| any? rusty_at == 10/12/2013
|
||||
<<<<<<< HEAD
|
||||
"#
|
||||
)),
|
||||
says().stdout("true")
|
||||
);
|
||||
})
|
||||
=======
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
@ -1,25 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
use nu_test_support::pipeline as input;
|
||||
use nu_test_support::playground::{says, Playground};
|
||||
|
||||
use hamcrest2::assert_that;
|
||||
use hamcrest2::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn adds_a_row_to_the_end() {
|
||||
Playground::setup("append_test_1", |_, nu| {
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
echo [ "Andrés N. Robalino", "Jonathan Turner", "Yehuda Katz" ]
|
||||
| append "pollo loco"
|
||||
| nth 3
|
||||
"#
|
||||
)),
|
||||
says().stdout("pollo loco")
|
||||
);
|
||||
})
|
||||
=======
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
@ -34,5 +12,4 @@ fn adds_a_row_to_the_end() {
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "pollo loco");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
@ -5,19 +5,11 @@ fn cal_full_year() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
cal -y --full-year 2010 | first | to json
|
||||
"#
|
||||
));
|
||||
|
||||
let first_week_2010_json = r#"{"year":2010,"sunday":null,"monday":null,"tuesday":null,"wednesday":null,"thursday":null,"friday":1,"saturday":2}"#;
|
||||
=======
|
||||
cal -y --full-year 2010 | first | to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
let first_week_2010_json = r#"{"year": 2010,"sunday": null,"monday": null,"tuesday": null,"wednesday": null,"thursday": null,"friday": 1,"saturday": 2}"#;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
||||
assert_eq!(actual.out, first_week_2010_json);
|
||||
}
|
||||
@ -27,19 +19,11 @@ fn cal_february_2020_leap_year() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
cal -ym --full-year 2020 --month-names | where month == "february" | to json
|
||||
"#
|
||||
));
|
||||
|
||||
let cal_february_json = r#"[{"year":2020,"month":"february","sunday":null,"monday":null,"tuesday":null,"wednesday":null,"thursday":null,"friday":null,"saturday":1},{"year":2020,"month":"february","sunday":2,"monday":3,"tuesday":4,"wednesday":5,"thursday":6,"friday":7,"saturday":8},{"year":2020,"month":"february","sunday":9,"monday":10,"tuesday":11,"wednesday":12,"thursday":13,"friday":14,"saturday":15},{"year":2020,"month":"february","sunday":16,"monday":17,"tuesday":18,"wednesday":19,"thursday":20,"friday":21,"saturday":22},{"year":2020,"month":"february","sunday":23,"monday":24,"tuesday":25,"wednesday":26,"thursday":27,"friday":28,"saturday":29}]"#;
|
||||
=======
|
||||
cal -ym --full-year 2020 --month-names | where month == "february" | to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
let cal_february_json = r#"[{"year": 2020,"month": "february","sunday": null,"monday": null,"tuesday": null,"wednesday": null,"thursday": null,"friday": null,"saturday": 1},{"year": 2020,"month": "february","sunday": 2,"monday": 3,"tuesday": 4,"wednesday": 5,"thursday": 6,"friday": 7,"saturday": 8},{"year": 2020,"month": "february","sunday": 9,"monday": 10,"tuesday": 11,"wednesday": 12,"thursday": 13,"friday": 14,"saturday": 15},{"year": 2020,"month": "february","sunday": 16,"monday": 17,"tuesday": 18,"wednesday": 19,"thursday": 20,"friday": 21,"saturday": 22},{"year": 2020,"month": "february","sunday": 23,"monday": 24,"tuesday": 25,"wednesday": 26,"thursday": 27,"friday": 28,"saturday": 29}]"#;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
||||
assert_eq!(actual.out, cal_february_json);
|
||||
}
|
||||
@ -73,19 +57,11 @@ fn cal_week_day_start_monday() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
cal --full-year 2020 -m --month-names --week-start monday | where month == january | to json
|
||||
"#
|
||||
));
|
||||
|
||||
let cal_january_json = r#"[{"month":"january","monday":null,"tuesday":null,"wednesday":1,"thursday":2,"friday":3,"saturday":4,"sunday":5},{"month":"january","monday":6,"tuesday":7,"wednesday":8,"thursday":9,"friday":10,"saturday":11,"sunday":12},{"month":"january","monday":13,"tuesday":14,"wednesday":15,"thursday":16,"friday":17,"saturday":18,"sunday":19},{"month":"january","monday":20,"tuesday":21,"wednesday":22,"thursday":23,"friday":24,"saturday":25,"sunday":26},{"month":"january","monday":27,"tuesday":28,"wednesday":29,"thursday":30,"friday":31,"saturday":null,"sunday":null}]"#;
|
||||
=======
|
||||
cal --full-year 2020 -m --month-names --week-start monday | where month == january | to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
let cal_january_json = r#"[{"month": "january","monday": null,"tuesday": null,"wednesday": 1,"thursday": 2,"friday": 3,"saturday": 4,"sunday": 5},{"month": "january","monday": 6,"tuesday": 7,"wednesday": 8,"thursday": 9,"friday": 10,"saturday": 11,"sunday": 12},{"month": "january","monday": 13,"tuesday": 14,"wednesday": 15,"thursday": 16,"friday": 17,"saturday": 18,"sunday": 19},{"month": "january","monday": 20,"tuesday": 21,"wednesday": 22,"thursday": 23,"friday": 24,"saturday": 25,"sunday": 26},{"month": "january","monday": 27,"tuesday": 28,"wednesday": 29,"thursday": 30,"friday": 31,"saturday": null,"sunday": null}]"#;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
||||
assert_eq!(actual.out, cal_january_json);
|
||||
}
|
||||
@ -95,17 +71,9 @@ fn cal_sees_pipeline_year() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
cal --full-year 1020 | get monday | first 3 | to json
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "[3,10,17]");
|
||||
=======
|
||||
cal --full-year 1020 | get monday | first 4 | to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "[null,3,10,17]");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
@ -1,17 +1,10 @@
|
||||
<<<<<<< HEAD
|
||||
use nu_test_support::fs::{Stub::EmptyFile, Stub::FileWithContent};
|
||||
=======
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
use std::path::PathBuf;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_from_current_directory_using_relative_path() {
|
||||
Playground::setup("cd_test_1", |dirs, _| {
|
||||
@ -27,11 +20,8 @@ fn filesystem_change_from_current_directory_using_relative_path() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_from_current_directory_using_absolute_path() {
|
||||
Playground::setup("cd_test_2", |dirs, _| {
|
||||
@ -48,11 +38,8 @@ fn filesystem_change_from_current_directory_using_absolute_path() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_switch_back_to_previous_working_directory() {
|
||||
Playground::setup("cd_test_3", |dirs, sandbox| {
|
||||
@ -72,11 +59,8 @@ fn filesystem_switch_back_to_previous_working_directory() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesytem_change_from_current_directory_using_relative_path_and_dash() {
|
||||
Playground::setup("cd_test_4", |dirs, sandbox| {
|
||||
@ -97,11 +81,8 @@ fn filesytem_change_from_current_directory_using_relative_path_and_dash() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_current_directory_to_parent_directory() {
|
||||
Playground::setup("cd_test_5", |dirs, _| {
|
||||
@ -117,11 +98,8 @@ fn filesystem_change_current_directory_to_parent_directory() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_current_directory_to_two_parents_up_using_multiple_dots() {
|
||||
Playground::setup("cd_test_6", |dirs, sandbox| {
|
||||
@ -139,11 +117,8 @@ fn filesystem_change_current_directory_to_two_parents_up_using_multiple_dots() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_current_directory_to_parent_directory_after_delete_cwd() {
|
||||
Playground::setup("cd_test_7", |dirs, sandbox| {
|
||||
@ -166,11 +141,8 @@ fn filesystem_change_current_directory_to_parent_directory_after_delete_cwd() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_to_home_directory() {
|
||||
Playground::setup("cd_test_8", |dirs, _| {
|
||||
@ -186,11 +158,8 @@ fn filesystem_change_to_home_directory() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_to_a_directory_containing_spaces() {
|
||||
Playground::setup("cd_test_9", |dirs, sandbox| {
|
||||
@ -211,11 +180,8 @@ fn filesystem_change_to_a_directory_containing_spaces() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_not_a_directory() {
|
||||
Playground::setup("cd_test_10", |dirs, sandbox| {
|
||||
@ -239,11 +205,8 @@ fn filesystem_not_a_directory() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_directory_not_found() {
|
||||
Playground::setup("cd_test_11", |dirs, _| {
|
||||
@ -266,11 +229,8 @@ fn filesystem_directory_not_found() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_directory_to_symlink_relative() {
|
||||
Playground::setup("cd_test_12", |dirs, sandbox| {
|
||||
@ -290,218 +250,8 @@ fn filesystem_change_directory_to_symlink_relative() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
#[test]
|
||||
fn valuesystem_change_from_current_path_using_relative_path() {
|
||||
Playground::setup("cd_test_13", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[[bin]]
|
||||
path = "src/plugins/turner.rs"
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/robalino.rs"
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/katz.rs"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
r#"
|
||||
enter sample.toml
|
||||
cd bin
|
||||
pwd
|
||||
exit
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), PathBuf::from("/bin"));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valuesystem_change_from_current_path_using_absolute_path() {
|
||||
Playground::setup("cd_test_14", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[dependencies]
|
||||
turner-ts = "0.1.1"
|
||||
robalino-tkd = "0.0.1"
|
||||
katz-ember = "0.2.3"
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/arepa.rs"
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/bbq.rs"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
r#"
|
||||
enter sample.toml
|
||||
cd bin
|
||||
cd /dependencies
|
||||
pwd
|
||||
exit
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), PathBuf::from("/dependencies"));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valuesystem_switch_back_to_previous_working_path() {
|
||||
Playground::setup("cd_test_15", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[dependencies]
|
||||
turner-ts = "0.1.1"
|
||||
robalino-tkd = "0.0.1"
|
||||
katz-ember = "0.2.3"
|
||||
odin-gf = "0.2.1"
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/arepa.rs"
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/bbq.rs"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
r#"
|
||||
enter sample.toml
|
||||
cd dependencies
|
||||
cd /bin
|
||||
cd -
|
||||
pwd
|
||||
exit
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), PathBuf::from("/dependencies"));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valuesystem_change_from_current_path_using_relative_path_and_dash() {
|
||||
Playground::setup("cd_test_16", |dirs, sandbox| {
|
||||
sandbox
|
||||
.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
- = ["Yehuda Katz <wycats@gmail.com>", "Jonathan Turner <jonathan.d.turner@gmail.com>", "Andrés N. Robalino <andres@androbtech.com>"]
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/arepa.rs"
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/bbq.rs"
|
||||
"#
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
r#"
|
||||
enter sample.toml
|
||||
cd package/-
|
||||
cd /bin
|
||||
cd -
|
||||
pwd
|
||||
exit
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), PathBuf::from("/package/-"));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valuesystem_change_current_path_to_parent_path() {
|
||||
Playground::setup("cd_test_17", |dirs, sandbox| {
|
||||
sandbox
|
||||
.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
emberenios = ["Yehuda Katz <wycats@gmail.com>", "Jonathan Turner <jonathan.d.turner@gmail.com>", "Andrés N. Robalino <andres@androbtech.com>"]
|
||||
"#
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
r#"
|
||||
enter sample.toml
|
||||
cd package/emberenios
|
||||
cd ..
|
||||
pwd
|
||||
exit
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), PathBuf::from("/package"));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valuesystem_change_to_a_path_containing_spaces() {
|
||||
Playground::setup("cd_test_18", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
["pa que te"]
|
||||
el = "pollo loco"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
r#"
|
||||
enter sample.toml
|
||||
cd "pa que te"
|
||||
pwd
|
||||
exit
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
PathBuf::from(actual.out),
|
||||
PathBuf::from("/").join("pa que te")
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valuesystem_path_not_found() {
|
||||
Playground::setup("cd_test_19", |dirs, _| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.formats(),
|
||||
r#"
|
||||
enter cargo_sample.toml
|
||||
cd im_a_path_that_does_not_exist
|
||||
exit
|
||||
"#
|
||||
);
|
||||
|
||||
assert!(actual.err.contains("Can not change to path inside"));
|
||||
assert!(actual.err.contains("No such path exists"));
|
||||
})
|
||||
}
|
||||
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[cfg(target_os = "windows")]
|
||||
#[test]
|
||||
fn test_change_windows_drive() {
|
||||
|
50
crates/nu-command/tests/commands/compact.rs
Normal file
50
crates/nu-command/tests/commands/compact.rs
Normal file
@ -0,0 +1,50 @@
|
||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn discards_rows_where_given_column_is_empty() {
|
||||
Playground::setup("compact_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"los_tres_amigos.json",
|
||||
r#"
|
||||
{
|
||||
"amigos": [
|
||||
{"name": "Yehuda", "rusty_luck": 1},
|
||||
{"name": "Jonathan", "rusty_luck": 1},
|
||||
{"name": "Andres", "rusty_luck": 1},
|
||||
{"name":"GorbyPuff"}
|
||||
]
|
||||
}
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open los_tres_amigos.json
|
||||
| get amigos
|
||||
| compact rusty_luck
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "3");
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn discards_empty_rows_by_default() {
|
||||
Playground::setup("compact_test_2", |dirs, _| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
echo "[1,2,3,14,null]"
|
||||
| from json
|
||||
| compact
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4");
|
||||
});
|
||||
}
|
@ -31,11 +31,8 @@ fn copies_the_file_inside_directory_if_path_to_copy_is_directory() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn error_if_attempting_to_copy_a_directory_to_another_directory() {
|
||||
Playground::setup("cp_test_3", |dirs, _| {
|
||||
@ -80,11 +77,8 @@ fn copies_the_directory_inside_directory_if_path_to_copy_is_directory_and_with_r
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn deep_copies_with_recursive_flag() {
|
||||
Playground::setup("cp_test_5", |dirs, sandbox| {
|
||||
|
@ -1,12 +1,9 @@
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
use std::fs;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn def_with_comment() {
|
||||
Playground::setup("def_with_comment", |dirs, _| {
|
||||
|
35
crates/nu-command/tests/commands/default.rs
Normal file
35
crates/nu-command/tests/commands/default.rs
Normal file
@ -0,0 +1,35 @@
|
||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn adds_row_data_if_column_missing() {
|
||||
Playground::setup("default_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"los_tres_amigos.json",
|
||||
r#"
|
||||
{
|
||||
"amigos": [
|
||||
{"name": "Yehuda"},
|
||||
{"name": "Jonathan", "rusty_luck": 0},
|
||||
{"name": "Andres", "rusty_luck": 0},
|
||||
{"name":"GorbyPuff"}
|
||||
]
|
||||
}
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open los_tres_amigos.json
|
||||
| get amigos
|
||||
| default rusty_luck 1
|
||||
| where rusty_luck == 1
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "2");
|
||||
});
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn columns() {
|
||||
let actual = nu!(
|
||||
@ -25,11 +22,8 @@ fn columns() {
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn more_columns_than_table_has() {
|
||||
let actual = nu!(
|
||||
@ -76,18 +70,17 @@ fn more_rows_than_table_has() {
|
||||
|
||||
assert_eq!(actual.out, "0");
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
#[test]
|
||||
fn nth_range_inclusive() {
|
||||
let actual = nu!(cwd: ".", "echo 10..15 | drop nth (2..3) | to json");
|
||||
let actual = nu!(cwd: ".", "echo 10..15 | drop nth (2..3) | to json --raw");
|
||||
|
||||
assert_eq!(actual.out, "[10,11,14,15]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nth_range_exclusive() {
|
||||
let actual = nu!(cwd: ".", "echo 10..15 | drop nth (1..<3) | to json");
|
||||
let actual = nu!(cwd: ".", "echo 10..15 | drop nth (1..<3) | to json --raw");
|
||||
|
||||
assert_eq!(actual.out, "[10,13,14,15]");
|
||||
}
|
||||
@ -96,8 +89,5 @@ fn nth_range_exclusive() {
|
||||
fn nth_missing_first_argument() {
|
||||
let actual = nu!(cwd: ".", "echo 10..15 | drop nth \"\"");
|
||||
|
||||
assert!(actual.err.contains("Expected int or range"));
|
||||
assert!(actual.err.contains("found string"));
|
||||
assert!(actual.err.contains("int or range"));
|
||||
}
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
@ -5,11 +5,7 @@ fn each_works_separately() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo [1 2 3] | each { echo $it 10 | math sum } | to json
|
||||
=======
|
||||
echo [1 2 3] | each { echo $it 10 | math sum } | to json -r
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -21,11 +17,7 @@ fn each_group_works() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo [1 2 3 4 5 6] | each group 3 { $it } | to json
|
||||
=======
|
||||
echo [1 2 3 4 5 6] | each group 3 { $it } | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -37,11 +29,7 @@ fn each_window() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo [1 2 3 4] | each window 3 { $it } | to json
|
||||
=======
|
||||
echo [1 2 3 4] | each window 3 { $it } | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -53,11 +41,7 @@ fn each_window_stride() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo [1 2 3 4 5 6] | each window 3 -s 2 { echo $it } | to json
|
||||
=======
|
||||
echo [1 2 3 4 5 6] | each window 3 -s 2 { echo $it } | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -69,19 +53,11 @@ fn each_no_args_in_block() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo [[foo bar]; [a b] [c d] [e f]] | each { to json } | nth 1 | str collect
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#"{"foo":"c","bar":"d"}"#);
|
||||
=======
|
||||
echo [[foo bar]; [a b] [c d] [e f]] | each {|i| $i | to json -r } | nth 1
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#"{"foo": "c","bar": "d"}"#);
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -5,11 +5,7 @@ fn echo_range_is_lazy() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 1..10000000000 | first 3 | to json
|
||||
=======
|
||||
echo 1..10000000000 | first 3 | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -21,11 +17,7 @@ fn echo_range_handles_inclusive() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 1..3 | to json
|
||||
=======
|
||||
echo 1..3 | each { $it } | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -37,11 +29,7 @@ fn echo_range_handles_exclusive() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 1..<3 | to json
|
||||
=======
|
||||
echo 1..<3 | each { $it } | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -53,11 +41,7 @@ fn echo_range_handles_inclusive_down() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 3..1 | to json
|
||||
=======
|
||||
echo 3..1 | each { $it } | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -69,11 +53,7 @@ fn echo_range_handles_exclusive_down() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 3..<1 | to json
|
||||
=======
|
||||
echo 3..<1 | each { $it } | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn reports_emptiness() {
|
||||
let actual = nu!(
|
||||
@ -25,11 +22,8 @@ fn reports_emptiness() {
|
||||
assert_eq!(actual.out, "3");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn sets_block_run_value_for_an_empty_column() {
|
||||
let actual = nu!(
|
||||
@ -51,11 +45,8 @@ fn sets_block_run_value_for_an_empty_column() {
|
||||
assert_eq!(actual.out, "4");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn sets_block_run_value_for_many_empty_columns() {
|
||||
let actual = nu!(
|
||||
@ -76,11 +67,8 @@ fn sets_block_run_value_for_many_empty_columns() {
|
||||
assert_eq!(actual.out, "6");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn passing_a_block_will_set_contents_on_empty_cells_and_leave_non_empty_ones_untouched() {
|
||||
let actual = nu!(
|
||||
|
@ -71,18 +71,3 @@ fn knows_the_filesystems_entered() {
|
||||
));
|
||||
})
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
#[test]
|
||||
fn errors_if_file_not_found() {
|
||||
Playground::setup("enter_test_2", |dirs, _| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"enter i_dont_exist.csv"
|
||||
);
|
||||
|
||||
assert!(actual.err.contains("Cannot find file"));
|
||||
})
|
||||
}
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
@ -18,11 +18,7 @@ fn gets_all_rows_by_every_zero() {
|
||||
ls
|
||||
| get name
|
||||
| every 0
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -49,19 +45,11 @@ fn gets_no_rows_by_every_skip_zero() {
|
||||
ls
|
||||
| get name
|
||||
| every 0 --skip
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "");
|
||||
=======
|
||||
| to json --raw
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "[]");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
})
|
||||
}
|
||||
|
||||
@ -81,11 +69,7 @@ fn gets_all_rows_by_every_one() {
|
||||
ls
|
||||
| get name
|
||||
| every 1
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -96,11 +80,8 @@ fn gets_all_rows_by_every_one() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn gets_no_rows_by_every_skip_one() {
|
||||
Playground::setup("every_test_4", |dirs, sandbox| {
|
||||
@ -117,11 +98,7 @@ fn gets_no_rows_by_every_skip_one() {
|
||||
ls
|
||||
| get name
|
||||
| every 1 --skip
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -175,11 +152,7 @@ fn gets_all_rows_except_first_by_every_skip_too_much() {
|
||||
ls
|
||||
| get name
|
||||
| every 999 --skip
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -204,11 +177,7 @@ fn gets_every_third_row() {
|
||||
ls
|
||||
| get name
|
||||
| every 3
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -233,11 +202,7 @@ fn skips_every_third_row() {
|
||||
ls
|
||||
| get name
|
||||
| every 3 --skip
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
|
@ -19,11 +19,7 @@ fn find_with_list_search_with_char() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
[moe larry curly] | find l | to json
|
||||
=======
|
||||
[moe larry curly] | find l | to json -r
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -82,19 +78,11 @@ fn find_with_filepath_search_with_string() {
|
||||
ls
|
||||
| get name
|
||||
| find arep
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#""arepas.clu""#);
|
||||
=======
|
||||
| to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#"["arepas.clu"]"#);
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
})
|
||||
}
|
||||
|
||||
@ -114,11 +102,7 @@ fn find_with_filepath_search_with_multiple_patterns() {
|
||||
ls
|
||||
| get name
|
||||
| find arep ami
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json -r
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
|
67
crates/nu-command/tests/commands/first.rs
Normal file
67
crates/nu-command/tests/commands/first.rs
Normal file
@ -0,0 +1,67 @@
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn gets_first_rows_by_amount() {
|
||||
Playground::setup("first_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("los.txt"),
|
||||
EmptyFile("tres.txt"),
|
||||
EmptyFile("amigos.txt"),
|
||||
EmptyFile("arepas.clu"),
|
||||
]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| first 3
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "3");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gets_all_rows_if_amount_higher_than_all_rows() {
|
||||
Playground::setup("first_test_2", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("los.txt"),
|
||||
EmptyFile("tres.txt"),
|
||||
EmptyFile("amigos.txt"),
|
||||
EmptyFile("arepas.clu"),
|
||||
]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| first 99
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gets_first_row_when_no_amount_given() {
|
||||
Playground::setup("first_test_3", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("caballeros.txt"), EmptyFile("arepas.clu")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| first
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
})
|
||||
}
|
@ -2,11 +2,8 @@ use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn flatten_nested_tables_with_columns() {
|
||||
let actual = nu!(
|
||||
@ -23,11 +20,8 @@ fn flatten_nested_tables_with_columns() {
|
||||
assert_eq!(actual.out, "Andres,nuno");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn flatten_nested_tables_that_have_many_columns() {
|
||||
let actual = nu!(
|
||||
@ -88,11 +82,8 @@ fn flatten_row_column_explicitly() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn flatten_row_columns_having_same_column_names_flats_separately() {
|
||||
Playground::setup("flatten_test_2", |dirs, sandbox| {
|
||||
@ -127,11 +118,8 @@ fn flatten_row_columns_having_same_column_names_flats_separately() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn flatten_table_columns_explicitly() {
|
||||
Playground::setup("flatten_test_3", |dirs, sandbox| {
|
||||
|
@ -16,11 +16,8 @@ fn creates_the_resulting_string_from_the_given_fields() {
|
||||
assert_eq!(actual.out, "nu has license ISC");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn given_fields_can_be_column_paths() {
|
||||
let actual = nu!(
|
||||
@ -34,11 +31,8 @@ fn given_fields_can_be_column_paths() {
|
||||
assert_eq!(actual.out, "nu is a new type of shell");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn can_use_variables() {
|
||||
let actual = nu!(
|
||||
@ -52,11 +46,8 @@ fn can_use_variables() {
|
||||
assert_eq!(actual.out, "nu is a new type of shell");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn format_filesize_works() {
|
||||
Playground::setup("format_filesize_test_1", |dirs, sandbox| {
|
||||
@ -80,11 +71,8 @@ fn format_filesize_works() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn format_filesize_works_with_nonempty_files() {
|
||||
Playground::setup(
|
||||
|
@ -130,11 +130,8 @@ fn fetches_more_than_one_column_path() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_fetching_by_column_not_present() {
|
||||
Playground::setup("get_test_6", |dirs, sandbox| {
|
||||
@ -165,11 +162,8 @@ fn errors_fetching_by_column_not_present() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_fetching_by_column_using_a_number() {
|
||||
Playground::setup("get_test_7", |dirs, sandbox| {
|
||||
@ -196,12 +190,9 @@ fn errors_fetching_by_column_using_a_number() {
|
||||
.contains("Appears to contain columns. Columns available: 0"),)
|
||||
})
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_fetching_by_index_out_of_bounds() {
|
||||
Playground::setup("get_test_8", |dirs, sandbox| {
|
||||
|
@ -71,11 +71,8 @@ fn errors_if_given_unknown_column_name() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_block_given_evaluates_more_than_one_row() {
|
||||
Playground::setup("group_by_test_3", |dirs, sandbox| {
|
||||
|
@ -26,11 +26,8 @@ fn base64_encode_characterset_binhex() {
|
||||
assert_eq!(actual.out, "F@0NEPjJD97kE\'&bEhFZEP3");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn error_when_invalid_character_set_given() {
|
||||
let actual = nu!(
|
||||
@ -46,11 +43,8 @@ fn error_when_invalid_character_set_given() {
|
||||
.contains("this is invalid is not a valid character-set"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn base64_decode_characterset_binhex() {
|
||||
let actual = nu!(
|
||||
@ -94,11 +88,8 @@ fn error_use_both_flags() {
|
||||
.contains("only one of --decode and --encode flags can be used"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn md5_works_with_file() {
|
||||
let actual = nu!(
|
||||
@ -112,11 +103,8 @@ fn md5_works_with_file() {
|
||||
assert_eq!(actual.out, "4de97601d232c427977ef11db396c951");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn sha256_works_with_file() {
|
||||
let actual = nu!(
|
||||
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn headers_uses_first_row_as_header() {
|
||||
let actual = nu!(
|
||||
@ -20,11 +17,8 @@ fn headers_uses_first_row_as_header() {
|
||||
assert_eq!(actual.out, "r1c0r2c0")
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn headers_adds_missing_column_name() {
|
||||
let actual = nu!(
|
||||
|
@ -15,11 +15,8 @@ fn help_commands_length() {
|
||||
assert!(is_positive);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn help_generate_docs_length() {
|
||||
let actual = nu!(
|
||||
|
@ -2,11 +2,8 @@ use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn summarizes_by_column_given() {
|
||||
Playground::setup("histogram_test_1", |dirs, sandbox| {
|
||||
@ -38,11 +35,8 @@ fn summarizes_by_column_given() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn summarizes_by_values() {
|
||||
Playground::setup("histogram_test_2", |dirs, sandbox| {
|
||||
@ -71,11 +65,8 @@ fn summarizes_by_values() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn help() {
|
||||
Playground::setup("histogram_test_3", |dirs, _sandbox| {
|
||||
@ -105,11 +96,8 @@ fn help() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn count() {
|
||||
let actual = nu!(
|
||||
|
@ -33,11 +33,7 @@ fn into_filesize_str() {
|
||||
"#
|
||||
));
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert!(actual.out.contains("2.0 KB"));
|
||||
=======
|
||||
assert!(actual.out.contains("2.0 KiB"));
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -45,21 +41,12 @@ fn into_filesize_str_newline() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
'2000
|
||||
' | into filesize
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("2.0 KB"));
|
||||
=======
|
||||
"2000
|
||||
" | into filesize
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("2.0 KiB"));
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -67,15 +54,6 @@ fn into_filesize_str_many_newlines() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
'2000
|
||||
|
||||
' | into filesize
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("2.0 KB"));
|
||||
=======
|
||||
"2000
|
||||
|
||||
" | into filesize
|
||||
@ -83,7 +61,6 @@ fn into_filesize_str_many_newlines() {
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("2.0 KiB"));
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -91,17 +68,9 @@ fn into_filesize_filesize() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
3kb | into filesize
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("3.0 KB"));
|
||||
=======
|
||||
3kib | into filesize
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("3.0 KiB"));
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
37
crates/nu-command/tests/commands/into_int.rs
Normal file
37
crates/nu-command/tests/commands/into_int.rs
Normal file
@ -0,0 +1,37 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn into_int_filesize() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 1kb | into int | each { $it / 1000 }
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains('1'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn into_int_filesize2() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 1kib | into int | each { $it / 1024 }
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains('1'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn into_int_int() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 1024 | into int | each { $it / 1024 }
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains('1'));
|
||||
}
|
3
crates/nu-command/tests/commands/keep/mod.rs
Normal file
3
crates/nu-command/tests/commands/keep/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
mod rows;
|
||||
mod until;
|
||||
mod while_;
|
31
crates/nu-command/tests/commands/keep/rows.rs
Normal file
31
crates/nu-command/tests/commands/keep/rows.rs
Normal file
@ -0,0 +1,31 @@
|
||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn rows() {
|
||||
Playground::setup("keep_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"caballeros.csv",
|
||||
r#"
|
||||
name,lucky_code
|
||||
Andrés,1
|
||||
Jonathan,1
|
||||
Jason,2
|
||||
Yehuda,1
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open caballeros.csv
|
||||
| keep 3
|
||||
| get lucky_code
|
||||
| math sum
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4");
|
||||
})
|
||||
}
|
@ -10,11 +10,7 @@ fn condition_is_met() {
|
||||
r#"
|
||||
CHICKEN SUMMARY report date: April 29th, 2020
|
||||
--------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020,
|
||||
=======
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
Yellow Chickens,,,
|
||||
Andrés,1,1,1
|
||||
Jonathan,1,1,1
|
||||
@ -37,16 +33,6 @@ fn condition_is_met() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open --raw caballeros.txt
|
||||
<<<<<<< HEAD
|
||||
| lines
|
||||
| skip 2
|
||||
| split column ','
|
||||
| headers
|
||||
| skip while "Chicken Collection" != "Blue Chickens"
|
||||
| keep until "Chicken Collection" == "Red Chickens"
|
||||
| skip 1
|
||||
| str to-int "31/04/2020"
|
||||
=======
|
||||
| lines
|
||||
| skip 2
|
||||
| str trim
|
||||
@ -56,7 +42,6 @@ fn condition_is_met() {
|
||||
| keep until "Chicken Collection" == "Red Chickens"
|
||||
| skip 1
|
||||
| into int "31/04/2020"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get "31/04/2020"
|
||||
| math sum
|
||||
"#
|
||||
|
@ -10,11 +10,7 @@ fn condition_is_met() {
|
||||
r#"
|
||||
CHICKEN SUMMARY report date: April 29th, 2020
|
||||
--------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020,
|
||||
=======
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
Yellow Chickens,,,
|
||||
Andrés,1,1,1
|
||||
Jonathan,1,1,1
|
||||
@ -37,15 +33,6 @@ fn condition_is_met() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open --raw caballeros.txt
|
||||
<<<<<<< HEAD
|
||||
| lines
|
||||
| skip 2
|
||||
| split column ','
|
||||
| headers
|
||||
| skip 1
|
||||
| keep while "Chicken Collection" != "Blue Chickens"
|
||||
| str to-int "31/04/2020"
|
||||
=======
|
||||
| lines
|
||||
| skip 2
|
||||
| str trim
|
||||
@ -54,7 +41,6 @@ fn condition_is_met() {
|
||||
| skip 1
|
||||
| keep while "Chicken Collection" != "Blue Chickens"
|
||||
| into int "31/04/2020"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get "31/04/2020"
|
||||
| math sum
|
||||
"#
|
||||
|
66
crates/nu-command/tests/commands/last.rs
Normal file
66
crates/nu-command/tests/commands/last.rs
Normal file
@ -0,0 +1,66 @@
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn gets_the_last_row() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
"ls | sort-by name | last 1 | get name | str trim"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "utf16.ini");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gets_last_rows_by_amount() {
|
||||
Playground::setup("last_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("los.txt"),
|
||||
EmptyFile("tres.txt"),
|
||||
EmptyFile("amigos.txt"),
|
||||
EmptyFile("arepas.clu"),
|
||||
]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| last 3
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "3");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gets_last_row_when_no_amount_given() {
|
||||
Playground::setup("last_test_2", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("caballeros.txt"), EmptyFile("arepas.clu")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| last
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn requests_more_rows_than_table_has() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
date | last 50 | length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
25
crates/nu-command/tests/commands/length.rs
Normal file
25
crates/nu-command/tests/commands/length.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn length_columns_in_cal_table() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
cal | length -c
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "7");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn length_columns_no_rows() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [] | length -c
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "0");
|
||||
}
|
@ -27,11 +27,7 @@ fn lines_proper_buffering() {
|
||||
open lines_test.txt -r
|
||||
| lines
|
||||
| str length
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json -r
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -50,9 +46,5 @@ fn lines_multi_value_split() {
|
||||
"#
|
||||
));
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert_eq!(actual.out, "5");
|
||||
=======
|
||||
assert_eq!(actual.out, "6");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
@ -88,11 +88,7 @@ fn lists_all_files_in_directories_from_stream() {
|
||||
r#"
|
||||
echo dir_a dir_b
|
||||
| each { ls $it }
|
||||
<<<<<<< HEAD
|
||||
| length
|
||||
=======
|
||||
| flatten | length
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -304,22 +300,14 @@ fn list_all_columns() {
|
||||
// Normal Operation
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
<<<<<<< HEAD
|
||||
"ls | get | to md"
|
||||
=======
|
||||
"ls | columns | to md"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
);
|
||||
let expected = ["name", "type", "size", "modified"].join("");
|
||||
assert_eq!(actual.out, expected, "column names are incorrect for ls");
|
||||
// Long
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
<<<<<<< HEAD
|
||||
"ls -l | get | to md"
|
||||
=======
|
||||
"ls -l | columns | to md"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
);
|
||||
let expected = {
|
||||
#[cfg(unix)]
|
||||
@ -328,17 +316,10 @@ fn list_all_columns() {
|
||||
"name",
|
||||
"type",
|
||||
"target",
|
||||
<<<<<<< HEAD
|
||||
"num_links",
|
||||
"inode",
|
||||
"readonly",
|
||||
"mode",
|
||||
=======
|
||||
"readonly",
|
||||
"mode",
|
||||
"num_links",
|
||||
"inode",
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"uid",
|
||||
"group",
|
||||
"size",
|
||||
|
@ -18,15 +18,8 @@ fn can_average_numbers() {
|
||||
fn can_average_bytes() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
<<<<<<< HEAD
|
||||
"ls | sort-by name | skip 1 | first 2 | get size | math avg | format \"{$it}\" "
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "1.6 KB");
|
||||
=======
|
||||
"ls | sort-by name | skip 1 | first 2 | get size | math avg | to json -r"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "1600");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn evaluates_two_plus_two() {
|
||||
let actual = nu!(
|
||||
@ -17,11 +14,8 @@ fn evaluates_two_plus_two() {
|
||||
assert!(actual.out.contains("4.0"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn evaluates_two_to_the_power_four() {
|
||||
let actual = nu!(
|
||||
@ -34,11 +28,8 @@ fn evaluates_two_to_the_power_four() {
|
||||
assert!(actual.out.contains("16.0"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn evaluates_three_multiplied_by_five() {
|
||||
let actual = nu!(
|
||||
@ -51,11 +42,8 @@ fn evaluates_three_multiplied_by_five() {
|
||||
assert!(actual.out.contains("15.0"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn evaluates_twenty_four_divided_by_two() {
|
||||
let actual = nu!(
|
||||
|
40
crates/nu-command/tests/commands/math/median.rs
Normal file
40
crates/nu-command/tests/commands/math/median.rs
Normal file
@ -0,0 +1,40 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn median_numbers_with_even_rows() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [10 6 19 21 4]
|
||||
| math median
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "10")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn median_numbers_with_odd_rows() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [3 8 9 12 12 15]
|
||||
| math median
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "10.5")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn median_mixed_numbers() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [-11.5 -13.5 10]
|
||||
| math median
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "-11.5")
|
||||
}
|
@ -236,21 +236,6 @@ fn duration_math_with_negative() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
<<<<<<< HEAD
|
||||
fn duration_math_shell_error_on_big_numbers() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
(date now) + 100000000000000day
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.err.contains("Duration overflow"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
fn compound_comparison() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
@ -279,19 +264,11 @@ fn compound_where() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo '[{"a": 1, "b": 1}, {"a": 2, "b": 1}, {"a": 2, "b": 2}]' | from json | where a == 2 && b == 1 | to json
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#"{"a":2,"b":1}"#);
|
||||
=======
|
||||
echo '[{"a": 1, "b": 1}, {"a": 2, "b": 1}, {"a": 2, "b": 2}]' | from json | where a == 2 && b == 1 | to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#"[{"a": 2,"b": 1}]"#);
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -299,17 +276,9 @@ fn compound_where_paren() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo '[{"a": 1, "b": 1}, {"a": 2, "b": 1}, {"a": 2, "b": 2}]' | from json | where ($it.a == 2 && $it.b == 1) || $it.b == 2 | to json
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#"[{"a":2,"b":1},{"a":2,"b":2}]"#);
|
||||
=======
|
||||
echo '[{"a": 1, "b": 1}, {"a": 2, "b": 1}, {"a": 2, "b": 2}]' | from json | where ($it.a == 2 && $it.b == 1) || $it.b == 2 | to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#"[{"a": 2,"b": 1},{"a": 2,"b": 2}]"#);
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
21
crates/nu-command/tests/commands/math/round.rs
Normal file
21
crates/nu-command/tests/commands/math/round.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[test]
|
||||
fn can_round_very_large_numbers() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"echo 18.1372544780074142289927665486772012345 | math round"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "18")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_round_very_large_numbers_with_precision() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"echo 18.13725447800741422899276654867720121457878988 | math round -p 10"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "18.137254478")
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn can_sqrt_numbers() {
|
||||
let actual = nu!(
|
||||
@ -15,11 +12,8 @@ fn can_sqrt_numbers() {
|
||||
assert_eq!(actual.out, "3.914213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn can_sqrt_irrational() {
|
||||
let actual = nu!(
|
||||
|
@ -75,11 +75,8 @@ fn compute_sum_of_table() -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn sum_of_a_row_containing_a_table_is_an_error() {
|
||||
let actual = nu!(
|
||||
|
@ -2,11 +2,8 @@ use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn row() {
|
||||
Playground::setup("merge_test_1", |dirs, sandbox| {
|
||||
|
84
crates/nu-command/tests/commands/mkdir.rs
Normal file
84
crates/nu-command/tests/commands/mkdir.rs
Normal file
@ -0,0 +1,84 @@
|
||||
use nu_test_support::fs::files_exist_at;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
use std::path::Path;
|
||||
|
||||
#[test]
|
||||
fn creates_directory() {
|
||||
Playground::setup("mkdir_test_1", |dirs, _| {
|
||||
nu!(
|
||||
cwd: dirs.test(),
|
||||
"mkdir my_new_directory"
|
||||
);
|
||||
|
||||
let expected = dirs.test().join("my_new_directory");
|
||||
|
||||
assert!(expected.exists());
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn accepts_and_creates_directories() {
|
||||
Playground::setup("mkdir_test_2", |dirs, _| {
|
||||
nu!(
|
||||
cwd: dirs.test(),
|
||||
"mkdir dir_1 dir_2 dir_3"
|
||||
);
|
||||
|
||||
assert!(files_exist_at(
|
||||
vec![Path::new("dir_1"), Path::new("dir_2"), Path::new("dir_3")],
|
||||
dirs.test()
|
||||
));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn creates_intermediary_directories() {
|
||||
Playground::setup("mkdir_test_3", |dirs, _| {
|
||||
nu!(
|
||||
cwd: dirs.test(),
|
||||
"mkdir some_folder/another/deeper_one"
|
||||
);
|
||||
|
||||
let expected = dirs.test().join("some_folder/another/deeper_one");
|
||||
|
||||
assert!(expected.exists());
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_directory_two_parents_up_using_multiple_dots() {
|
||||
Playground::setup("mkdir_test_4", |dirs, sandbox| {
|
||||
sandbox.within("foo").mkdir("bar");
|
||||
|
||||
nu!(
|
||||
cwd: dirs.test().join("foo/bar"),
|
||||
"mkdir .../boo"
|
||||
);
|
||||
|
||||
let expected = dirs.test().join("boo");
|
||||
|
||||
assert!(expected.exists());
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn show_created_paths() {
|
||||
Playground::setup("mkdir_test_2", |dirs, _| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
pipeline(
|
||||
r#"
|
||||
mkdir -s dir_1 dir_2 dir_3
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(files_exist_at(
|
||||
vec![Path::new("dir_1"), Path::new("dir_2"), Path::new("dir_3")],
|
||||
dirs.test()
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "3");
|
||||
})
|
||||
}
|
@ -4,10 +4,6 @@ mod append;
|
||||
mod cal;
|
||||
mod cd;
|
||||
mod compact;
|
||||
<<<<<<< HEAD
|
||||
mod config;
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
mod cp;
|
||||
mod def;
|
||||
mod default;
|
||||
@ -27,10 +23,6 @@ mod hash_;
|
||||
mod headers;
|
||||
mod help;
|
||||
mod histogram;
|
||||
<<<<<<< HEAD
|
||||
mod insert;
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
mod into_filesize;
|
||||
mod into_int;
|
||||
mod keep;
|
||||
@ -42,17 +34,10 @@ mod math;
|
||||
mod merge;
|
||||
mod mkdir;
|
||||
mod move_;
|
||||
<<<<<<< HEAD
|
||||
mod open;
|
||||
mod parse;
|
||||
mod path;
|
||||
mod pathvar;
|
||||
=======
|
||||
mod nth;
|
||||
mod open;
|
||||
mod parse;
|
||||
mod path;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
mod prepend;
|
||||
mod random;
|
||||
mod range;
|
||||
|
@ -34,11 +34,8 @@ fn moves_a_column_before() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn moves_columns_before() {
|
||||
Playground::setup("move_column_test_2", |dirs, sandbox| {
|
||||
@ -73,11 +70,8 @@ fn moves_columns_before() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn moves_a_column_after() {
|
||||
Playground::setup("move_column_test_3", |dirs, sandbox| {
|
||||
@ -113,11 +107,8 @@ fn moves_a_column_after() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn moves_columns_after() {
|
||||
Playground::setup("move_column_test_4", |dirs, sandbox| {
|
||||
|
2
crates/nu-command/tests/commands/move_/mod.rs
Normal file
2
crates/nu-command/tests/commands/move_/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
mod column;
|
||||
mod mv;
|
@ -195,11 +195,8 @@ fn moves_a_directory_with_files() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_source_doesnt_exist() {
|
||||
Playground::setup("mv_test_10", |dirs, sandbox| {
|
||||
@ -212,11 +209,8 @@ fn errors_if_source_doesnt_exist() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_destination_doesnt_exist() {
|
||||
Playground::setup("mv_test_10_1", |dirs, sandbox| {
|
||||
@ -231,11 +225,8 @@ fn errors_if_destination_doesnt_exist() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_multiple_sources_but_destination_not_a_directory() {
|
||||
Playground::setup("mv_test_10_2", |dirs, sandbox| {
|
||||
@ -256,11 +247,8 @@ fn errors_if_multiple_sources_but_destination_not_a_directory() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_renaming_directory_to_an_existing_file() {
|
||||
Playground::setup("mv_test_10_3", |dirs, sandbox| {
|
||||
@ -277,11 +265,8 @@ fn errors_if_renaming_directory_to_an_existing_file() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_moving_to_itself() {
|
||||
Playground::setup("mv_test_10_4", |dirs, sandbox| {
|
||||
|
@ -1,10 +1,7 @@
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn selects_a_row() {
|
||||
Playground::setup("nth_test_1", |dirs, sandbox| {
|
||||
|
@ -185,22 +185,6 @@ fn parses_json() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
<<<<<<< HEAD
|
||||
fn parses_xml() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
"open jonathan.xml | get rss.children.channel.children | get item.children | get link.children.0"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"http://www.jonathanturner.org/2015/10/off-to-new-adventures.html"
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
fn parses_ini() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
@ -214,21 +198,14 @@ fn parses_ini() {
|
||||
fn parses_utf16_ini() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
<<<<<<< HEAD
|
||||
"open utf16.ini | rename info | get info | get IconIndex"
|
||||
=======
|
||||
"open ./utf16.ini --raw | decode utf-16 | from ini | rename info | get info | get IconIndex"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "-236")
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_file_not_found() {
|
||||
let actual = nu!(
|
||||
@ -244,11 +221,8 @@ fn errors_if_file_not_found() {
|
||||
);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: I think `open` on a directory is confusing. We should make discuss this one a bit more
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn open_dir_is_ls() {
|
||||
Playground::setup("open_dir", |dirs, sandbox| {
|
||||
|
@ -5,11 +5,8 @@ use nu_test_support::{nu, pipeline};
|
||||
mod simple {
|
||||
use super::*;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn extracts_fields_from_the_given_the_pattern() {
|
||||
Playground::setup("parse_test_1", |dirs, sandbox| {
|
||||
@ -86,11 +83,8 @@ mod simple {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_when_missing_closing_brace() {
|
||||
Playground::setup("parse_test_regex_5", |dirs, _sandbox| {
|
||||
|
83
crates/nu-command/tests/commands/path/basename.rs
Normal file
83
crates/nu-command/tests/commands/path/basename.rs
Normal file
@ -0,0 +1,83 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
use super::join_path_sep;
|
||||
|
||||
#[test]
|
||||
fn returns_basename_of_empty_input() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo ""
|
||||
| path basename
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_basename_of_empty_input() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo ""
|
||||
| path basename -r newname.txt
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "newname.txt");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_basename_of_path_ending_with_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/file.txt/."
|
||||
| path basename
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "file.txt");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_basename_of_path_ending_with_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/file.txt/."
|
||||
| path basename -r viking.txt
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["some", "viking.txt"]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_basename_of_path_ending_with_double_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/file.txt/.."
|
||||
| path basename
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_basename_of_path_ending_with_double_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/file.txt/.."
|
||||
| path basename -r eggs
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["some/file.txt/..", "eggs"]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
137
crates/nu-command/tests/commands/path/dirname.rs
Normal file
137
crates/nu-command/tests/commands/path/dirname.rs
Normal file
@ -0,0 +1,137 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
use super::join_path_sep;
|
||||
|
||||
#[test]
|
||||
fn returns_dirname_of_empty_input() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo ""
|
||||
| path dirname
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_dirname_of_empty_input() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo ""
|
||||
| path dirname -r newdir
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "newdir");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_dirname_of_path_ending_with_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/."
|
||||
| path dirname
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "some");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_dirname_of_path_ending_with_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/."
|
||||
| path dirname -r eggs
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["eggs", "dir"]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_dirname_of_path_ending_with_double_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/.."
|
||||
| path dirname
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "some/dir");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_dirname_of_path_with_double_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/.."
|
||||
| path dirname -r eggs
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["eggs", ".."]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_dirname_of_zero_levels() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/with/spam.txt"
|
||||
| path dirname -n 0
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "some/dir/with/spam.txt");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_dirname_of_zero_levels_with_empty_string() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/with/spam.txt"
|
||||
| path dirname -n 0 -r ""
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_dirname_of_more_levels() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/with/spam.txt"
|
||||
| path dirname -r eggs -n 2
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["eggs", "with/spam.txt"]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_dirname_of_way_too_many_levels() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/with/spam.txt"
|
||||
| path dirname -r eggs -n 999
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["eggs", "some/dir/with/spam.txt"]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
@ -2,11 +2,8 @@ use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn checks_if_existing_file_exists() {
|
||||
Playground::setup("path_exists_1", |dirs, sandbox| {
|
||||
|
78
crates/nu-command/tests/commands/path/expand.rs
Normal file
78
crates/nu-command/tests/commands/path/expand.rs
Normal file
@ -0,0 +1,78 @@
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[test]
|
||||
fn expands_path_with_dot() {
|
||||
Playground::setup("path_expand_1", |dirs, sandbox| {
|
||||
sandbox
|
||||
.within("menu")
|
||||
.with_files(vec![EmptyFile("spam.txt")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
echo "menu/./spam.txt"
|
||||
| path expand
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = dirs.test.join("menu").join("spam.txt");
|
||||
assert_eq!(PathBuf::from(actual.out), expected);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn expands_path_with_double_dot() {
|
||||
Playground::setup("path_expand_2", |dirs, sandbox| {
|
||||
sandbox
|
||||
.within("menu")
|
||||
.with_files(vec![EmptyFile("spam.txt")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
echo "menu/../menu/spam.txt"
|
||||
| path expand
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = dirs.test.join("menu").join("spam.txt");
|
||||
assert_eq!(PathBuf::from(actual.out), expected);
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
mod windows {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn expands_path_with_tilde_backward_slash() {
|
||||
Playground::setup("path_expand_2", |dirs, _| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
echo "~\tmp.txt" | path expand
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(!PathBuf::from(actual.out).starts_with("~"));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn win_expands_path_with_tilde_forward_slash() {
|
||||
Playground::setup("path_expand_2", |dirs, _| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
echo "~/tmp.txt" | path expand
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(!PathBuf::from(actual.out).starts_with("~"));
|
||||
})
|
||||
}
|
||||
}
|
59
crates/nu-command/tests/commands/path/join.rs
Normal file
59
crates/nu-command/tests/commands/path/join.rs
Normal file
@ -0,0 +1,59 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
use super::join_path_sep;
|
||||
|
||||
#[test]
|
||||
fn returns_path_joined_with_column_path() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo [ [name]; [eggs] ]
|
||||
| path join spam.txt -c [ name ]
|
||||
| get name
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["eggs", "spam.txt"]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_path_joined_from_list() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo [ home viking spam.txt ]
|
||||
| path join
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["home", "viking", "spam.txt"]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn appends_slash_when_joined_with_empty_path() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "/some/dir"
|
||||
| path join ''
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["/some/dir", ""]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_joined_path_when_joining_empty_path() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo ""
|
||||
| path join foo.txt
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "foo.txt");
|
||||
}
|
34
crates/nu-command/tests/commands/path/mod.rs
Normal file
34
crates/nu-command/tests/commands/path/mod.rs
Normal file
@ -0,0 +1,34 @@
|
||||
mod basename;
|
||||
mod dirname;
|
||||
mod exists;
|
||||
mod expand;
|
||||
mod join;
|
||||
mod parse;
|
||||
mod split;
|
||||
mod type_;
|
||||
|
||||
use std::path::MAIN_SEPARATOR;
|
||||
|
||||
/// Helper function that joins string literals with '/' or '\', based on host OS
|
||||
fn join_path_sep(pieces: &[&str]) -> String {
|
||||
let sep_string = String::from(MAIN_SEPARATOR);
|
||||
pieces.join(&sep_string)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
#[test]
|
||||
fn joins_path_on_windows() {
|
||||
let pieces = ["sausage", "bacon", "spam"];
|
||||
let actual = join_path_sep(&pieces);
|
||||
|
||||
assert_eq!(&actual, "sausage\\bacon\\spam");
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
#[test]
|
||||
fn joins_path_on_other_than_windows() {
|
||||
let pieces = ["sausage", "bacon", "spam"];
|
||||
let actual = join_path_sep(&pieces);
|
||||
|
||||
assert_eq!(&actual, "sausage/bacon/spam");
|
||||
}
|
@ -114,11 +114,8 @@ fn parses_column_path_extension() {
|
||||
assert_eq!(actual.out, "png");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn parses_into_correct_number_of_columns() {
|
||||
let actual = nu!(
|
||||
|
@ -17,11 +17,7 @@ fn splits_correctly_single_path() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo ['home/viking/spam.txt']
|
||||
=======
|
||||
'home/viking/spam.txt'
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| path split
|
||||
| last
|
||||
"#
|
||||
@ -43,10 +39,7 @@ fn splits_correctly_with_column_path() {
|
||||
]
|
||||
| path split -c [ home barn ]
|
||||
| get barn
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
| flatten
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
@ -15,11 +15,8 @@ fn returns_type_of_missing_file() {
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn returns_type_of_existing_file() {
|
||||
Playground::setup("path_expand_1", |dirs, sandbox| {
|
||||
@ -35,19 +32,12 @@ fn returns_type_of_existing_file() {
|
||||
"#
|
||||
));
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert_eq!(actual.out, "Dir");
|
||||
})
|
||||
}
|
||||
|
||||
=======
|
||||
assert_eq!(actual.out, "dir");
|
||||
})
|
||||
}
|
||||
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn returns_type_of_existing_directory() {
|
||||
Playground::setup("path_expand_1", |dirs, sandbox| {
|
||||
@ -63,10 +53,6 @@ fn returns_type_of_existing_directory() {
|
||||
"#
|
||||
));
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert_eq!(actual.out, "File");
|
||||
=======
|
||||
assert_eq!(actual.out, "file");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
})
|
||||
}
|
||||
|
29
crates/nu-command/tests/commands/prepend.rs
Normal file
29
crates/nu-command/tests/commands/prepend.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn adds_a_row_to_the_beginning() {
|
||||
Playground::setup("prepend_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"los_tres_caballeros.txt",
|
||||
r#"
|
||||
Andrés N. Robalino
|
||||
Jonathan Turner
|
||||
Yehuda Katz
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open los_tres_caballeros.txt
|
||||
| lines
|
||||
| prepend "pollo loco"
|
||||
| nth 0
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "pollo loco");
|
||||
})
|
||||
}
|
16
crates/nu-command/tests/commands/random/bool.rs
Normal file
16
crates/nu-command/tests/commands/random/bool.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn generates_a_bool() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
random bool
|
||||
"#
|
||||
));
|
||||
|
||||
let output = actual.out;
|
||||
let is_boolean_output = output == "true" || output == "false";
|
||||
|
||||
assert!(is_boolean_output);
|
||||
}
|
14
crates/nu-command/tests/commands/random/chars.rs
Normal file
14
crates/nu-command/tests/commands/random/chars.rs
Normal file
@ -0,0 +1,14 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn generates_chars_of_specified_length() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
random chars -l 15 | size | get chars
|
||||
"#
|
||||
));
|
||||
|
||||
let result = actual.out;
|
||||
assert_eq!(result, "15");
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn generates_an_decimal() {
|
||||
let actual = nu!(
|
||||
@ -17,11 +14,8 @@ fn generates_an_decimal() {
|
||||
assert!(actual.out.contains("42") || actual.out.contains("43"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn generates_55() {
|
||||
let actual = nu!(
|
||||
@ -34,11 +28,8 @@ fn generates_55() {
|
||||
assert!(actual.out.contains("55"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn generates_0() {
|
||||
let actual = nu!(
|
||||
|
13
crates/nu-command/tests/commands/random/dice.rs
Normal file
13
crates/nu-command/tests/commands/random/dice.rs
Normal file
@ -0,0 +1,13 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn rolls_4_roll() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
random dice -d 4 -s 10 | length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4");
|
||||
}
|
@ -24,11 +24,8 @@ fn generates_55() {
|
||||
assert!(actual.out.contains("55"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn generates_0() {
|
||||
let actual = nu!(
|
||||
|
7
crates/nu-command/tests/commands/random/mod.rs
Normal file
7
crates/nu-command/tests/commands/random/mod.rs
Normal file
@ -0,0 +1,7 @@
|
||||
mod bool;
|
||||
mod chars;
|
||||
mod decimal;
|
||||
mod dice;
|
||||
mod integer;
|
||||
#[cfg(feature = "uuid_crate")]
|
||||
mod uuid;
|
16
crates/nu-command/tests/commands/random/uuid.rs
Normal file
16
crates/nu-command/tests/commands/random/uuid.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
use uuid_crate::Uuid;
|
||||
|
||||
#[test]
|
||||
fn generates_valid_uuid4() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
random uuid
|
||||
"#
|
||||
));
|
||||
|
||||
let result = Uuid::parse_str(actual.out.as_str());
|
||||
|
||||
assert!(result.is_ok());
|
||||
}
|
68
crates/nu-command/tests/commands/range.rs
Normal file
68
crates/nu-command/tests/commands/range.rs
Normal file
@ -0,0 +1,68 @@
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn selects_a_row() {
|
||||
Playground::setup("range_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("notes.txt"), EmptyFile("tests.txt")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| sort-by name
|
||||
| range 0..0
|
||||
| get name
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "notes.txt");
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn selects_some_rows() {
|
||||
Playground::setup("range_test_2", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("notes.txt"),
|
||||
EmptyFile("tests.txt"),
|
||||
EmptyFile("persons.txt"),
|
||||
]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| get name
|
||||
| range 1..2
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "2");
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn negative_indices() {
|
||||
Playground::setup("range_test_negative_indices", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("notes.txt"),
|
||||
EmptyFile("tests.txt"),
|
||||
EmptyFile("persons.txt"),
|
||||
]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| get name
|
||||
| range (-1..)
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
});
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn reduce_table_column() {
|
||||
let actual = nu!(
|
||||
@ -13,11 +10,7 @@ fn reduce_table_column() {
|
||||
echo "[{month:2,total:30}, {month:3,total:10}, {month:4,total:3}, {month:5,total:60}]"
|
||||
| from json
|
||||
| get total
|
||||
<<<<<<< HEAD
|
||||
| reduce -f 20 { $it + (math eval $"($acc)^1.05")}
|
||||
=======
|
||||
| reduce -f 20 { $it.item + (math eval $"($item.acc)^1.05")}
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| into string -d 1
|
||||
"#
|
||||
)
|
||||
@ -26,24 +19,15 @@ fn reduce_table_column() {
|
||||
assert_eq!(actual.out, "180.6");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn reduce_table_column_with_path() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo "[{month:2,total:30}, {month:3,total:10}, {month:4,total:3}, {month:5,total:60}]"
|
||||
| from json
|
||||
| reduce -f 20 { $it.total + (math eval $"($acc)^1.05")}
|
||||
=======
|
||||
[{month:2,total:30}, {month:3,total:10}, {month:4,total:3}, {month:5,total:60}]
|
||||
| reduce -f 20 { $it.item.total + (math eval $"($item.acc)^1.05")}
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| into string -d 1
|
||||
"#
|
||||
)
|
||||
@ -52,25 +36,15 @@ fn reduce_table_column_with_path() {
|
||||
assert_eq!(actual.out, "180.6");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn reduce_rows_example() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo a,b 1,2 3,4
|
||||
| split column ,
|
||||
| headers
|
||||
| reduce -f 1.6 { $acc * ($it.a | str to-int) + ($it.b | str to-int) }
|
||||
=======
|
||||
[[a,b]; [1,2] [3,4]]
|
||||
| reduce -f 1.6 { $it.acc * ($it.item.a | into int) + ($it.item.b | into int) }
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
)
|
||||
);
|
||||
@ -78,22 +52,15 @@ fn reduce_rows_example() {
|
||||
assert_eq!(actual.out, "14.8");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn reduce_numbered_example() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo one longest three bar
|
||||
<<<<<<< HEAD
|
||||
| reduce -n { if ($it.item | str length) > ($acc.item | str length) {echo $it} {echo $acc}}
|
||||
=======
|
||||
| reduce -n { if ($it.item.item | str length) > ($it.acc.item | str length) {echo $it.item} else {echo $it.acc}}
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get index
|
||||
"#
|
||||
)
|
||||
@ -102,22 +69,15 @@ fn reduce_numbered_example() {
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn reduce_numbered_integer_addition_example() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [1 2 3 4]
|
||||
<<<<<<< HEAD
|
||||
| reduce -n { $acc.item + $it.item }
|
||||
=======
|
||||
| reduce -n { $it.acc.item + $it.item.item }
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get item
|
||||
"#
|
||||
)
|
||||
@ -126,11 +86,8 @@ fn reduce_numbered_integer_addition_example() {
|
||||
assert_eq!(actual.out, "10");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn folding_with_tables() {
|
||||
let actual = nu!(
|
||||
@ -138,13 +95,8 @@ fn folding_with_tables() {
|
||||
r#"
|
||||
echo [10 20 30 40]
|
||||
| reduce -f [] {
|
||||
<<<<<<< HEAD
|
||||
with-env [value $it] {
|
||||
echo $acc | append (10 * ($nu.env.value | str to-int))
|
||||
=======
|
||||
with-env [value $it.item] {
|
||||
echo $acc | append (10 * ($env.value | into int))
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
}
|
||||
| math sum
|
||||
@ -155,46 +107,29 @@ fn folding_with_tables() {
|
||||
assert_eq!(actual.out, "1000");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn error_reduce_fold_type_mismatch() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo a b c | reduce -f 0 { $acc + $it }
|
||||
=======
|
||||
echo a b c | reduce -f 0 { $it.acc + $it.item }
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert!(actual.err.contains("Coercion"));
|
||||
}
|
||||
|
||||
=======
|
||||
assert!(actual.err.contains("mismatch"));
|
||||
}
|
||||
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn error_reduce_empty() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
reduce { $acc + $it }
|
||||
=======
|
||||
reduce { $it.$acc + $it.item }
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
@ -61,11 +61,8 @@ fn keeps_remaining_original_names_given_less_new_names_than_total_original_names
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_no_columns_present() {
|
||||
Playground::setup("rename_test_3", |dirs, sandbox| {
|
||||
|
11
crates/nu-command/tests/commands/reverse.rs
Normal file
11
crates/nu-command/tests/commands/reverse.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[test]
|
||||
fn can_get_reverse_first() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
"ls | sort-by name | reverse | first 1 | get name | str trim "
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "utf16.ini");
|
||||
}
|
@ -121,11 +121,8 @@ fn removes_directory_contents_with_recursive_flag() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_attempting_to_delete_a_directory_with_content_without_recursive_flag() {
|
||||
Playground::setup("rm_test_6", |dirs, sandbox| {
|
||||
@ -140,11 +137,8 @@ fn errors_if_attempting_to_delete_a_directory_with_content_without_recursive_fla
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_attempting_to_delete_single_dot_as_argument() {
|
||||
Playground::setup("rm_test_7", |dirs, _| {
|
||||
@ -157,11 +151,8 @@ fn errors_if_attempting_to_delete_single_dot_as_argument() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_attempting_to_delete_two_dot_as_argument() {
|
||||
Playground::setup("rm_test_8", |dirs, _| {
|
||||
@ -292,11 +283,8 @@ fn no_errors_if_attempting_to_delete_non_existent_file_with_f_flag() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn rm_wildcard_keeps_dotfiles() {
|
||||
Playground::setup("rm_test_15", |dirs, sandbox| {
|
||||
|
@ -17,11 +17,8 @@ mod rows {
|
||||
)
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn roll_down_by_default() {
|
||||
let actual = nu!(
|
||||
@ -35,11 +32,8 @@ mod rows {
|
||||
assert_eq!(actual.out, "HERE");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn can_roll_up() {
|
||||
let actual = nu!(
|
||||
@ -72,11 +66,8 @@ mod columns {
|
||||
)
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn roll_left_by_default() {
|
||||
let actual = nu!(
|
||||
@ -90,11 +81,8 @@ mod columns {
|
||||
assert_eq!(actual.out, "origin-stars-commit_author");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn can_roll_in_the_opposite_direction() {
|
||||
let actual = nu!(
|
||||
@ -110,11 +98,8 @@ mod columns {
|
||||
|
||||
struct ThirtieTwo<'a>(usize, &'a str);
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn can_roll_the_cells_only_keeping_the_header_names() {
|
||||
let four_bitstring = bitstring_to_nu_row_pipeline("00000100");
|
||||
@ -128,11 +113,8 @@ mod columns {
|
||||
assert_eq!(actual.out, expected_value.1);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn four_in_bitstring_left_shifted_with_three_bits_should_be_32_in_decimal() {
|
||||
let four_bitstring = "00000100";
|
||||
@ -185,11 +167,7 @@ mod columns {
|
||||
pipeline(
|
||||
r#"
|
||||
split chars
|
||||
<<<<<<< HEAD
|
||||
| each { str to-int }
|
||||
=======
|
||||
| each { into int }
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| rotate counter-clockwise _
|
||||
| reject _
|
||||
| rename bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit8
|
||||
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn counter_clockwise() {
|
||||
let table = pipeline(
|
||||
|
@ -48,11 +48,8 @@ fn writes_out_csv() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn save_append_will_create_file_if_not_exists() {
|
||||
Playground::setup("save_test_3", |dirs, sandbox| {
|
||||
|
@ -22,11 +22,8 @@ fn regular_columns() {
|
||||
assert_eq!(actual.out, "Robalino");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn complex_nested_columns() {
|
||||
Playground::setup("select_test_2", |dirs, sandbox| {
|
||||
@ -69,11 +66,8 @@ fn complex_nested_columns() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn allows_if_given_unknown_column_name_is_missing() {
|
||||
let actual = nu!(cwd: ".", pipeline(
|
||||
@ -112,11 +106,8 @@ fn column_names_with_spaces() {
|
||||
assert_eq!(actual.out, "Robalino Jnth");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn ignores_duplicate_columns_selected() {
|
||||
let actual = nu!(cwd: ".", pipeline(
|
||||
|
29
crates/nu-command/tests/commands/semicolon.rs
Normal file
29
crates/nu-command/tests/commands/semicolon.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn semicolon_allows_lhs_to_complete() {
|
||||
Playground::setup("create_test_1", |dirs, _sandbox| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"touch i_will_be_created_semi.txt; echo done"
|
||||
);
|
||||
|
||||
let path = dirs.test().join("i_will_be_created_semi.txt");
|
||||
|
||||
assert!(path.exists());
|
||||
assert_eq!(actual.out, "done");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn semicolon_lhs_error_stops_processing() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
where 1 1; echo done
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(!actual.out.contains("done"));
|
||||
}
|
2
crates/nu-command/tests/commands/skip/mod.rs
Normal file
2
crates/nu-command/tests/commands/skip/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
mod until;
|
||||
mod while_;
|
@ -10,11 +10,7 @@ fn condition_is_met() {
|
||||
r#"
|
||||
CHICKEN SUMMARY report date: April 29th, 2020
|
||||
--------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020,
|
||||
=======
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
Yellow Chickens,,,
|
||||
Andrés,0,0,1
|
||||
Jonathan,0,0,1
|
||||
@ -36,16 +32,6 @@ fn condition_is_met() {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
open --raw caballeros.txt
|
||||
| lines
|
||||
| skip 2
|
||||
| split column ','
|
||||
| headers
|
||||
| skip until "Chicken Collection" == "Red Chickens"
|
||||
| skip 1
|
||||
| str to-int "31/04/2020"
|
||||
=======
|
||||
open --raw ./caballeros.txt
|
||||
| lines
|
||||
| skip 2
|
||||
@ -55,7 +41,6 @@ fn condition_is_met() {
|
||||
| skip until "Chicken Collection" == "Red Chickens"
|
||||
| skip 1
|
||||
| into int "31/04/2020"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get "31/04/2020"
|
||||
| math sum
|
||||
"#
|
||||
|
@ -10,11 +10,7 @@ fn condition_is_met() {
|
||||
r#"
|
||||
CHICKEN SUMMARY report date: April 29th, 2020
|
||||
--------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020,
|
||||
=======
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
Yellow Chickens,,,
|
||||
Andrés,0,0,1
|
||||
Jonathan,0,0,1
|
||||
@ -37,15 +33,6 @@ fn condition_is_met() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open --raw caballeros.txt
|
||||
<<<<<<< HEAD
|
||||
| lines
|
||||
| skip 2
|
||||
| split column ','
|
||||
| headers
|
||||
| skip while "Chicken Collection" != "Red Chickens"
|
||||
| skip 1
|
||||
| str to-int "31/04/2020"
|
||||
=======
|
||||
| lines
|
||||
| skip 2
|
||||
| str trim
|
||||
@ -54,7 +41,6 @@ fn condition_is_met() {
|
||||
| skip while "Chicken Collection" != "Red Chickens"
|
||||
| skip 1
|
||||
| into int "31/04/2020"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get "31/04/2020"
|
||||
| math sum
|
||||
"#
|
||||
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn by_column() {
|
||||
let actual = nu!(
|
||||
@ -26,11 +23,8 @@ fn by_column() {
|
||||
assert_eq!(actual.out, "description");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn by_invalid_column() {
|
||||
let actual = nu!(
|
||||
@ -53,11 +47,8 @@ fn by_invalid_column() {
|
||||
assert!(actual.err.contains("invalid column"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn by_invalid_types() {
|
||||
let actual = nu!(
|
||||
@ -100,20 +91,12 @@ fn ls_sort_by_name_sensitive() {
|
||||
open sample-ls-output.json
|
||||
| sort-by name
|
||||
| select name
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
"#
|
||||
));
|
||||
|
||||
let json_output = r#"[{"name":"B.txt"},{"name":"C"},{"name":"a.txt"}]"#;
|
||||
=======
|
||||
| to json --raw
|
||||
"#
|
||||
));
|
||||
|
||||
//let json_output = r#"[{"name":"B.txt"},{"name":"C"},{"name":"a.txt"}]"#;
|
||||
let json_output = r#"[{"name": "B.txt"},{"name": "C"},{"name": "a.txt"}]"#;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
||||
assert_eq!(actual.out, json_output);
|
||||
}
|
||||
@ -126,20 +109,11 @@ fn ls_sort_by_name_insensitive() {
|
||||
open sample-ls-output.json
|
||||
| sort-by -i name
|
||||
| select name
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
"#
|
||||
));
|
||||
|
||||
let json_output = r#"[{"name":"a.txt"},{"name":"B.txt"},{"name":"C"}]"#;
|
||||
|
||||
=======
|
||||
| to json --raw
|
||||
"#
|
||||
));
|
||||
|
||||
let json_output = r#"[{"name": "B.txt"},{"name": "C"},{"name": "a.txt"}]"#;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
assert_eq!(actual.out, json_output);
|
||||
}
|
||||
|
||||
@ -151,20 +125,11 @@ fn ls_sort_by_type_name_sensitive() {
|
||||
open sample-ls-output.json
|
||||
| sort-by type name
|
||||
| select name type
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
"#
|
||||
));
|
||||
|
||||
let json_output = r#"[{"name":"C","type":"Dir"},{"name":"B.txt","type":"File"},{"name":"a.txt","type":"File"}]"#;
|
||||
|
||||
=======
|
||||
| to json --raw
|
||||
"#
|
||||
));
|
||||
|
||||
let json_output = r#"[{"name": "C","type": "Dir"},{"name": "a.txt","type": "File"},{"name": "B.txt","type": "File"}]"#;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
assert_eq!(actual.out, json_output);
|
||||
}
|
||||
|
||||
@ -176,19 +141,10 @@ fn ls_sort_by_type_name_insensitive() {
|
||||
open sample-ls-output.json
|
||||
| sort-by -i type name
|
||||
| select name type
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
"#
|
||||
));
|
||||
|
||||
let json_output = r#"[{"name":"C","type":"Dir"},{"name":"a.txt","type":"File"},{"name":"B.txt","type":"File"}]"#;
|
||||
|
||||
=======
|
||||
| to json --raw
|
||||
"#
|
||||
));
|
||||
|
||||
let json_output = r#"[{"name": "C","type": "Dir"},{"name": "a.txt","type": "File"},{"name": "B.txt","type": "File"}]"#;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
assert_eq!(actual.out, json_output);
|
||||
}
|
||||
|
@ -1,15 +1,7 @@
|
||||
use nu_test_support::fs::{AbsolutePath, DisplayPath, Stub::FileWithContent};
|
||||
use nu_test_support::nu;
|
||||
<<<<<<< HEAD
|
||||
use nu_test_support::pipeline as input;
|
||||
use nu_test_support::playground::{says, Playground};
|
||||
|
||||
use hamcrest2::assert_that;
|
||||
use hamcrest2::prelude::*;
|
||||
=======
|
||||
use nu_test_support::pipeline;
|
||||
use nu_test_support::playground::Playground;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
||||
#[should_panic]
|
||||
#[test]
|
||||
@ -45,18 +37,6 @@ fn sources_also_files_under_custom_lib_dirs_path() {
|
||||
"#,
|
||||
)]);
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
source my_library.nu ;
|
||||
|
||||
hello
|
||||
"#,
|
||||
)),
|
||||
says().stdout("hello nu")
|
||||
);
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
@ -67,7 +47,6 @@ fn sources_also_files_under_custom_lib_dirs_path() {
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "hello nu");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
})
|
||||
}
|
||||
|
||||
@ -122,11 +101,8 @@ fn try_source_foo_without_quotes_in(testdir: &str, playdir: &str) {
|
||||
});
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn sources_unicode_file_in_normal_dir() {
|
||||
try_source_foo_with_single_quotes_in("foo", "source_test_1");
|
||||
@ -134,11 +110,8 @@ fn sources_unicode_file_in_normal_dir() {
|
||||
try_source_foo_without_quotes_in("foo", "source_test_3");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn sources_unicode_file_in_unicode_dir_without_spaces_1() {
|
||||
try_source_foo_with_single_quotes_in("🚒", "source_test_4");
|
||||
@ -146,11 +119,8 @@ fn sources_unicode_file_in_unicode_dir_without_spaces_1() {
|
||||
try_source_foo_without_quotes_in("🚒", "source_test_6");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[cfg(not(windows))] // ':' is not allowed in Windows paths
|
||||
#[test]
|
||||
fn sources_unicode_file_in_unicode_dir_without_spaces_2() {
|
||||
@ -159,22 +129,16 @@ fn sources_unicode_file_in_unicode_dir_without_spaces_2() {
|
||||
try_source_foo_without_quotes_in(":fire_engine:", "source_test_9");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn sources_unicode_file_in_unicode_dir_with_spaces_1() {
|
||||
try_source_foo_with_single_quotes_in("e-$ èрт🚒♞中片-j", "source_test_8");
|
||||
try_source_foo_with_double_quotes_in("e-$ èрт🚒♞中片-j", "source_test_9");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[cfg(not(windows))] // ':' is not allowed in Windows paths
|
||||
#[test]
|
||||
fn sources_unicode_file_in_unicode_dir_with_spaces_2() {
|
||||
|
@ -49,10 +49,6 @@ fn errors_if_no_table_given_as_input() {
|
||||
"#
|
||||
));
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert!(actual.err.contains("Expected table from pipeline"));
|
||||
=======
|
||||
assert!(actual.err.contains("requires a table"));
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
})
|
||||
}
|
||||
|
28
crates/nu-command/tests/commands/split_column.rs
Normal file
28
crates/nu-command/tests/commands/split_column.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn to_column() {
|
||||
Playground::setup("split_column_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"sample.txt",
|
||||
r#"
|
||||
importer,shipper,tariff_item,name,origin
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open sample.txt
|
||||
| lines
|
||||
| str trim
|
||||
| split column ","
|
||||
| get Column2
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("shipper"));
|
||||
})
|
||||
}
|
28
crates/nu-command/tests/commands/split_row.rs
Normal file
28
crates/nu-command/tests/commands/split_row.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn to_row() {
|
||||
Playground::setup("split_row_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"sample.txt",
|
||||
r#"
|
||||
importer,shipper,tariff_item,name,origin
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open sample.txt
|
||||
| lines
|
||||
| str trim
|
||||
| split row ","
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains('5'));
|
||||
})
|
||||
}
|
@ -44,18 +44,10 @@ fn sum_one_to_four() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 1..4 | into string | str collect "+" | math eval
|
||||
=======
|
||||
1..4 | each { $it } | into string | str collect "+" | math eval
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert!(actual.out.contains("10.0"));
|
||||
=======
|
||||
assert!(actual.out.contains("10"));
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
158
crates/nu-command/tests/commands/str_/into_string.rs
Normal file
158
crates/nu-command/tests/commands/str_/into_string.rs
Normal file
@ -0,0 +1,158 @@
|
||||
use nu_test_support::playground::{Dirs, Playground};
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn from_range() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 1..5 | into string | to json
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "[\"1\",\"2\",\"3\",\"4\",\"5\"]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_number() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 5 | into string
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "5");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_decimal() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 1.5 | into string
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "1.5");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_boolean() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo $true | into string
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_string() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo "one" | into string
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "one");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_filename() {
|
||||
Playground::setup("from_filename", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[dependency]
|
||||
name = "nu"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"ls sample.toml | get name | into string"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "sample.toml");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_filesize() {
|
||||
Playground::setup("from_filesize", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[dependency]
|
||||
name = "nu"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"ls sample.toml | get size | into string"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "25 B");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_decimal_correct_trailing_zeros() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
= 1.23000 | into string -d 3
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("1.230"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_int_decimal_correct_trailing_zeros() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
= 1.00000 | into string -d 3
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("1.000"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_int_decimal_trim_trailing_zeros() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
= 1.00000 | into string | format "{$it} flat"
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("1 flat")); // "1" would match "1.0"
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_table() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo '[{"name": "foo", "weight": 32.377}, {"name": "bar", "weight": 15.2}]'
|
||||
| from json
|
||||
| into string weight -d 2
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("32.38"));
|
||||
assert!(actual.out.contains("15.20"));
|
||||
}
|
@ -29,11 +29,7 @@ fn error_trim_multiple_chars() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 'does it work now?!' | str trim -c '?!'
|
||||
=======
|
||||
echo "does it work now?!" | str trim -c "?!"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
)
|
||||
);
|
||||
@ -128,11 +124,7 @@ fn converts_to_int() {
|
||||
r#"
|
||||
echo '{number_as_string: "1"}'
|
||||
| from json
|
||||
<<<<<<< HEAD
|
||||
| str to-int number_as_string
|
||||
=======
|
||||
| into int number_as_string
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| rename number
|
||||
| where number == 1
|
||||
| get number
|
||||
@ -150,11 +142,7 @@ fn converts_to_decimal() {
|
||||
r#"
|
||||
echo "3.1, 0.0415"
|
||||
| split row ","
|
||||
<<<<<<< HEAD
|
||||
| str to-decimal
|
||||
=======
|
||||
| into decimal
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| math sum
|
||||
"#
|
||||
));
|
||||
|
31
crates/nu-command/tests/commands/touch.rs
Normal file
31
crates/nu-command/tests/commands/touch.rs
Normal file
@ -0,0 +1,31 @@
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
|
||||
#[test]
|
||||
fn creates_a_file_when_it_doesnt_exist() {
|
||||
Playground::setup("create_test_1", |dirs, _sandbox| {
|
||||
nu!(
|
||||
cwd: dirs.test(),
|
||||
"touch i_will_be_created.txt"
|
||||
);
|
||||
|
||||
let path = dirs.test().join("i_will_be_created.txt");
|
||||
assert!(path.exists());
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn creates_two_files() {
|
||||
Playground::setup("create_test_2", |dirs, _sandbox| {
|
||||
nu!(
|
||||
cwd: dirs.test(),
|
||||
"touch a b"
|
||||
);
|
||||
|
||||
let path = dirs.test().join("a");
|
||||
assert!(path.exists());
|
||||
|
||||
let path2 = dirs.test().join("b");
|
||||
assert!(path2.exists());
|
||||
})
|
||||
}
|
@ -61,11 +61,8 @@ fn uniq_values() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn nested_json_structures() {
|
||||
Playground::setup("uniq_test_3", |dirs, sandbox| {
|
||||
@ -130,22 +127,14 @@ fn nested_json_structures() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn uniq_when_keys_out_of_order() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo '[{"a": "a", "b": [1,2,3]},{"b": [1,2,3], "a": "a"}]'
|
||||
| from json
|
||||
=======
|
||||
[{"a": "a", "b": [1,2,3]}, {"b": [1,2,3], "a": "a"}]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| uniq
|
||||
| length
|
||||
|
||||
@ -155,22 +144,14 @@ fn uniq_when_keys_out_of_order() {
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn uniq_counting() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo '["A", "B", "A"]'
|
||||
| from json
|
||||
=======
|
||||
["A", "B", "A"]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| wrap item
|
||||
| uniq --count
|
||||
| where item == A
|
||||
@ -182,12 +163,7 @@ fn uniq_counting() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo '["A", "B", "A"]'
|
||||
| from json
|
||||
=======
|
||||
echo ["A", "B", "A"]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| wrap item
|
||||
| uniq --count
|
||||
| where item == B
|
||||
|
60
crates/nu-command/tests/commands/update.rs
Normal file
60
crates/nu-command/tests/commands/update.rs
Normal file
@ -0,0 +1,60 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn sets_the_column() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open cargo_sample.toml
|
||||
| update dev-dependencies.pretty_assertions "0.7.0"
|
||||
| get dev-dependencies.pretty_assertions
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "0.7.0");
|
||||
}
|
||||
|
||||
#[cfg(features = "inc")]
|
||||
#[test]
|
||||
fn sets_the_column_from_a_block_run_output() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open cargo_sample.toml
|
||||
| update dev-dependencies.pretty_assertions { open cargo_sample.toml | get dev-dependencies.pretty_assertions | inc --minor }
|
||||
| get dev-dependencies.pretty_assertions
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "0.7.0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sets_the_column_from_a_block_full_stream_output() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
wrap content
|
||||
| update content { open --raw cargo_sample.toml | lines | first 5 }
|
||||
| get content.1
|
||||
| str contains "nu"
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sets_the_column_from_a_subexpression() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
wrap content
|
||||
| update content (open --raw cargo_sample.toml | lines | first 5)
|
||||
| get content.1
|
||||
| str contains "nu"
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
}
|
166
crates/nu-command/tests/commands/where_.rs
Normal file
166
crates/nu-command/tests/commands/where_.rs
Normal file
@ -0,0 +1,166 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
use nu_test_support::pipeline;
|
||||
|
||||
#[test]
|
||||
fn filters_by_unit_size_comparison() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
"ls | where size > 1kib | sort-by size | get name | first 1 | str trim"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "cargo_sample.toml");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn filters_with_nothing_comparison() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
r#"echo '[{"foo": 3}, {"foo": null}, {"foo": 4}]' | from json | get foo | compact | where $it > 1 | math sum"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "7");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn where_in_table() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
r#"echo '[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name in ["foo"] | get size | math sum"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "5");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn where_not_in_table() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
r#"echo '[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name not-in ["foo"] | get size | math sum"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "4");
|
||||
}
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
#[test]
|
||||
fn explicit_block_condition() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| first 4
|
||||
| where {= $it.z > 4200}
|
||||
| get z
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4253");
|
||||
}
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
#[test]
|
||||
fn binary_operator_comparisons() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| first 4
|
||||
| where z > 4200
|
||||
| get z
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4253");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| first 4
|
||||
| where z >= 4253
|
||||
| get z
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4253");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| first 4
|
||||
| where z < 10
|
||||
| get z
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| first 4
|
||||
| where z <= 1
|
||||
| get z
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| where z != 1
|
||||
| first 1
|
||||
| get z
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "42");
|
||||
}
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
#[test]
|
||||
fn contains_operator() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == strings
|
||||
| get table_values
|
||||
| where x =~ ell
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == strings
|
||||
| get table_values
|
||||
| where x !~ ell
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "2");
|
||||
}
|
96
crates/nu-command/tests/commands/which.rs
Normal file
96
crates/nu-command/tests/commands/which.rs
Normal file
@ -0,0 +1,96 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[test]
|
||||
fn which_ls() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"which ls | get path | str trim"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "Nushell built-in command");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn which_alias_ls() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"alias ls = ls -a; which ls | get path | str trim"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "Nushell alias: ls -a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn which_def_ls() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"def ls [] {echo def}; which ls | get path | str trim"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "Nushell custom command");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn correct_precedence_alias_def_custom() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"def ls [] {echo def}; alias ls = echo alias; which ls | get path | str trim"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "Nushell alias: echo alias");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiple_reports_for_alias_def_custom() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"def ls [] {echo def}; alias ls = echo alias; which -a ls | length"
|
||||
);
|
||||
|
||||
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
|
||||
// values
|
||||
// I suspect this is due to the ScopeFrame getting discarded at '}' and the command is then
|
||||
// executed in the parent scope
|
||||
// See: parse_definition, line 2187 for reference.
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn multiple_reports_of_multiple_alias() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"alias xaz = echo alias1; def helper [] {alias xaz = echo alias2; which -a xaz}; helper | length"
|
||||
);
|
||||
|
||||
let length: i32 = actual.out.parse().unwrap();
|
||||
assert_eq!(length, 2);
|
||||
}
|
||||
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn multiple_reports_of_multiple_defs() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"def xaz [] {echo def1}; def helper [] { def xaz [] { echo def2 }; which -a xaz }; helper | length"
|
||||
);
|
||||
|
||||
let length: i32 = actual.out.parse().unwrap();
|
||||
assert_eq!(length, 2);
|
||||
}
|
||||
|
||||
//Fails due to ParserScope::add_definition
|
||||
// frame.custom_commands.insert(name.clone(), block.clone());
|
||||
// frame.commands.insert(name, whole_stream_command(block));
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn def_only_seen_once() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"def xaz [] {echo def1}; which -a xaz | length"
|
||||
);
|
||||
//length is 2. One custom_command (def) one built in ("wrongly" added)
|
||||
let length: i32 = actual.out.parse().unwrap();
|
||||
assert_eq!(length, 1);
|
||||
}
|
@ -4,11 +4,7 @@ use nu_test_support::nu;
|
||||
fn with_env_extends_environment() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
<<<<<<< HEAD
|
||||
"with-env [FOO BARRRR] {echo $nu.env} | get FOO"
|
||||
=======
|
||||
"with-env [FOO BARRRR] {echo $env} | get FOO"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "BARRRR");
|
||||
@ -18,11 +14,7 @@ fn with_env_extends_environment() {
|
||||
fn with_env_shorthand() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
<<<<<<< HEAD
|
||||
"FOO=BARRRR echo $nu.env | get FOO"
|
||||
=======
|
||||
"FOO=BARRRR echo $env | get FOO"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "BARRRR");
|
||||
@ -42,11 +34,7 @@ fn shorthand_doesnt_reorder_arguments() {
|
||||
fn with_env_shorthand_trims_quotes() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
<<<<<<< HEAD
|
||||
"FOO='BARRRR' echo $nu.env | get FOO"
|
||||
=======
|
||||
"FOO='BARRRR' echo $env | get FOO"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "BARRRR");
|
||||
@ -56,68 +44,42 @@ fn with_env_shorthand_trims_quotes() {
|
||||
fn with_env_and_shorthand_same_result() {
|
||||
let actual_shorthand = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
<<<<<<< HEAD
|
||||
"FOO='BARRRR' echo $nu.env | get FOO"
|
||||
=======
|
||||
"FOO='BARRRR' echo $env | get FOO"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
);
|
||||
|
||||
let actual_normal = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
<<<<<<< HEAD
|
||||
"with-env [FOO BARRRR] {echo $nu.env} | get FOO"
|
||||
=======
|
||||
"with-env [FOO BARRRR] {echo $env} | get FOO"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
);
|
||||
|
||||
assert_eq!(actual_shorthand.out, actual_normal.out);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn with_env_shorthand_nested_quotes() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
<<<<<<< HEAD
|
||||
"FOO='-arg \"hello world\"' echo $nu.env | get FOO"
|
||||
=======
|
||||
"FOO='-arg \"hello world\"' echo $env | get FOO"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "-arg \"hello world\"");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn with_env_hides_variables_in_parent_scope() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
r#"
|
||||
let-env FOO = "1"
|
||||
<<<<<<< HEAD
|
||||
echo $nu.env.FOO
|
||||
with-env [FOO $nothing] {
|
||||
echo $nu.env.FOO
|
||||
}
|
||||
echo $nu.env.FOO
|
||||
=======
|
||||
echo $env.FOO
|
||||
with-env [FOO $nothing] {
|
||||
echo $env.FOO
|
||||
}
|
||||
echo $env.FOO
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
);
|
||||
|
||||
@ -126,26 +88,17 @@ fn with_env_hides_variables_in_parent_scope() {
|
||||
assert!(actual.err.contains("Unknown column"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn with_env_shorthand_can_not_hide_variables() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
r#"
|
||||
let-env FOO = "1"
|
||||
<<<<<<< HEAD
|
||||
echo $nu.env.FOO
|
||||
FOO=$nothing echo $nu.env.FOO
|
||||
echo $nu.env.FOO
|
||||
=======
|
||||
echo $env.FOO
|
||||
FOO=$nothing echo $env.FOO
|
||||
echo $env.FOO
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
);
|
||||
|
||||
|
61
crates/nu-command/tests/commands/wrap.rs
Normal file
61
crates/nu-command/tests/commands/wrap.rs
Normal file
@ -0,0 +1,61 @@
|
||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn wrap_rows_into_a_row() {
|
||||
Playground::setup("wrap_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"los_tres_caballeros.txt",
|
||||
r#"
|
||||
first_name,last_name
|
||||
Andrés,Robalino
|
||||
Jonathan,Turner
|
||||
Yehuda,Katz
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open los_tres_caballeros.txt
|
||||
| from csv
|
||||
| wrap caballeros
|
||||
| get caballeros
|
||||
| nth 0
|
||||
| get last_name
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "Robalino");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wrap_rows_into_a_table() {
|
||||
Playground::setup("wrap_test_2", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"los_tres_caballeros.txt",
|
||||
r#"
|
||||
first_name,last_name
|
||||
Andrés,Robalino
|
||||
Jonathan,Turner
|
||||
Yehuda,Katz
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open los_tres_caballeros.txt
|
||||
| from csv
|
||||
| get last_name
|
||||
| wrap caballero
|
||||
| nth 2
|
||||
| get caballero
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "Katz");
|
||||
})
|
||||
}
|
@ -1,14 +1,6 @@
|
||||
use nu_test_support::fs::Stub::FileWithContent;
|
||||
<<<<<<< HEAD
|
||||
use nu_test_support::pipeline as input;
|
||||
use nu_test_support::playground::{says, Playground};
|
||||
|
||||
use hamcrest2::assert_that;
|
||||
use hamcrest2::prelude::*;
|
||||
=======
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
||||
const ZIP_POWERED_TEST_ASSERTION_SCRIPT: &str = r#"
|
||||
def expect [
|
||||
@ -34,11 +26,8 @@ def add-commits [n] {
|
||||
}
|
||||
"#;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn zips_two_tables() {
|
||||
Playground::setup("zip_test_1", |dirs, nu| {
|
||||
@ -47,14 +36,9 @@ fn zips_two_tables() {
|
||||
&format!("{}\n", ZIP_POWERED_TEST_ASSERTION_SCRIPT),
|
||||
)]);
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert_that!(
|
||||
nu.pipeline(&input(&format!(
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
&format!(
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
r#"
|
||||
source {} ;
|
||||
|
||||
@ -69,36 +53,15 @@ fn zips_two_tables() {
|
||||
expect $actual --to-eq [[name, commits]; [andres, 20] [jt, 30]]
|
||||
"#,
|
||||
dirs.test().join("zip_test.nu").display()
|
||||
<<<<<<< HEAD
|
||||
))),
|
||||
says().stdout("true")
|
||||
);
|
||||
=======
|
||||
)
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zips_two_lists() {
|
||||
<<<<<<< HEAD
|
||||
Playground::setup("zip_test_2", |_, nu| {
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
echo [0 2 4 6 8] | zip { [1 3 5 7 9] }
|
||||
| flatten
|
||||
| into string
|
||||
| str collect '-'
|
||||
"#
|
||||
)),
|
||||
says().stdout("0-1-2-3-4-5-6-7-8-9")
|
||||
);
|
||||
})
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
@ -107,5 +70,4 @@ fn zips_two_lists() {
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "0-1-2-3-4-5-6-7-8-9");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
17
crates/nu-command/tests/format_conversions/bson.rs
Normal file
17
crates/nu-command/tests/format_conversions/bson.rs
Normal file
@ -0,0 +1,17 @@
|
||||
#[cfg(feature = "bson")]
|
||||
#[test]
|
||||
fn table_to_bson_and_back_into_table() {
|
||||
use nu_test_support::{nu, pipeline};
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.bson
|
||||
| to bson
|
||||
| from bson
|
||||
| get root
|
||||
| get 1.b
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "whel");
|
||||
}
|
@ -34,11 +34,7 @@ fn table_to_csv_text() {
|
||||
| last 1
|
||||
| to csv
|
||||
| lines
|
||||
<<<<<<< HEAD
|
||||
| nth 1
|
||||
=======
|
||||
| get 1
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -149,11 +145,7 @@ fn from_csv_text_with_separator_to_table() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open los_tres_caballeros.txt
|
||||
<<<<<<< HEAD
|
||||
| from csv --separator ';'
|
||||
=======
|
||||
| from csv --separator ";"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get rusty_luck
|
||||
| length
|
||||
"#
|
||||
@ -180,11 +172,7 @@ fn from_csv_text_with_tab_separator_to_table() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open los_tres_caballeros.txt
|
||||
<<<<<<< HEAD
|
||||
| from csv --separator '\t'
|
||||
=======
|
||||
| from csv --separator (char tab)
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get rusty_luck
|
||||
| length
|
||||
"#
|
||||
|
93
crates/nu-command/tests/format_conversions/eml.rs
Normal file
93
crates/nu-command/tests/format_conversions/eml.rs
Normal file
@ -0,0 +1,93 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
const TEST_CWD: &str = "tests/fixtures/formats";
|
||||
|
||||
// The To field in this email is just "to@example.com", which gets parsed out as the Address. The Name is empty.
|
||||
#[test]
|
||||
fn from_eml_get_to_field() {
|
||||
let actual = nu!(
|
||||
cwd: TEST_CWD,
|
||||
pipeline(
|
||||
r#"
|
||||
open sample.eml
|
||||
| get To
|
||||
| get Address
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "to@example.com");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: TEST_CWD,
|
||||
pipeline(
|
||||
r#"
|
||||
open sample.eml
|
||||
| get To
|
||||
| get Name
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
// The Reply-To field in this email is "replyto@example.com" <replyto@example.com>, meaning both the Name and Address values are identical.
|
||||
#[test]
|
||||
fn from_eml_get_replyto_field() {
|
||||
let actual = nu!(
|
||||
cwd: TEST_CWD,
|
||||
pipeline(
|
||||
r#"
|
||||
open sample.eml
|
||||
| get Reply-To
|
||||
| get Address
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "replyto@example.com");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: TEST_CWD,
|
||||
pipeline(
|
||||
r#"
|
||||
open sample.eml
|
||||
| get Reply-To
|
||||
| get Name
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "replyto@example.com");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_eml_get_subject_field() {
|
||||
let actual = nu!(
|
||||
cwd: TEST_CWD,
|
||||
pipeline(
|
||||
r#"
|
||||
open sample.eml
|
||||
| get Subject
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "Test Message");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_eml_get_another_header_field() {
|
||||
let actual = nu!(
|
||||
cwd: TEST_CWD,
|
||||
pipeline(
|
||||
r#"
|
||||
open sample.eml
|
||||
| get MIME-Version
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "1.0");
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user