mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 22:07:57 +02:00
working for comparing filepath to string (#2906)
* working for comparing filepath to string * added tests
This commit is contained in:
1
crates/nu-engine/tests/evaluate/mod.rs
Normal file
1
crates/nu-engine/tests/evaluate/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
mod operator;
|
38
crates/nu-engine/tests/evaluate/operator.rs
Normal file
38
crates/nu-engine/tests/evaluate/operator.rs
Normal file
@ -0,0 +1,38 @@
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn filter_ls_by_in_array() {
|
||||
Playground::setup("filter_ls_by_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("jean-luc.cap"),
|
||||
EmptyFile("riker.cmdr"),
|
||||
EmptyFile("data.ltcmdr"),
|
||||
EmptyFile("troi.ltcmdr"),
|
||||
EmptyFile("worf.lt"),
|
||||
EmptyFile("geordi.lt"),
|
||||
]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls | where name in ['data.ltcmdr', 'riker.cmdr'] | get name | to json
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "[\"data.ltcmdr\",\"riker.cmdr\"]");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn filter_json_with_in_array() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo '[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where size in [2] | get name
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "foo");
|
||||
}
|
3
crates/nu-engine/tests/main.rs
Normal file
3
crates/nu-engine/tests/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
extern crate nu_test_support;
|
||||
|
||||
mod evaluate;
|
Reference in New Issue
Block a user