forked from extern/nushell
engine-q merge
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
<<<<<<< HEAD
|
||||
use nu_test_support::pipeline as input;
|
||||
use nu_test_support::playground::{says, Playground};
|
||||
|
||||
@ -17,10 +18,26 @@ fn checks_all_rows_are_true() {
|
||||
says().stdout("true")
|
||||
);
|
||||
})
|
||||
=======
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn checks_all_rows_are_true() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [ "Andrés", "Andrés", "Andrés" ]
|
||||
| all? $it == "Andrés"
|
||||
"#
|
||||
));
|
||||
|
||||
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(
|
||||
@ -31,10 +48,21 @@ fn checks_all_rows_are_false_with_param() {
|
||||
says().stdout("false")
|
||||
);
|
||||
})
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
[1, 2, 3, 4] | all? { |a| $a >= 5 }
|
||||
"#
|
||||
));
|
||||
|
||||
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(
|
||||
@ -45,14 +73,30 @@ fn checks_all_rows_are_true_with_param() {
|
||||
says().stdout("true")
|
||||
);
|
||||
})
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
[1, 2, 3, 4] | all? { |a| $a < 5 }
|
||||
"#
|
||||
));
|
||||
|
||||
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 ]
|
||||
@ -61,9 +105,16 @@ 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,3 +1,4 @@
|
||||
<<<<<<< HEAD
|
||||
use nu_test_support::pipeline as input;
|
||||
use nu_test_support::playground::{says, Playground};
|
||||
|
||||
@ -17,14 +18,35 @@ fn checks_any_row_is_true() {
|
||||
says().stdout("true")
|
||||
);
|
||||
})
|
||||
=======
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn checks_any_row_is_true() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [ "Ecuador", "USA", "New Zealand" ]
|
||||
| any? $it == "New Zealand"
|
||||
"#
|
||||
));
|
||||
|
||||
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 ]
|
||||
@ -33,9 +55,16 @@ 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,3 +1,4 @@
|
||||
<<<<<<< HEAD
|
||||
use nu_test_support::pipeline as input;
|
||||
use nu_test_support::playground::{says, Playground};
|
||||
|
||||
@ -18,4 +19,20 @@ fn adds_a_row_to_the_end() {
|
||||
says().stdout("pollo loco")
|
||||
);
|
||||
})
|
||||
=======
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn adds_a_row_to_the_end() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [ "Andrés N. Robalino", "Jonathan Turner", "Yehuda Katz" ]
|
||||
| append "pollo loco"
|
||||
| nth 3
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "pollo loco");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
@ -5,11 +5,19 @@ 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);
|
||||
}
|
||||
@ -19,11 +27,19 @@ 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);
|
||||
}
|
||||
@ -57,11 +73,19 @@ 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);
|
||||
}
|
||||
@ -71,9 +95,17 @@ 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,8 +1,17 @@
|
||||
<<<<<<< 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, _| {
|
||||
@ -18,6 +27,11 @@ 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, _| {
|
||||
@ -34,6 +48,11 @@ 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| {
|
||||
@ -53,6 +72,11 @@ 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| {
|
||||
@ -73,6 +97,11 @@ 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, _| {
|
||||
@ -88,6 +117,11 @@ 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| {
|
||||
@ -105,6 +139,11 @@ 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| {
|
||||
@ -127,6 +166,11 @@ 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, _| {
|
||||
@ -142,6 +186,11 @@ 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| {
|
||||
@ -162,6 +211,11 @@ 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| {
|
||||
@ -185,6 +239,11 @@ 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, _| {
|
||||
@ -207,6 +266,11 @@ 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| {
|
||||
@ -226,6 +290,7 @@ 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| {
|
||||
@ -433,6 +498,10 @@ fn valuesystem_path_not_found() {
|
||||
})
|
||||
}
|
||||
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[cfg(target_os = "windows")]
|
||||
#[test]
|
||||
fn test_change_windows_drive() {
|
||||
|
@ -1,50 +0,0 @@
|
||||
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");
|
||||
});
|
||||
}
|
@ -1,138 +0,0 @@
|
||||
use nu_test_support::fs::AbsolutePath;
|
||||
use nu_test_support::fs::Stub::FileWithContent;
|
||||
use nu_test_support::playground::{says, Playground};
|
||||
|
||||
use hamcrest2::assert_that;
|
||||
use hamcrest2::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn clearing_config_clears_config() {
|
||||
Playground::setup("environment_syncing_test_1", |dirs, nu| {
|
||||
let file = AbsolutePath::new(dirs.test().join("config.toml"));
|
||||
|
||||
nu.with_config(&file);
|
||||
nu.with_files(vec![FileWithContent(
|
||||
"config.toml",
|
||||
r#"
|
||||
skip_welcome_message = true
|
||||
"#,
|
||||
)]);
|
||||
|
||||
assert_that!(
|
||||
nu.pipeline("config clear | ignore; config get skip_welcome_message"),
|
||||
says().stdout("")
|
||||
);
|
||||
let config_contents = std::fs::read_to_string(file).expect("Could not read file");
|
||||
assert!(config_contents.is_empty());
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_get_returns_value() {
|
||||
Playground::setup("environment_syncing_test_1", |dirs, nu| {
|
||||
let file = AbsolutePath::new(dirs.test().join("config.toml"));
|
||||
|
||||
nu.with_config(&file);
|
||||
nu.with_files(vec![FileWithContent(
|
||||
"config.toml",
|
||||
r#"
|
||||
skip_welcome_message = true
|
||||
"#,
|
||||
)]);
|
||||
|
||||
assert_that!(
|
||||
//Clears config
|
||||
nu.pipeline("config get skip_welcome_message"),
|
||||
says().stdout("true")
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_set_sets_value() {
|
||||
Playground::setup("environment_syncing_test_1", |dirs, nu| {
|
||||
let file = AbsolutePath::new(dirs.test().join("config.toml"));
|
||||
|
||||
nu.with_config(&file);
|
||||
nu.with_files(vec![FileWithContent(
|
||||
"config.toml",
|
||||
r#"
|
||||
skip_welcome_message = true
|
||||
"#,
|
||||
)]);
|
||||
|
||||
assert_that!(
|
||||
//Clears config
|
||||
nu.pipeline("config set key value | ignore; config get key"),
|
||||
says().stdout("value")
|
||||
);
|
||||
let config_contents = std::fs::read_to_string(file).expect("Could not read file");
|
||||
assert!(config_contents.contains("key = \"value\""));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_set_into_sets_value() {
|
||||
Playground::setup("environment_syncing_test_1", |dirs, nu| {
|
||||
let file = AbsolutePath::new(dirs.test().join("config.toml"));
|
||||
|
||||
nu.with_config(&file);
|
||||
nu.with_files(vec![FileWithContent(
|
||||
"config.toml",
|
||||
r#"
|
||||
skip_welcome_message = true
|
||||
"#,
|
||||
)]);
|
||||
|
||||
assert_that!(
|
||||
//Clears config
|
||||
nu.pipeline("echo value | config set_into key | ignore; config get key"),
|
||||
says().stdout("value")
|
||||
);
|
||||
let config_contents = std::fs::read_to_string(file).expect("Could not read file");
|
||||
assert!(config_contents.contains("key = \"value\""));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_rm_removes_value() {
|
||||
Playground::setup("environment_syncing_test_1", |dirs, nu| {
|
||||
let file = AbsolutePath::new(dirs.test().join("config.toml"));
|
||||
|
||||
nu.with_config(&file);
|
||||
nu.with_files(vec![FileWithContent(
|
||||
"config.toml",
|
||||
r#"
|
||||
key = "value"
|
||||
skip_welcome_message = true
|
||||
"#,
|
||||
)]);
|
||||
|
||||
assert_that!(
|
||||
nu.pipeline("config remove key | ignore; config get key"),
|
||||
says().stdout("")
|
||||
);
|
||||
let config_contents = std::fs::read_to_string(file).expect("Could not read file");
|
||||
assert!(!config_contents.contains("key = \"value\""));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_path_returns_correct_path() {
|
||||
Playground::setup("environment_syncing_test_1", |dirs, nu| {
|
||||
let file = AbsolutePath::new(dirs.test().join("config.toml"));
|
||||
|
||||
nu.with_config(&file);
|
||||
nu.with_files(vec![FileWithContent(
|
||||
"config.toml",
|
||||
r#"
|
||||
skip_welcome_message = true
|
||||
"#,
|
||||
)]);
|
||||
|
||||
assert_that!(
|
||||
nu.pipeline("config path"),
|
||||
says().stdout(&file.inner.to_string_lossy().to_string())
|
||||
);
|
||||
});
|
||||
}
|
@ -31,6 +31,11 @@ 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, _| {
|
||||
@ -75,6 +80,11 @@ 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,6 +1,12 @@
|
||||
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, _| {
|
||||
|
@ -1,35 +0,0 @@
|
||||
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,5 +1,10 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn columns() {
|
||||
let actual = nu!(
|
||||
@ -20,6 +25,11 @@ 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!(
|
||||
@ -66,6 +76,7 @@ fn more_rows_than_table_has() {
|
||||
|
||||
assert_eq!(actual.out, "0");
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
#[test]
|
||||
fn nth_range_inclusive() {
|
||||
@ -88,3 +99,5 @@ fn nth_missing_first_argument() {
|
||||
assert!(actual.err.contains("Expected int or range"));
|
||||
assert!(actual.err.contains("found string"));
|
||||
}
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
@ -5,7 +5,11 @@ 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
|
||||
"#
|
||||
));
|
||||
|
||||
@ -17,7 +21,11 @@ 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
|
||||
"#
|
||||
));
|
||||
|
||||
@ -29,7 +37,11 @@ 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
|
||||
"#
|
||||
));
|
||||
|
||||
@ -41,7 +53,11 @@ 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
|
||||
"#
|
||||
));
|
||||
|
||||
@ -53,11 +69,19 @@ 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,7 +5,11 @@ 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
|
||||
"#
|
||||
));
|
||||
|
||||
@ -17,7 +21,11 @@ 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
|
||||
"#
|
||||
));
|
||||
|
||||
@ -29,7 +37,11 @@ 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
|
||||
"#
|
||||
));
|
||||
|
||||
@ -41,7 +53,11 @@ 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
|
||||
"#
|
||||
));
|
||||
|
||||
@ -53,7 +69,11 @@ 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,5 +1,10 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn reports_emptiness() {
|
||||
let actual = nu!(
|
||||
@ -20,6 +25,11 @@ 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!(
|
||||
@ -41,6 +51,11 @@ 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!(
|
||||
@ -61,6 +76,11 @@ 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,6 +71,7 @@ fn knows_the_filesystems_entered() {
|
||||
));
|
||||
})
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
#[test]
|
||||
fn errors_if_file_not_found() {
|
||||
@ -83,3 +84,5 @@ fn errors_if_file_not_found() {
|
||||
assert!(actual.err.contains("Cannot find file"));
|
||||
})
|
||||
}
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
@ -18,7 +18,11 @@ fn gets_all_rows_by_every_zero() {
|
||||
ls
|
||||
| get name
|
||||
| every 0
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -45,11 +49,19 @@ 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
|
||||
})
|
||||
}
|
||||
|
||||
@ -69,7 +81,11 @@ fn gets_all_rows_by_every_one() {
|
||||
ls
|
||||
| get name
|
||||
| every 1
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -80,6 +96,11 @@ 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| {
|
||||
@ -96,7 +117,11 @@ fn gets_no_rows_by_every_skip_one() {
|
||||
ls
|
||||
| get name
|
||||
| every 1 --skip
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -150,7 +175,11 @@ fn gets_all_rows_except_first_by_every_skip_too_much() {
|
||||
ls
|
||||
| get name
|
||||
| every 999 --skip
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -175,7 +204,11 @@ fn gets_every_third_row() {
|
||||
ls
|
||||
| get name
|
||||
| every 3
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -200,7 +233,11 @@ fn skips_every_third_row() {
|
||||
ls
|
||||
| get name
|
||||
| every 3 --skip
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
|
@ -19,7 +19,11 @@ 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
|
||||
"#
|
||||
));
|
||||
|
||||
@ -78,11 +82,19 @@ 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
|
||||
})
|
||||
}
|
||||
|
||||
@ -102,7 +114,11 @@ fn find_with_filepath_search_with_multiple_patterns() {
|
||||
ls
|
||||
| get name
|
||||
| find arep ami
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json -r
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
|
@ -1,67 +0,0 @@
|
||||
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,6 +2,11 @@ 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!(
|
||||
@ -18,6 +23,11 @@ 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!(
|
||||
@ -78,6 +88,11 @@ 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| {
|
||||
@ -112,6 +127,11 @@ 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,6 +16,11 @@ 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!(
|
||||
@ -29,6 +34,11 @@ 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!(
|
||||
@ -42,6 +52,11 @@ 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| {
|
||||
@ -65,6 +80,11 @@ fn format_filesize_works() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn format_filesize_works_with_nonempty_files() {
|
||||
Playground::setup(
|
||||
|
@ -130,6 +130,11 @@ 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| {
|
||||
@ -160,6 +165,11 @@ 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| {
|
||||
@ -186,6 +196,12 @@ 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,6 +71,11 @@ 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,6 +26,11 @@ 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!(
|
||||
@ -41,6 +46,11 @@ 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!(
|
||||
@ -84,6 +94,11 @@ 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!(
|
||||
@ -97,6 +112,11 @@ 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,5 +1,10 @@
|
||||
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!(
|
||||
@ -15,6 +20,11 @@ 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,6 +15,11 @@ 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,6 +2,11 @@ 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| {
|
||||
@ -33,6 +38,11 @@ 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| {
|
||||
@ -61,6 +71,11 @@ fn summarizes_by_values() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn help() {
|
||||
Playground::setup("histogram_test_3", |dirs, _sandbox| {
|
||||
@ -90,6 +105,11 @@ fn help() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn count() {
|
||||
let actual = nu!(
|
||||
|
@ -1,45 +0,0 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn sets_the_column_from_a_block_run_output() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open cargo_sample.toml
|
||||
| insert dev-dependencies.newdep "1"
|
||||
| get dev-dependencies.newdep
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sets_the_column_from_a_block_full_stream_output() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
wrap _
|
||||
| insert 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
|
||||
| insert content (open --raw cargo_sample.toml | lines | first 5)
|
||||
| get content.1
|
||||
| str contains "nu"
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
}
|
@ -33,7 +33,11 @@ fn into_filesize_str() {
|
||||
"#
|
||||
));
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert!(actual.out.contains("2.0 KB"));
|
||||
=======
|
||||
assert!(actual.out.contains("2.0 KiB"));
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -41,12 +45,21 @@ 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]
|
||||
@ -54,6 +67,7 @@ fn into_filesize_str_many_newlines() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
'2000
|
||||
|
||||
' | into filesize
|
||||
@ -61,6 +75,15 @@ fn into_filesize_str_many_newlines() {
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("2.0 KB"));
|
||||
=======
|
||||
"2000
|
||||
|
||||
" | into filesize
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("2.0 KiB"));
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -68,9 +91,17 @@ 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
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
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'));
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
mod rows;
|
||||
mod until;
|
||||
mod while_;
|
@ -1,31 +0,0 @@
|
||||
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,7 +10,11 @@ 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
|
||||
@ -33,6 +37,7 @@ fn condition_is_met() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open --raw caballeros.txt
|
||||
<<<<<<< HEAD
|
||||
| lines
|
||||
| skip 2
|
||||
| split column ','
|
||||
@ -41,6 +46,17 @@ fn condition_is_met() {
|
||||
| keep until "Chicken Collection" == "Red Chickens"
|
||||
| skip 1
|
||||
| str to-int "31/04/2020"
|
||||
=======
|
||||
| lines
|
||||
| skip 2
|
||||
| str trim
|
||||
| str collect (char nl)
|
||||
| from csv
|
||||
| skip while "Chicken Collection" != "Blue Chickens"
|
||||
| keep until "Chicken Collection" == "Red Chickens"
|
||||
| skip 1
|
||||
| into int "31/04/2020"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get "31/04/2020"
|
||||
| math sum
|
||||
"#
|
||||
|
@ -10,7 +10,11 @@ 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
|
||||
@ -33,6 +37,7 @@ fn condition_is_met() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open --raw caballeros.txt
|
||||
<<<<<<< HEAD
|
||||
| lines
|
||||
| skip 2
|
||||
| split column ','
|
||||
@ -40,6 +45,16 @@ fn condition_is_met() {
|
||||
| skip 1
|
||||
| keep while "Chicken Collection" != "Blue Chickens"
|
||||
| str to-int "31/04/2020"
|
||||
=======
|
||||
| lines
|
||||
| skip 2
|
||||
| str trim
|
||||
| str collect (char nl)
|
||||
| from csv
|
||||
| skip 1
|
||||
| keep while "Chicken Collection" != "Blue Chickens"
|
||||
| into int "31/04/2020"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get "31/04/2020"
|
||||
| math sum
|
||||
"#
|
||||
|
@ -1,66 +0,0 @@
|
||||
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");
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
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,7 +27,11 @@ fn lines_proper_buffering() {
|
||||
open lines_test.txt -r
|
||||
| lines
|
||||
| str length
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json -r
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -46,5 +50,9 @@ fn lines_multi_value_split() {
|
||||
"#
|
||||
));
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert_eq!(actual.out, "5");
|
||||
=======
|
||||
assert_eq!(actual.out, "6");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
@ -88,7 +88,11 @@ fn lists_all_files_in_directories_from_stream() {
|
||||
r#"
|
||||
echo dir_a dir_b
|
||||
| each { ls $it }
|
||||
<<<<<<< HEAD
|
||||
| length
|
||||
=======
|
||||
| flatten | length
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -300,14 +304,22 @@ 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)]
|
||||
@ -316,10 +328,17 @@ fn list_all_columns() {
|
||||
"name",
|
||||
"type",
|
||||
"target",
|
||||
<<<<<<< HEAD
|
||||
"num_links",
|
||||
"inode",
|
||||
"readonly",
|
||||
"mode",
|
||||
=======
|
||||
"readonly",
|
||||
"mode",
|
||||
"num_links",
|
||||
"inode",
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"uid",
|
||||
"group",
|
||||
"size",
|
||||
|
@ -18,8 +18,15 @@ 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,5 +1,10 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn evaluates_two_plus_two() {
|
||||
let actual = nu!(
|
||||
@ -12,6 +17,11 @@ 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!(
|
||||
@ -24,6 +34,11 @@ 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!(
|
||||
@ -36,6 +51,11 @@ 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!(
|
||||
|
@ -1,40 +0,0 @@
|
||||
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,6 +236,7 @@ fn duration_math_with_negative() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
<<<<<<< HEAD
|
||||
fn duration_math_shell_error_on_big_numbers() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
@ -248,6 +249,8 @@ fn duration_math_shell_error_on_big_numbers() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
fn compound_comparison() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
@ -276,11 +279,19 @@ 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]
|
||||
@ -288,9 +299,17 @@ 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
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
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,5 +1,10 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn can_sqrt_numbers() {
|
||||
let actual = nu!(
|
||||
@ -10,6 +15,11 @@ 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,6 +75,11 @@ 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,6 +2,11 @@ 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| {
|
||||
|
@ -1,84 +0,0 @@
|
||||
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,7 +4,10 @@ mod append;
|
||||
mod cal;
|
||||
mod cd;
|
||||
mod compact;
|
||||
<<<<<<< HEAD
|
||||
mod config;
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
mod cp;
|
||||
mod def;
|
||||
mod default;
|
||||
@ -24,7 +27,10 @@ mod hash_;
|
||||
mod headers;
|
||||
mod help;
|
||||
mod histogram;
|
||||
<<<<<<< HEAD
|
||||
mod insert;
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
mod into_filesize;
|
||||
mod into_int;
|
||||
mod keep;
|
||||
@ -36,10 +42,17 @@ 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,6 +34,11 @@ 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| {
|
||||
@ -68,6 +73,11 @@ 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| {
|
||||
@ -103,6 +113,11 @@ 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| {
|
||||
|
@ -1,2 +0,0 @@
|
||||
mod column;
|
||||
mod mv;
|
@ -195,6 +195,11 @@ 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| {
|
||||
@ -207,6 +212,11 @@ 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| {
|
||||
@ -221,6 +231,11 @@ 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| {
|
||||
@ -241,6 +256,11 @@ 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| {
|
||||
@ -257,6 +277,11 @@ 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,3 +1,10 @@
|
||||
<<<<<<< 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,6 +185,7 @@ fn parses_json() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
<<<<<<< HEAD
|
||||
fn parses_xml() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
@ -198,6 +199,8 @@ fn parses_xml() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
fn parses_ini() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
@ -211,12 +214,21 @@ 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!(
|
||||
@ -232,6 +244,11 @@ 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,6 +5,11 @@ 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| {
|
||||
@ -81,6 +86,11 @@ 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| {
|
||||
|
@ -1,83 +0,0 @@
|
||||
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);
|
||||
}
|
@ -1,137 +0,0 @@
|
||||
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,6 +2,11 @@ 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| {
|
||||
|
@ -1,78 +0,0 @@
|
||||
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("~"));
|
||||
})
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
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");
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
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,6 +114,11 @@ 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,7 +17,11 @@ 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
|
||||
"#
|
||||
@ -39,6 +43,10 @@ fn splits_correctly_with_column_path() {
|
||||
]
|
||||
| path split -c [ home barn ]
|
||||
| get barn
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
| flatten
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
@ -15,6 +15,11 @@ 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| {
|
||||
@ -30,10 +35,19 @@ 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| {
|
||||
@ -49,6 +63,10 @@ fn returns_type_of_existing_directory() {
|
||||
"#
|
||||
));
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert_eq!(actual.out, "File");
|
||||
=======
|
||||
assert_eq!(actual.out, "file");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
})
|
||||
}
|
||||
|
@ -1,380 +0,0 @@
|
||||
use nu_test_support::fs::Stub::FileWithContent;
|
||||
use nu_test_support::fs::{AbsolutePath, DisplayPath};
|
||||
use nu_test_support::playground::{says, Playground};
|
||||
use nu_test_support::{nu, NATIVE_PATH_ENV_SEPARATOR};
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use hamcrest2::assert_that;
|
||||
use hamcrest2::prelude::*;
|
||||
|
||||
/// Helper function that joins string literals with ':' or ';', based on host OS
|
||||
fn join_env_sep(pieces: &[&str]) -> String {
|
||||
let sep_string = String::from(NATIVE_PATH_ENV_SEPARATOR);
|
||||
pieces.join(&sep_string)
|
||||
}
|
||||
|
||||
// Helpers
|
||||
|
||||
#[cfg(windows)]
|
||||
#[test]
|
||||
fn joins_env_on_windows() {
|
||||
let pieces = ["sausage", "bacon", "spam"];
|
||||
let actual = join_env_sep(&pieces);
|
||||
|
||||
assert_eq!(&actual, "sausage;bacon;spam");
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
#[test]
|
||||
fn joins_env_on_non_windows() {
|
||||
let pieces = ["sausage", "bacon", "spam"];
|
||||
let actual = join_env_sep(&pieces);
|
||||
|
||||
assert_eq!(&actual, "sausage:bacon:spam");
|
||||
}
|
||||
|
||||
// The following tests don't work on Windows likely because of this issue:
|
||||
// https://github.com/nushell/nushell/issues/3831
|
||||
//
|
||||
// fn pathvar_correctly_reads_path_from_config_and_env()
|
||||
// fn pathvar_correctly_reads_path_from_env()
|
||||
// fn pathvar_saves_new_path_to_config()
|
||||
//
|
||||
// Requires also auto-reading other-than-path env vars from config:
|
||||
// fn pathvar_correctly_reads_env_var_from_config_and_env()
|
||||
// fn pathvar_correctly_reads_env_var_from_config()
|
||||
|
||||
// pathvar
|
||||
|
||||
#[test]
|
||||
fn pathvar_correctly_reads_path_from_config() {
|
||||
Playground::setup("hi_there", |dirs, sandbox| {
|
||||
let file = AbsolutePath::new(dirs.test().join("config.toml"));
|
||||
|
||||
sandbox
|
||||
.with_files(vec![FileWithContent(
|
||||
"config.toml",
|
||||
r#"
|
||||
skip_welcome_message = true
|
||||
|
||||
path = ["/Users/andresrobalino/.volta/bin", "/Users/mosqueteros/bin"]
|
||||
"#,
|
||||
)])
|
||||
.with_config(&file);
|
||||
|
||||
let expected = "/Users/andresrobalino/.volta/bin-/Users/mosqueteros/bin";
|
||||
let actual = sandbox.pipeline(r#" pathvar | first 2 | str collect '-' "#);
|
||||
|
||||
assert_that!(actual, says().stdout(expected));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pathvar_correctly_reads_env_var_from_env() {
|
||||
Playground::setup("hi_there", |_, sandbox| {
|
||||
sandbox.with_env("BREAKFAST", &join_env_sep(&["bacon", "spam"]));
|
||||
|
||||
let expected = "bacon-spam";
|
||||
let actual = sandbox.pipeline(r#" pathvar -v BREAKFAST | str collect '-' "#);
|
||||
|
||||
assert_that!(actual, says().stdout(expected));
|
||||
})
|
||||
}
|
||||
|
||||
// pathvar add
|
||||
|
||||
#[test]
|
||||
fn pathvar_adds_to_path() {
|
||||
Playground::setup("hi_there", |dirs, sandbox| {
|
||||
let file = AbsolutePath::new(dirs.test().join("config.toml"));
|
||||
|
||||
sandbox
|
||||
.with_files(vec![FileWithContent(
|
||||
"config.toml",
|
||||
r#"
|
||||
skip_welcome_message = true
|
||||
|
||||
path = ["/Users/mosquito/proboscis"]
|
||||
"#,
|
||||
)])
|
||||
.with_config(&file);
|
||||
|
||||
let expected = "spam";
|
||||
let actual = sandbox.pipeline(r#" pathvar add spam; pathvar | first "#);
|
||||
|
||||
assert_that!(actual, says().stdout(expected));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pathvar_adds_to_env_var() {
|
||||
Playground::setup("hi_there", |_, sandbox| {
|
||||
sandbox.with_env("BREAKFAST", &join_env_sep(&["egg", "sausage", "bacon"]));
|
||||
|
||||
let expected = join_env_sep(&["spam", "egg", "sausage", "bacon"]);
|
||||
let actual = sandbox.pipeline(
|
||||
r#"
|
||||
pathvar add -v BREAKFAST spam
|
||||
$nu.env.BREAKFAST
|
||||
"#,
|
||||
);
|
||||
|
||||
assert_that!(actual, says().stdout(&expected));
|
||||
})
|
||||
}
|
||||
|
||||
// pathvar append
|
||||
|
||||
#[test]
|
||||
fn pathvar_appends_to_path() {
|
||||
Playground::setup("hi_there", |dirs, sandbox| {
|
||||
let file = AbsolutePath::new(dirs.test().join("config.toml"));
|
||||
|
||||
sandbox
|
||||
.with_files(vec![FileWithContent(
|
||||
"config.toml",
|
||||
r#"
|
||||
skip_welcome_message = true
|
||||
|
||||
path = ["/Users/mosquito/proboscis"]
|
||||
"#,
|
||||
)])
|
||||
.with_config(&file);
|
||||
|
||||
let expected = "spam";
|
||||
let actual = sandbox.pipeline(r#" pathvar append spam; pathvar | last "#);
|
||||
|
||||
assert_that!(actual, says().stdout(expected));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pathvar_appends_to_env_var() {
|
||||
Playground::setup("hi_there", |_, sandbox| {
|
||||
sandbox.with_env("BREAKFAST", &join_env_sep(&["egg", "sausage", "bacon"]));
|
||||
|
||||
let expected = join_env_sep(&["egg", "sausage", "bacon", "spam"]);
|
||||
let actual = sandbox.pipeline(
|
||||
r#"
|
||||
pathvar append -v BREAKFAST spam
|
||||
$nu.env.BREAKFAST
|
||||
"#,
|
||||
);
|
||||
|
||||
assert_that!(actual, says().stdout(&expected));
|
||||
})
|
||||
}
|
||||
|
||||
// pathvar remove
|
||||
|
||||
#[test]
|
||||
fn pathvar_removes_from_path() {
|
||||
Playground::setup("hi_there", |dirs, sandbox| {
|
||||
let file = AbsolutePath::new(dirs.test().join("config.toml"));
|
||||
|
||||
sandbox
|
||||
.with_files(vec![FileWithContent(
|
||||
"config.toml",
|
||||
r#"
|
||||
skip_welcome_message = true
|
||||
|
||||
path = ["/Users/mosquito/proboscis", "spam"]
|
||||
"#,
|
||||
)])
|
||||
.with_config(&file);
|
||||
|
||||
let expected = "/Users/mosquito/proboscis";
|
||||
let actual = sandbox.pipeline(r#" pathvar remove 1; pathvar | first "#);
|
||||
|
||||
assert_that!(actual, says().stdout(expected));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pathvar_removes_from_env_var() {
|
||||
Playground::setup("hi_there", |_, sandbox| {
|
||||
sandbox.with_env(
|
||||
"BREAKFAST",
|
||||
&join_env_sep(&["egg", "sausage", "bacon", "spam"]),
|
||||
);
|
||||
|
||||
let expected = join_env_sep(&["egg", "sausage", "bacon"]);
|
||||
let actual = sandbox.pipeline(
|
||||
r#"
|
||||
pathvar remove -v BREAKFAST 3
|
||||
$nu.env.BREAKFAST
|
||||
"#,
|
||||
);
|
||||
|
||||
assert_that!(actual, says().stdout(&expected));
|
||||
})
|
||||
}
|
||||
|
||||
// pathvar reset
|
||||
|
||||
#[test]
|
||||
fn pathvar_resets_path_from_config() {
|
||||
Playground::setup("hi_there", |dirs, sandbox| {
|
||||
let file = AbsolutePath::new(dirs.test().join("config.toml"));
|
||||
|
||||
sandbox
|
||||
.with_files(vec![FileWithContent(
|
||||
"config.toml",
|
||||
r#"
|
||||
skip_welcome_message = true
|
||||
|
||||
path = ["/Users/andresrobalino/.volta/bin", "/Users/mosqueteros/bin"]
|
||||
"#,
|
||||
)])
|
||||
.with_config(&file)
|
||||
.with_env(
|
||||
nu_test_support::NATIVE_PATH_ENV_VAR,
|
||||
&PathBuf::from("/Users/mosquito/proboscis").display_path(),
|
||||
);
|
||||
|
||||
let expected = "/Users/andresrobalino/.volta/bin-/Users/mosqueteros/bin";
|
||||
let actual = sandbox.pipeline(
|
||||
r#"
|
||||
pathvar reset
|
||||
pathvar | str collect '-'
|
||||
"#,
|
||||
);
|
||||
|
||||
assert_that!(actual, says().stdout(expected));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pathvar_resets_env_var_from_config() {
|
||||
Playground::setup("hi_there", |dirs, sandbox| {
|
||||
let file = AbsolutePath::new(dirs.test().join("config.toml"));
|
||||
|
||||
sandbox
|
||||
.with_files(vec![FileWithContent(
|
||||
"config.toml",
|
||||
r#"
|
||||
skip_welcome_message = true
|
||||
|
||||
breakfast = ["egg", "sausage", "bacon"]
|
||||
"#,
|
||||
)])
|
||||
.with_config(&file)
|
||||
.with_env(
|
||||
"BREAKFAST",
|
||||
&join_env_sep(&["egg", "sausage", "bacon", "spam"]),
|
||||
);
|
||||
|
||||
let expected = "egg-sausage-bacon";
|
||||
let actual = sandbox.pipeline(
|
||||
r#"
|
||||
pathvar reset -v BREAKFAST
|
||||
pathvar -v BREAKFAST | str collect '-'
|
||||
"#,
|
||||
);
|
||||
|
||||
assert_that!(actual, says().stdout(expected));
|
||||
})
|
||||
}
|
||||
|
||||
// pathvar save
|
||||
|
||||
#[test]
|
||||
fn pathvar_saves_path_to_config() {
|
||||
Playground::setup("hi_there", |dirs, sandbox| {
|
||||
let file = AbsolutePath::new(dirs.test().join("config.toml"));
|
||||
|
||||
sandbox
|
||||
.with_files(vec![FileWithContent(
|
||||
"config.toml",
|
||||
r#"
|
||||
skip_welcome_message = true
|
||||
|
||||
path = ["/Users/andresrobalino/.volta/bin", "/Users/mosqueteros/bin"]
|
||||
"#,
|
||||
)])
|
||||
.with_config(&file);
|
||||
|
||||
let expected = "/Users/mosquito/proboscis";
|
||||
let actual = sandbox.pipeline(
|
||||
r#"
|
||||
pathvar append "/Users/mosquito/proboscis"
|
||||
pathvar save
|
||||
(config).path | last
|
||||
"#,
|
||||
);
|
||||
|
||||
assert_that!(actual, says().stdout(expected));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pathvar_saves_env_var_to_config() {
|
||||
Playground::setup("hi_there", |dirs, sandbox| {
|
||||
let file = AbsolutePath::new(dirs.test().join("config.toml"));
|
||||
|
||||
sandbox
|
||||
.with_files(vec![FileWithContent(
|
||||
"config.toml",
|
||||
r#"
|
||||
skip_welcome_message = true
|
||||
|
||||
breakfast = ["egg", "sausage", "bacon"]
|
||||
"#,
|
||||
)])
|
||||
.with_config(&file)
|
||||
.with_env("BREAKFAST", "spam");
|
||||
|
||||
let expected = "spam";
|
||||
let actual = sandbox.pipeline(
|
||||
r#"
|
||||
pathvar save -v BREAKFAST
|
||||
(config).breakfast | str collect '-'
|
||||
"#,
|
||||
);
|
||||
|
||||
assert_that!(actual, says().stdout(expected));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pathvar_saves_new_env_var_to_config() {
|
||||
Playground::setup("hi_there", |dirs, sandbox| {
|
||||
let file = AbsolutePath::new(dirs.test().join("config.toml"));
|
||||
|
||||
sandbox
|
||||
.with_files(vec![FileWithContent(
|
||||
"config.toml",
|
||||
r#"
|
||||
skip_welcome_message = true
|
||||
"#,
|
||||
)])
|
||||
.with_config(&file)
|
||||
.with_env("BREAKFAST", "spam");
|
||||
|
||||
let expected = "spam";
|
||||
let actual = sandbox.pipeline(
|
||||
r#"
|
||||
pathvar save -v BREAKFAST
|
||||
(config).breakfast | str collect '-'
|
||||
"#,
|
||||
);
|
||||
|
||||
assert_that!(actual, says().stdout(expected));
|
||||
})
|
||||
}
|
||||
|
||||
// test some errors
|
||||
|
||||
#[test]
|
||||
fn pathvar_error_non_existent_env_var() {
|
||||
Playground::setup("hi_there", |dirs, _| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"pathvar -v EGGS_BACON_SPAM_SAUSAGE_SPAM_AND_SPAM_WITH_EXTRA_SPAM"
|
||||
);
|
||||
|
||||
assert!(actual.err.contains("Error"));
|
||||
assert!(actual.err.contains("not set"));
|
||||
})
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
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");
|
||||
})
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
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);
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
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,5 +1,10 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn generates_an_decimal() {
|
||||
let actual = nu!(
|
||||
@ -12,6 +17,11 @@ 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!(
|
||||
@ -24,6 +34,11 @@ fn generates_55() {
|
||||
assert!(actual.out.contains("55"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn generates_0() {
|
||||
let actual = nu!(
|
||||
|
@ -1,13 +0,0 @@
|
||||
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,6 +24,11 @@ fn generates_55() {
|
||||
assert!(actual.out.contains("55"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn generates_0() {
|
||||
let actual = nu!(
|
||||
|
@ -1,7 +0,0 @@
|
||||
mod bool;
|
||||
mod chars;
|
||||
mod decimal;
|
||||
mod dice;
|
||||
mod integer;
|
||||
#[cfg(feature = "uuid_crate")]
|
||||
mod uuid;
|
@ -1,16 +0,0 @@
|
||||
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());
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
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,5 +1,10 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn reduce_table_column() {
|
||||
let actual = nu!(
|
||||
@ -8,7 +13,11 @@ 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
|
||||
"#
|
||||
)
|
||||
@ -17,14 +26,24 @@ 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
|
||||
"#
|
||||
)
|
||||
@ -33,15 +52,25 @@ 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
|
||||
"#
|
||||
)
|
||||
);
|
||||
@ -49,13 +78,22 @@ 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
|
||||
"#
|
||||
)
|
||||
@ -64,13 +102,22 @@ 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
|
||||
"#
|
||||
)
|
||||
@ -79,6 +126,11 @@ 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!(
|
||||
@ -86,8 +138,13 @@ 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
|
||||
@ -98,25 +155,46 @@ 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,6 +61,11 @@ 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| {
|
||||
|
@ -1,11 +0,0 @@
|
||||
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,6 +121,11 @@ 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| {
|
||||
@ -135,6 +140,11 @@ 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, _| {
|
||||
@ -147,6 +157,11 @@ 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, _| {
|
||||
@ -277,6 +292,11 @@ 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,6 +17,11 @@ mod rows {
|
||||
)
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn roll_down_by_default() {
|
||||
let actual = nu!(
|
||||
@ -30,6 +35,11 @@ mod rows {
|
||||
assert_eq!(actual.out, "HERE");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn can_roll_up() {
|
||||
let actual = nu!(
|
||||
@ -62,6 +72,11 @@ mod columns {
|
||||
)
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn roll_left_by_default() {
|
||||
let actual = nu!(
|
||||
@ -75,6 +90,11 @@ 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!(
|
||||
@ -90,6 +110,11 @@ 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");
|
||||
@ -103,6 +128,11 @@ 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";
|
||||
@ -155,7 +185,11 @@ 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,5 +1,10 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn counter_clockwise() {
|
||||
let table = pipeline(
|
||||
|
@ -48,6 +48,11 @@ 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,6 +22,11 @@ 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| {
|
||||
@ -64,6 +69,11 @@ 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(
|
||||
@ -102,6 +112,11 @@ 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(
|
||||
|
@ -1,29 +0,0 @@
|
||||
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"));
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
mod until;
|
||||
mod while_;
|
@ -10,7 +10,11 @@ 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
|
||||
@ -32,6 +36,7 @@ fn condition_is_met() {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
open --raw caballeros.txt
|
||||
| lines
|
||||
| skip 2
|
||||
@ -40,6 +45,17 @@ fn condition_is_met() {
|
||||
| skip until "Chicken Collection" == "Red Chickens"
|
||||
| skip 1
|
||||
| str to-int "31/04/2020"
|
||||
=======
|
||||
open --raw ./caballeros.txt
|
||||
| lines
|
||||
| skip 2
|
||||
| str trim
|
||||
| str collect (char nl)
|
||||
| from csv
|
||||
| skip until "Chicken Collection" == "Red Chickens"
|
||||
| skip 1
|
||||
| into int "31/04/2020"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get "31/04/2020"
|
||||
| math sum
|
||||
"#
|
||||
|
@ -10,7 +10,11 @@ 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
|
||||
@ -33,6 +37,7 @@ fn condition_is_met() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open --raw caballeros.txt
|
||||
<<<<<<< HEAD
|
||||
| lines
|
||||
| skip 2
|
||||
| split column ','
|
||||
@ -40,6 +45,16 @@ fn condition_is_met() {
|
||||
| skip while "Chicken Collection" != "Red Chickens"
|
||||
| skip 1
|
||||
| str to-int "31/04/2020"
|
||||
=======
|
||||
| lines
|
||||
| skip 2
|
||||
| str trim
|
||||
| str collect (char nl)
|
||||
| from csv
|
||||
| skip while "Chicken Collection" != "Red Chickens"
|
||||
| skip 1
|
||||
| into int "31/04/2020"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get "31/04/2020"
|
||||
| math sum
|
||||
"#
|
||||
|
@ -1,5 +1,10 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn by_column() {
|
||||
let actual = nu!(
|
||||
@ -21,6 +26,11 @@ fn by_column() {
|
||||
assert_eq!(actual.out, "description");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn by_invalid_column() {
|
||||
let actual = nu!(
|
||||
@ -43,6 +53,11 @@ 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!(
|
||||
@ -85,11 +100,20 @@ 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);
|
||||
}
|
||||
@ -102,12 +126,20 @@ 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);
|
||||
}
|
||||
|
||||
@ -119,12 +151,20 @@ 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);
|
||||
}
|
||||
|
||||
@ -136,11 +176,19 @@ 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,10 +1,15 @@
|
||||
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]
|
||||
@ -40,6 +45,7 @@ fn sources_also_files_under_custom_lib_dirs_path() {
|
||||
"#,
|
||||
)]);
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
@ -50,6 +56,18 @@ fn sources_also_files_under_custom_lib_dirs_path() {
|
||||
)),
|
||||
says().stdout("hello nu")
|
||||
);
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
source my_library.nu ;
|
||||
|
||||
hello
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "hello nu");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
})
|
||||
}
|
||||
|
||||
@ -104,6 +122,11 @@ 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");
|
||||
@ -111,6 +134,11 @@ 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");
|
||||
@ -118,6 +146,11 @@ 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() {
|
||||
@ -126,12 +159,22 @@ 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,6 +49,10 @@ 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
|
||||
})
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
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"));
|
||||
})
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
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,10 +44,18 @@ 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
|
||||
}
|
||||
|
@ -1,158 +0,0 @@
|
||||
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,7 +29,11 @@ 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
|
||||
"#
|
||||
)
|
||||
);
|
||||
@ -124,7 +128,11 @@ 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
|
||||
@ -142,7 +150,11 @@ fn converts_to_decimal() {
|
||||
r#"
|
||||
echo "3.1, 0.0415"
|
||||
| split row ","
|
||||
<<<<<<< HEAD
|
||||
| str to-decimal
|
||||
=======
|
||||
| into decimal
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| math sum
|
||||
"#
|
||||
));
|
||||
|
@ -1,31 +0,0 @@
|
||||
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,6 +61,11 @@ fn uniq_values() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn nested_json_structures() {
|
||||
Playground::setup("uniq_test_3", |dirs, sandbox| {
|
||||
@ -125,13 +130,22 @@ 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
|
||||
|
||||
@ -141,13 +155,22 @@ 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
|
||||
@ -159,8 +182,12 @@ 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
|
||||
|
@ -1,60 +0,0 @@
|
||||
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");
|
||||
}
|
@ -1,166 +0,0 @@
|
||||
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");
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
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,7 +4,11 @@ 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");
|
||||
@ -14,7 +18,11 @@ 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");
|
||||
@ -34,7 +42,11 @@ 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");
|
||||
@ -44,38 +56,68 @@ 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
|
||||
"#
|
||||
);
|
||||
|
||||
@ -84,15 +126,26 @@ 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
|
||||
"#
|
||||
);
|
||||
|
||||
|
@ -1,61 +0,0 @@
|
||||
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,9 +1,14 @@
|
||||
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 [
|
||||
@ -29,6 +34,11 @@ def add-commits [n] {
|
||||
}
|
||||
"#;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn zips_two_tables() {
|
||||
Playground::setup("zip_test_1", |dirs, nu| {
|
||||
@ -37,8 +47,14 @@ 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 {} ;
|
||||
|
||||
@ -53,14 +69,22 @@ 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(
|
||||
@ -74,4 +98,14 @@ fn zips_two_lists() {
|
||||
says().stdout("0-1-2-3-4-5-6-7-8-9")
|
||||
);
|
||||
})
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [0 2 4 6 8] | zip [1 3 5 7 9] | flatten | into string | str collect '-'
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "0-1-2-3-4-5-6-7-8-9");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
Reference in New Issue
Block a user