forked from extern/nushell
Remove old nushell/merge engine-q
This commit is contained in:
@ -1,55 +1,6 @@
|
||||
[package]
|
||||
<<<<<<< HEAD
|
||||
authors = ["The Nu Project Contributors"]
|
||||
build = "build.rs"
|
||||
description = "Commands for Nushell"
|
||||
edition = "2018"
|
||||
license = "MIT"
|
||||
name = "nu-command"
|
||||
version = "0.43.0"
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
nu-data = { version = "0.43.0", path="../nu-data" }
|
||||
nu-engine = { version = "0.43.0", path="../nu-engine" }
|
||||
nu-errors = { version = "0.43.0", path="../nu-errors" }
|
||||
nu-json = { version = "0.43.0", path="../nu-json" }
|
||||
nu-path = { version = "0.43.0", path="../nu-path" }
|
||||
nu-parser = { version = "0.43.0", path="../nu-parser" }
|
||||
nu-plugin = { version = "0.43.0", path="../nu-plugin" }
|
||||
nu-protocol = { version = "0.43.0", path="../nu-protocol" }
|
||||
nu-serde = { version = "0.43.0", path="../nu-serde" }
|
||||
nu-source = { version = "0.43.0", path="../nu-source" }
|
||||
nu-stream = { version = "0.43.0", path="../nu-stream" }
|
||||
nu-table = { version = "0.43.0", path="../nu-table" }
|
||||
nu-test-support = { version = "0.43.0", path="../nu-test-support" }
|
||||
nu-value-ext = { version = "0.43.0", path="../nu-value-ext" }
|
||||
nu-ansi-term = { version = "0.43.0", path="../nu-ansi-term" }
|
||||
nu-pretty-hex = { version = "0.43.0", path="../nu-pretty-hex" }
|
||||
|
||||
url = "2.2.1"
|
||||
mime = "0.3.16"
|
||||
heck = "0.4.0"
|
||||
base64 = "0.13.0"
|
||||
bigdecimal = { version = "0.3.0", features = ["serde"] }
|
||||
calamine = "0.18.0"
|
||||
chrono = { version="0.4.19", features=["serde"] }
|
||||
chrono-tz = "0.5.3"
|
||||
crossterm = { version="0.19.0", optional=true }
|
||||
csv = "1.1.3"
|
||||
ctrlc = { version="3.1.7", optional=true }
|
||||
derive-new = "0.5.8"
|
||||
dirs-next = "2.0.0"
|
||||
dtparse = "1.2.0"
|
||||
eml-parser = "0.1.0"
|
||||
encoding_rs = "0.8.28"
|
||||
filesize = "0.2.0"
|
||||
futures = { version="0.3.12", features=["compat", "io-compat"] }
|
||||
=======
|
||||
name = "nu-command"
|
||||
version = "0.1.0"
|
||||
version = "0.59.0"
|
||||
edition = "2021"
|
||||
build = "build.rs"
|
||||
|
||||
@ -57,18 +8,20 @@ build = "build.rs"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
# nu-ansi-term = {path = "../nu-ansi-term", version = "0.59.0" }
|
||||
nu-ansi-term = "0.42.0"
|
||||
nu-color-config = { path = "../nu-color-config" }
|
||||
nu-engine = { path = "../nu-engine" }
|
||||
nu-json = { path = "../nu-json" }
|
||||
nu-parser = { path = "../nu-parser" }
|
||||
nu-path = { path = "../nu-path" }
|
||||
nu-pretty-hex = { path = "../nu-pretty-hex" }
|
||||
nu-protocol = { path = "../nu-protocol" }
|
||||
nu-system = { path = "../nu-system" }
|
||||
nu-table = { path = "../nu-table" }
|
||||
nu-term-grid = { path = "../nu-term-grid" }
|
||||
nu-test-support = { path = "../nu-test-support" }
|
||||
|
||||
nu-color-config = { path = "../nu-color-config", version = "0.59.0" }
|
||||
nu-engine = { path = "../nu-engine", version = "0.59.0" }
|
||||
nu-json = { path = "../nu-json", version = "0.59.0" }
|
||||
nu-parser = { path = "../nu-parser", version = "0.59.0" }
|
||||
nu-path = { path = "../nu-path", version = "0.59.0" }
|
||||
nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.59.0" }
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.59.0" }
|
||||
nu-system = { path = "../nu-system", version = "0.59.0" }
|
||||
nu-table = { path = "../nu-table", version = "0.59.0" }
|
||||
nu-term-grid = { path = "../nu-term-grid", version = "0.59.0" }
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.59.0" }
|
||||
|
||||
# Potential dependencies for extras
|
||||
base64 = "0.13.0"
|
||||
@ -85,55 +38,10 @@ dtparse = "1.2.0"
|
||||
eml-parser = "0.1.0"
|
||||
encoding_rs = "0.8.30"
|
||||
filesize = "0.2.0"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
glob = "0.3.0"
|
||||
htmlescape = "0.3.1"
|
||||
ical = "0.7.0"
|
||||
indexmap = { version="1.7", features=["serde-1"] }
|
||||
<<<<<<< HEAD
|
||||
itertools = "0.10.0"
|
||||
lazy_static = "1.*"
|
||||
log = "0.4.14"
|
||||
md-5 = "0.9.1"
|
||||
meval = "0.2.0"
|
||||
num-bigint = { version="0.4.3", features=["serde"] }
|
||||
num-format = { version="0.4.0", features=["with-num-bigint"] }
|
||||
num-traits = "0.2.14"
|
||||
parking_lot = "0.11.1"
|
||||
quick-xml = "0.22"
|
||||
rand = "0.8"
|
||||
regex = "1.4.3"
|
||||
reqwest = {version = "0.11", optional = true }
|
||||
roxmltree = "0.14.0"
|
||||
rust-embed = "5.9.0"
|
||||
rustyline = { version="9.0.0", optional=true }
|
||||
serde = { version="1.0.123", features=["derive"] }
|
||||
serde_ini = "0.2.0"
|
||||
serde_json = "1.0.61"
|
||||
serde_urlencoded = "0.7.0"
|
||||
serde_yaml = "0.8.16"
|
||||
sha2 = "0.9.3"
|
||||
strip-ansi-escapes = "0.1.0"
|
||||
sysinfo = { version = "0.23.0", optional = true }
|
||||
thiserror = "1.0.26"
|
||||
term = { version="0.7.0", optional=true }
|
||||
term_size = "0.3.2"
|
||||
titlecase = "1.1.0"
|
||||
tokio = { version = "1", features = ["rt-multi-thread"], optional = true }
|
||||
toml = "0.5.8"
|
||||
trash = { version = "2.0.2", optional = true }
|
||||
unicode-segmentation = "1.8"
|
||||
uuid_crate = { package="uuid", version="0.8.2", features=["v4"], optional=true }
|
||||
which = { version="4.1.0", optional=true }
|
||||
zip = { version="0.5.9", optional=true }
|
||||
digest = "0.9.0"
|
||||
|
||||
[dependencies.polars]
|
||||
version = "0.17.0"
|
||||
optional = true
|
||||
default-features = false
|
||||
features = ["docs", "zip_with", "csv-file", "temporal", "performant", "pretty_fmt", "dtype-slim", "parquet", "json", "random", "pivot", "strings", "is_in", "cum_agg", "rolling_window"]
|
||||
=======
|
||||
Inflector = "0.11"
|
||||
itertools = "0.10.0"
|
||||
lazy_static = "1.4.0"
|
||||
@ -170,19 +78,11 @@ uuid = { version = "0.8.2", features = ["v4"] }
|
||||
which = { version = "4.2.2", optional = true }
|
||||
reedline = { git = "https://github.com/nushell/reedline", branch = "main" }
|
||||
zip = { version="0.5.9", optional = true }
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
umask = "1.0.0"
|
||||
users = "0.11.0"
|
||||
|
||||
<<<<<<< HEAD
|
||||
# TODO this will be possible with new dependency resolver
|
||||
# (currently on nightly behind -Zfeatures=itarget):
|
||||
# https://github.com/rust-lang/cargo/issues/7914
|
||||
# [target.'cfg(not(windows))'.dependencies]
|
||||
# num-format = { version = "0.4", features = ["with-system-locale"] }
|
||||
=======
|
||||
[dependencies.polars]
|
||||
version = "0.18.0"
|
||||
optional = true
|
||||
@ -196,29 +96,12 @@ features = [
|
||||
trash-support = ["trash"]
|
||||
plugin = ["nu-parser/plugin"]
|
||||
dataframe = ["polars", "num"]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
||||
[build-dependencies]
|
||||
shadow-rs = "0.8.1"
|
||||
|
||||
[dev-dependencies]
|
||||
<<<<<<< HEAD
|
||||
quickcheck = "1.0.3"
|
||||
quickcheck_macros = "1.0.0"
|
||||
hamcrest2 = "0.3.0"
|
||||
|
||||
[features]
|
||||
rustyline-support = ["rustyline"]
|
||||
stable = []
|
||||
trash-support = ["trash"]
|
||||
dataframe = ["nu-protocol/dataframe", "polars"]
|
||||
fetch = ["reqwest", "tokio"]
|
||||
post = ["reqwest", "tokio"]
|
||||
sys = ["sysinfo"]
|
||||
ps = ["sysinfo"]
|
||||
=======
|
||||
hamcrest2 = "0.3.0"
|
||||
dirs-next = "2.0.0"
|
||||
quickcheck = "1.0.3"
|
||||
quickcheck_macros = "1.0.0"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
BIN
crates/nu-command/assets/228_themes.zip
Normal file
BIN
crates/nu-command/assets/228_themes.zip
Normal file
Binary file not shown.
3
crates/nu-command/build.rs
Normal file
3
crates/nu-command/build.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() -> shadow_rs::SdResult<()> {
|
||||
shadow_rs::new()
|
||||
}
|
@ -1,376 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
use crate::prelude::*;
|
||||
use nu_engine::whole_stream_command;
|
||||
use std::error::Error;
|
||||
|
||||
pub fn create_default_context(interactive: bool) -> Result<EvaluationContext, Box<dyn Error>> {
|
||||
let context = EvaluationContext::basic();
|
||||
|
||||
{
|
||||
use crate::commands::*;
|
||||
|
||||
context.add_commands(vec![
|
||||
// Fundamentals
|
||||
whole_stream_command(NuPlugin),
|
||||
whole_stream_command(Let),
|
||||
whole_stream_command(LetEnv),
|
||||
whole_stream_command(UnletEnv),
|
||||
whole_stream_command(LoadEnv),
|
||||
whole_stream_command(Def),
|
||||
whole_stream_command(Source),
|
||||
whole_stream_command(Alias),
|
||||
whole_stream_command(Unalias),
|
||||
whole_stream_command(Ignore),
|
||||
whole_stream_command(Tutor),
|
||||
whole_stream_command(Find),
|
||||
// System/file operations
|
||||
whole_stream_command(ErrorMake),
|
||||
whole_stream_command(Exec),
|
||||
whole_stream_command(Pwd),
|
||||
whole_stream_command(Ls),
|
||||
whole_stream_command(Du),
|
||||
whole_stream_command(Cd),
|
||||
whole_stream_command(Remove),
|
||||
whole_stream_command(Open),
|
||||
whole_stream_command(Pathvar),
|
||||
whole_stream_command(PathvarAdd),
|
||||
whole_stream_command(PathvarRemove),
|
||||
whole_stream_command(PathvarReset),
|
||||
whole_stream_command(PathvarAppend),
|
||||
whole_stream_command(PathvarSave),
|
||||
whole_stream_command(Config),
|
||||
whole_stream_command(ConfigGet),
|
||||
whole_stream_command(ConfigSet),
|
||||
whole_stream_command(ConfigSetInto),
|
||||
whole_stream_command(ConfigClear),
|
||||
whole_stream_command(ConfigRemove),
|
||||
whole_stream_command(ConfigPath),
|
||||
whole_stream_command(Help),
|
||||
whole_stream_command(History),
|
||||
whole_stream_command(Save),
|
||||
whole_stream_command(Touch),
|
||||
whole_stream_command(Cpy),
|
||||
whole_stream_command(Date),
|
||||
whole_stream_command(DateListTimeZone),
|
||||
whole_stream_command(DateNow),
|
||||
whole_stream_command(DateToTable),
|
||||
whole_stream_command(DateToTimeZone),
|
||||
whole_stream_command(DateFormat),
|
||||
whole_stream_command(DateHumanize),
|
||||
whole_stream_command(Cal),
|
||||
whole_stream_command(Mkdir),
|
||||
whole_stream_command(Mv),
|
||||
whole_stream_command(Kill),
|
||||
whole_stream_command(Version),
|
||||
whole_stream_command(Clear),
|
||||
whole_stream_command(Describe),
|
||||
whole_stream_command(Which),
|
||||
whole_stream_command(Debug),
|
||||
whole_stream_command(WithEnv),
|
||||
whole_stream_command(Do),
|
||||
whole_stream_command(Sleep),
|
||||
// Statistics
|
||||
whole_stream_command(Size),
|
||||
whole_stream_command(Length),
|
||||
whole_stream_command(Benchmark),
|
||||
// Metadata
|
||||
whole_stream_command(Tags),
|
||||
// Shells
|
||||
whole_stream_command(Next),
|
||||
whole_stream_command(Previous),
|
||||
whole_stream_command(Goto),
|
||||
whole_stream_command(Shells),
|
||||
whole_stream_command(Enter),
|
||||
whole_stream_command(Exit),
|
||||
// Viz
|
||||
whole_stream_command(Chart),
|
||||
// Viewers
|
||||
whole_stream_command(Autoview),
|
||||
whole_stream_command(Table),
|
||||
// Text manipulation
|
||||
whole_stream_command(Hash),
|
||||
whole_stream_command(HashBase64),
|
||||
whole_stream_command(HashMd5::default()),
|
||||
whole_stream_command(HashSha256::default()),
|
||||
whole_stream_command(Split),
|
||||
whole_stream_command(SplitColumn),
|
||||
whole_stream_command(SplitRow),
|
||||
whole_stream_command(SplitChars),
|
||||
whole_stream_command(Lines),
|
||||
whole_stream_command(Echo),
|
||||
whole_stream_command(Parse),
|
||||
whole_stream_command(Str),
|
||||
whole_stream_command(StrToDecimal),
|
||||
whole_stream_command(StrToInteger),
|
||||
whole_stream_command(StrDowncase),
|
||||
whole_stream_command(StrUpcase),
|
||||
whole_stream_command(StrCapitalize),
|
||||
whole_stream_command(StrFindReplace),
|
||||
whole_stream_command(StrSubstring),
|
||||
whole_stream_command(StrToDatetime),
|
||||
whole_stream_command(StrContains),
|
||||
whole_stream_command(StrIndexOf),
|
||||
whole_stream_command(StrTrim),
|
||||
whole_stream_command(StrStartsWith),
|
||||
whole_stream_command(StrEndsWith),
|
||||
whole_stream_command(StrCollect),
|
||||
whole_stream_command(StrLength),
|
||||
whole_stream_command(StrLPad),
|
||||
whole_stream_command(StrReverse),
|
||||
whole_stream_command(StrRPad),
|
||||
whole_stream_command(StrCamelCase),
|
||||
whole_stream_command(StrPascalCase),
|
||||
whole_stream_command(StrKebabCase),
|
||||
whole_stream_command(StrSnakeCase),
|
||||
whole_stream_command(StrScreamingSnakeCase),
|
||||
whole_stream_command(BuildString),
|
||||
whole_stream_command(Ansi),
|
||||
whole_stream_command(AnsiStrip),
|
||||
whole_stream_command(AnsiGradient),
|
||||
whole_stream_command(Char),
|
||||
whole_stream_command(DetectColumns),
|
||||
// Column manipulation
|
||||
whole_stream_command(DropColumn),
|
||||
whole_stream_command(MoveColumn),
|
||||
whole_stream_command(Reject),
|
||||
whole_stream_command(Select),
|
||||
whole_stream_command(Get),
|
||||
whole_stream_command(Update),
|
||||
whole_stream_command(UpdateCells),
|
||||
whole_stream_command(Insert),
|
||||
whole_stream_command(Into),
|
||||
whole_stream_command(IntoBinary),
|
||||
whole_stream_command(IntoColumnPath),
|
||||
whole_stream_command(IntoInt),
|
||||
whole_stream_command(IntoFilepath),
|
||||
whole_stream_command(IntoFilesize),
|
||||
whole_stream_command(IntoString),
|
||||
whole_stream_command(SplitBy),
|
||||
// Row manipulation
|
||||
whole_stream_command(All),
|
||||
whole_stream_command(Any),
|
||||
whole_stream_command(Reverse),
|
||||
whole_stream_command(Append),
|
||||
whole_stream_command(Prepend),
|
||||
whole_stream_command(SortBy),
|
||||
whole_stream_command(GroupBy),
|
||||
whole_stream_command(GroupByDate),
|
||||
whole_stream_command(First),
|
||||
whole_stream_command(Last),
|
||||
whole_stream_command(Every),
|
||||
whole_stream_command(Nth),
|
||||
whole_stream_command(Drop),
|
||||
whole_stream_command(DropNth),
|
||||
whole_stream_command(Format),
|
||||
whole_stream_command(FileSize),
|
||||
whole_stream_command(Where),
|
||||
whole_stream_command(If),
|
||||
whole_stream_command(Compact),
|
||||
whole_stream_command(Default),
|
||||
whole_stream_command(Skip),
|
||||
whole_stream_command(SkipUntil),
|
||||
whole_stream_command(SkipWhile),
|
||||
whole_stream_command(Keep),
|
||||
whole_stream_command(KeepUntil),
|
||||
whole_stream_command(KeepWhile),
|
||||
whole_stream_command(Range),
|
||||
whole_stream_command(Rename),
|
||||
whole_stream_command(Uniq),
|
||||
whole_stream_command(Each),
|
||||
whole_stream_command(EachGroup),
|
||||
whole_stream_command(EachWindow),
|
||||
whole_stream_command(Empty),
|
||||
whole_stream_command(ForIn),
|
||||
// Table manipulation
|
||||
whole_stream_command(Flatten),
|
||||
whole_stream_command(Merge),
|
||||
whole_stream_command(Shuffle),
|
||||
whole_stream_command(Wrap),
|
||||
whole_stream_command(Pivot),
|
||||
whole_stream_command(Headers),
|
||||
whole_stream_command(Reduce),
|
||||
whole_stream_command(Roll),
|
||||
whole_stream_command(RollColumn),
|
||||
whole_stream_command(RollUp),
|
||||
whole_stream_command(Rotate),
|
||||
whole_stream_command(RotateCounterClockwise),
|
||||
whole_stream_command(Zip),
|
||||
whole_stream_command(Collect),
|
||||
// Data processing
|
||||
whole_stream_command(Histogram),
|
||||
whole_stream_command(Autoenv),
|
||||
whole_stream_command(AutoenvTrust),
|
||||
whole_stream_command(AutoenvUntrust),
|
||||
whole_stream_command(Math),
|
||||
whole_stream_command(MathAbs),
|
||||
whole_stream_command(MathAverage),
|
||||
whole_stream_command(MathEval),
|
||||
whole_stream_command(MathMedian),
|
||||
whole_stream_command(MathMinimum),
|
||||
whole_stream_command(MathMode),
|
||||
whole_stream_command(MathMaximum),
|
||||
whole_stream_command(MathStddev),
|
||||
whole_stream_command(MathSummation),
|
||||
whole_stream_command(MathVariance),
|
||||
whole_stream_command(MathProduct),
|
||||
whole_stream_command(MathRound),
|
||||
whole_stream_command(MathFloor),
|
||||
whole_stream_command(MathCeil),
|
||||
whole_stream_command(MathSqrt),
|
||||
// File format output
|
||||
whole_stream_command(To),
|
||||
whole_stream_command(ToCsv),
|
||||
whole_stream_command(ToHtml),
|
||||
whole_stream_command(ToJson),
|
||||
whole_stream_command(ToMarkdown),
|
||||
whole_stream_command(ToToml),
|
||||
whole_stream_command(ToTsv),
|
||||
whole_stream_command(ToUrl),
|
||||
whole_stream_command(ToYaml),
|
||||
whole_stream_command(ToXml),
|
||||
// File format input
|
||||
whole_stream_command(From),
|
||||
whole_stream_command(FromCsv),
|
||||
whole_stream_command(FromEml),
|
||||
whole_stream_command(FromTsv),
|
||||
whole_stream_command(FromSsv),
|
||||
whole_stream_command(FromIni),
|
||||
whole_stream_command(FromJson),
|
||||
whole_stream_command(FromOds),
|
||||
whole_stream_command(FromToml),
|
||||
whole_stream_command(FromUrl),
|
||||
whole_stream_command(FromXlsx),
|
||||
whole_stream_command(FromXml),
|
||||
whole_stream_command(FromYaml),
|
||||
whole_stream_command(FromYml),
|
||||
whole_stream_command(FromIcs),
|
||||
whole_stream_command(FromVcf),
|
||||
// "Private" commands (not intended to be accessed directly)
|
||||
whole_stream_command(RunExternalCommand { interactive }),
|
||||
// Random value generation
|
||||
whole_stream_command(Random),
|
||||
whole_stream_command(RandomBool),
|
||||
whole_stream_command(RandomDice),
|
||||
#[cfg(feature = "uuid_crate")]
|
||||
whole_stream_command(RandomUUID),
|
||||
whole_stream_command(RandomInteger),
|
||||
whole_stream_command(RandomDecimal),
|
||||
whole_stream_command(RandomChars),
|
||||
// Path
|
||||
whole_stream_command(PathBasename),
|
||||
whole_stream_command(PathCommand),
|
||||
whole_stream_command(PathDirname),
|
||||
whole_stream_command(PathExists),
|
||||
whole_stream_command(PathExpand),
|
||||
whole_stream_command(PathJoin),
|
||||
whole_stream_command(PathParse),
|
||||
whole_stream_command(PathRelativeTo),
|
||||
whole_stream_command(PathSplit),
|
||||
whole_stream_command(PathType),
|
||||
// Url
|
||||
whole_stream_command(UrlCommand),
|
||||
whole_stream_command(UrlScheme),
|
||||
whole_stream_command(UrlPath),
|
||||
whole_stream_command(UrlHost),
|
||||
whole_stream_command(UrlQuery),
|
||||
whole_stream_command(Seq),
|
||||
whole_stream_command(SeqDates),
|
||||
whole_stream_command(TermSize),
|
||||
// Network
|
||||
#[cfg(feature = "fetch")]
|
||||
whole_stream_command(Fetch),
|
||||
#[cfg(feature = "post")]
|
||||
whole_stream_command(Post),
|
||||
// System
|
||||
#[cfg(feature = "ps")]
|
||||
whole_stream_command(Ps),
|
||||
#[cfg(feature = "sys")]
|
||||
whole_stream_command(Sys),
|
||||
]);
|
||||
|
||||
//Dataframe commands
|
||||
#[cfg(feature = "dataframe")]
|
||||
context.add_commands(vec![
|
||||
whole_stream_command(DataFrame),
|
||||
whole_stream_command(DataFrameOpen),
|
||||
whole_stream_command(DataFrameList),
|
||||
whole_stream_command(DataFrameGroupBy),
|
||||
whole_stream_command(DataFrameAggregate),
|
||||
whole_stream_command(DataFrameShow),
|
||||
whole_stream_command(DataFrameSample),
|
||||
whole_stream_command(DataFrameJoin),
|
||||
whole_stream_command(DataFrameDrop),
|
||||
whole_stream_command(DataFrameSelect),
|
||||
whole_stream_command(DataFrameDTypes),
|
||||
whole_stream_command(DataFrameDummies),
|
||||
whole_stream_command(DataFrameFirst),
|
||||
whole_stream_command(DataFrameLast),
|
||||
whole_stream_command(DataFrameSlice),
|
||||
whole_stream_command(DataFrameMelt),
|
||||
whole_stream_command(DataFramePivot),
|
||||
whole_stream_command(DataFrameWhere),
|
||||
whole_stream_command(DataFrameToDF),
|
||||
whole_stream_command(DataFrameToParquet),
|
||||
whole_stream_command(DataFrameToCsv),
|
||||
whole_stream_command(DataFrameSort),
|
||||
whole_stream_command(DataFrameGet),
|
||||
whole_stream_command(DataFrameDropDuplicates),
|
||||
whole_stream_command(DataFrameDropNulls),
|
||||
whole_stream_command(DataFrameColumn),
|
||||
whole_stream_command(DataFrameWithColumn),
|
||||
whole_stream_command(DataFrameFilter),
|
||||
whole_stream_command(DataFrameSeriesRename),
|
||||
whole_stream_command(DataFrameValueCounts),
|
||||
whole_stream_command(DataFrameIsNull),
|
||||
whole_stream_command(DataFrameIsNotNull),
|
||||
whole_stream_command(DataFrameAllTrue),
|
||||
whole_stream_command(DataFrameAllFalse),
|
||||
whole_stream_command(DataFrameArgMax),
|
||||
whole_stream_command(DataFrameArgMin),
|
||||
whole_stream_command(DataFrameArgTrue),
|
||||
whole_stream_command(DataFrameArgUnique),
|
||||
whole_stream_command(DataFrameArgSort),
|
||||
whole_stream_command(DataFrameUnique),
|
||||
whole_stream_command(DataFrameNUnique),
|
||||
whole_stream_command(DataFrameNNull),
|
||||
whole_stream_command(DataFrameIsUnique),
|
||||
whole_stream_command(DataFrameIsDuplicated),
|
||||
whole_stream_command(DataFrameIsIn),
|
||||
whole_stream_command(DataFrameShift),
|
||||
whole_stream_command(DataFrameSet),
|
||||
whole_stream_command(DataFrameNot),
|
||||
whole_stream_command(DataFrameTake),
|
||||
whole_stream_command(DataFrameSetWithIdx),
|
||||
whole_stream_command(DataFrameShape),
|
||||
whole_stream_command(DataFrameReplace),
|
||||
whole_stream_command(DataFrameReplaceAll),
|
||||
whole_stream_command(DataFrameStringLengths),
|
||||
whole_stream_command(DataFrameContains),
|
||||
whole_stream_command(DataFrameToLowercase),
|
||||
whole_stream_command(DataFrameToUppercase),
|
||||
whole_stream_command(DataFrameStringSlice),
|
||||
whole_stream_command(DataFrameConcatenate),
|
||||
whole_stream_command(DataFrameAppend),
|
||||
whole_stream_command(DataFrameGetHour),
|
||||
whole_stream_command(DataFrameGetMinute),
|
||||
whole_stream_command(DataFrameGetSecond),
|
||||
whole_stream_command(DataFrameGetDay),
|
||||
whole_stream_command(DataFrameGetMonth),
|
||||
whole_stream_command(DataFrameGetYear),
|
||||
whole_stream_command(DataFrameGetWeek),
|
||||
whole_stream_command(DataFrameGetWeekDay),
|
||||
whole_stream_command(DataFrameGetOrdinal),
|
||||
whole_stream_command(DataFrameGetNanoSecond),
|
||||
whole_stream_command(DataFrameStrFTime),
|
||||
whole_stream_command(DataFrameDescribe),
|
||||
whole_stream_command(DataFrameRolling),
|
||||
whole_stream_command(DataFrameCumulative),
|
||||
whole_stream_command(DataFrameRename),
|
||||
]);
|
||||
}
|
||||
|
||||
Ok(context)
|
||||
=======
|
||||
use nu_protocol::engine::{EngineState, StateWorkingSet};
|
||||
|
||||
use std::path::Path;
|
||||
@ -729,5 +356,4 @@ pub fn create_default_context(cwd: impl AsRef<Path>) -> EngineState {
|
||||
let _ = engine_state.merge_delta(delta, None, &cwd);
|
||||
|
||||
engine_state
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
use itertools::Either;
|
||||
use nu_engine::CallExt;
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::ast::{Call, RangeInclusion};
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, IntoInterruptiblePipelineData, PipelineData, PipelineIterator, ShellError,
|
||||
Signature, Span, SyntaxShape, Value,
|
||||
Category, Example, FromValue, IntoInterruptiblePipelineData, PipelineData, PipelineIterator,
|
||||
Range, ShellError, Signature, Span, Spanned, SyntaxShape, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -16,7 +17,13 @@ impl Command for DropNth {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("drop nth")
|
||||
.rest("rest", SyntaxShape::Int, "the number of the row to drop")
|
||||
.required(
|
||||
"row number or row range",
|
||||
// FIXME: we can make this accept either Int or Range when we can compose SyntaxShapes
|
||||
SyntaxShape::Any,
|
||||
"the number of the row to drop or a range to drop consecutive rows",
|
||||
)
|
||||
.rest("rest", SyntaxShape::Any, "the number of the row to drop")
|
||||
.category(Category::Filters)
|
||||
}
|
||||
|
||||
@ -58,6 +65,14 @@ impl Command for DropNth {
|
||||
span: Span::test_data(),
|
||||
}),
|
||||
},
|
||||
Example {
|
||||
description: "Drop range rows from second to fourth",
|
||||
example: "echo [first second third fourth fifth] | drop nth (1..3)",
|
||||
result: Some(Value::List {
|
||||
vals: vec![Value::test_string("first"), Value::test_string("fifth")],
|
||||
span: Span::test_data(),
|
||||
}),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
@ -68,12 +83,34 @@ impl Command for DropNth {
|
||||
call: &Call,
|
||||
input: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
let mut rows: Vec<usize> = call.rest(engine_state, stack, 0)?;
|
||||
rows.sort_unstable();
|
||||
let pipeline_iter: PipelineIterator = input.into_iter();
|
||||
// let mut rows: Vec<usize> = call.rest(engine_state, stack, 0)?;
|
||||
// rows.sort_unstable();
|
||||
// let pipeline_iter: PipelineIterator = input.into_iter();
|
||||
|
||||
let number_or_range = extract_int_or_range(engine_state, stack, call)?;
|
||||
let rows = match number_or_range {
|
||||
Either::Left(row_number) => {
|
||||
let and_rows: Vec<Spanned<i64>> = call.rest(engine_state, stack, 1)?;
|
||||
|
||||
let mut rows: Vec<_> = and_rows.into_iter().map(|x| x.item as usize).collect();
|
||||
rows.push(row_number as usize);
|
||||
rows.sort_unstable();
|
||||
rows
|
||||
}
|
||||
Either::Right(row_range) => {
|
||||
let from = row_range.from.as_integer()? as usize;
|
||||
let to = row_range.to.as_integer()? as usize;
|
||||
|
||||
if matches!(row_range.inclusion, RangeInclusion::Inclusive) {
|
||||
(from..=to).collect()
|
||||
} else {
|
||||
(from..to).collect()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Ok(DropNthIterator {
|
||||
input: pipeline_iter,
|
||||
input: input.into_iter(),
|
||||
rows,
|
||||
current: 0,
|
||||
}
|
||||
@ -81,6 +118,26 @@ impl Command for DropNth {
|
||||
}
|
||||
}
|
||||
|
||||
fn extract_int_or_range(
|
||||
engine_state: &EngineState,
|
||||
stack: &mut Stack,
|
||||
call: &Call,
|
||||
) -> Result<Either<i64, Range>, ShellError> {
|
||||
let value = call.req::<Value>(engine_state, stack, 0)?;
|
||||
|
||||
let int_opt = value.as_integer().map(Either::Left).ok();
|
||||
let range_opt: Result<nu_protocol::Range, ShellError> = FromValue::from_value(&value);
|
||||
|
||||
let range_opt = range_opt.map(Either::Right).ok();
|
||||
|
||||
int_opt.or(range_opt).ok_or_else(|| {
|
||||
ShellError::TypeMismatch(
|
||||
"int or range".into(),
|
||||
value.span().unwrap_or_else(|_| Span::new(0, 0)),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
struct DropNthIterator {
|
||||
input: PipelineIterator,
|
||||
rows: Vec<usize>,
|
||||
|
@ -1,32 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
#![recursion_limit = "2048"]
|
||||
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
extern crate indexmap;
|
||||
|
||||
#[macro_use]
|
||||
mod prelude;
|
||||
mod classified;
|
||||
pub mod commands;
|
||||
mod default_context;
|
||||
pub mod utils;
|
||||
|
||||
#[cfg(test)]
|
||||
mod examples;
|
||||
|
||||
pub use crate::default_context::create_default_context;
|
||||
pub use nu_data::config;
|
||||
pub use nu_data::dict::TaggedListBuilder;
|
||||
pub use nu_data::primitive;
|
||||
pub use nu_data::value;
|
||||
pub use nu_stream::{ActionStream, InputStream, InterruptibleStream};
|
||||
pub use nu_value_ext::ValueExt;
|
||||
pub use num_traits::cast::ToPrimitive;
|
||||
|
||||
// TODO: Temporary redirect
|
||||
pub use nu_protocol::{did_you_mean, TaggedDictBuilder};
|
||||
=======
|
||||
mod conversions;
|
||||
mod core_commands;
|
||||
mod date;
|
||||
@ -77,4 +48,3 @@ mod dataframe;
|
||||
|
||||
#[cfg(feature = "dataframe")]
|
||||
pub use dataframe::*;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
@ -1,24 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
use nu_test_support::pipeline as input;
|
||||
use nu_test_support::playground::{says, Playground};
|
||||
|
||||
use hamcrest2::assert_that;
|
||||
use hamcrest2::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn checks_all_rows_are_true() {
|
||||
Playground::setup("all_test_1", |_, nu| {
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
echo [ "Andrés", "Andrés", "Andrés" ]
|
||||
| all? $it == "Andrés"
|
||||
"#
|
||||
)),
|
||||
says().stdout("true")
|
||||
);
|
||||
})
|
||||
=======
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
@ -32,23 +11,10 @@ fn checks_all_rows_are_true() {
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checks_all_rows_are_false_with_param() {
|
||||
<<<<<<< HEAD
|
||||
Playground::setup("all_test_1", |_, nu| {
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
[1, 2, 3, 4] | all? { |a| $a >= 5 }
|
||||
"#
|
||||
)),
|
||||
says().stdout("false")
|
||||
);
|
||||
})
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
@ -57,23 +23,10 @@ fn checks_all_rows_are_false_with_param() {
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "false");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checks_all_rows_are_true_with_param() {
|
||||
<<<<<<< HEAD
|
||||
Playground::setup("all_test_1", |_, nu| {
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
[1, 2, 3, 4] | all? { |a| $a < 5 }
|
||||
"#
|
||||
)),
|
||||
says().stdout("true")
|
||||
);
|
||||
})
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
@ -82,21 +35,13 @@ fn checks_all_rows_are_true_with_param() {
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checks_all_columns_of_a_table_is_true() {
|
||||
<<<<<<< HEAD
|
||||
Playground::setup("any_test_1", |_, nu| {
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
echo [
|
||||
[ first_name, last_name, rusty_at, likes ];
|
||||
[ Andrés, Robalino, 10/11/2013, 1 ]
|
||||
@ -105,16 +50,8 @@ fn checks_all_columns_of_a_table_is_true() {
|
||||
[ Yehuda, Katz, 10/11/2013, 1 ]
|
||||
]
|
||||
| all? likes > 0
|
||||
<<<<<<< HEAD
|
||||
"#
|
||||
)),
|
||||
says().stdout("true")
|
||||
);
|
||||
})
|
||||
=======
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
@ -1,24 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
use nu_test_support::pipeline as input;
|
||||
use nu_test_support::playground::{says, Playground};
|
||||
|
||||
use hamcrest2::assert_that;
|
||||
use hamcrest2::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn checks_any_row_is_true() {
|
||||
Playground::setup("any_test_1", |_, nu| {
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
echo [ "Ecuador", "USA", "New Zealand" ]
|
||||
| any? $it == "New Zealand"
|
||||
"#
|
||||
)),
|
||||
says().stdout("true")
|
||||
);
|
||||
})
|
||||
=======
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
@ -32,21 +11,13 @@ fn checks_any_row_is_true() {
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checks_any_column_of_a_table_is_true() {
|
||||
<<<<<<< HEAD
|
||||
Playground::setup("any_test_1", |_, nu| {
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
echo [
|
||||
[ first_name, last_name, rusty_at, likes ];
|
||||
[ Andrés, Robalino, 10/11/2013, 1 ]
|
||||
@ -55,16 +26,8 @@ fn checks_any_column_of_a_table_is_true() {
|
||||
[ Yehuda, Katz, 10/11/2013, 1 ]
|
||||
]
|
||||
| any? rusty_at == 10/12/2013
|
||||
<<<<<<< HEAD
|
||||
"#
|
||||
)),
|
||||
says().stdout("true")
|
||||
);
|
||||
})
|
||||
=======
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
@ -1,25 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
use nu_test_support::pipeline as input;
|
||||
use nu_test_support::playground::{says, Playground};
|
||||
|
||||
use hamcrest2::assert_that;
|
||||
use hamcrest2::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn adds_a_row_to_the_end() {
|
||||
Playground::setup("append_test_1", |_, nu| {
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
echo [ "Andrés N. Robalino", "Jonathan Turner", "Yehuda Katz" ]
|
||||
| append "pollo loco"
|
||||
| nth 3
|
||||
"#
|
||||
)),
|
||||
says().stdout("pollo loco")
|
||||
);
|
||||
})
|
||||
=======
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
@ -34,5 +12,4 @@ fn adds_a_row_to_the_end() {
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "pollo loco");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
@ -5,19 +5,11 @@ fn cal_full_year() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
cal -y --full-year 2010 | first | to json
|
||||
"#
|
||||
));
|
||||
|
||||
let first_week_2010_json = r#"{"year":2010,"sunday":null,"monday":null,"tuesday":null,"wednesday":null,"thursday":null,"friday":1,"saturday":2}"#;
|
||||
=======
|
||||
cal -y --full-year 2010 | first | to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
let first_week_2010_json = r#"{"year": 2010,"sunday": null,"monday": null,"tuesday": null,"wednesday": null,"thursday": null,"friday": 1,"saturday": 2}"#;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
||||
assert_eq!(actual.out, first_week_2010_json);
|
||||
}
|
||||
@ -27,19 +19,11 @@ fn cal_february_2020_leap_year() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
cal -ym --full-year 2020 --month-names | where month == "february" | to json
|
||||
"#
|
||||
));
|
||||
|
||||
let cal_february_json = r#"[{"year":2020,"month":"february","sunday":null,"monday":null,"tuesday":null,"wednesday":null,"thursday":null,"friday":null,"saturday":1},{"year":2020,"month":"february","sunday":2,"monday":3,"tuesday":4,"wednesday":5,"thursday":6,"friday":7,"saturday":8},{"year":2020,"month":"february","sunday":9,"monday":10,"tuesday":11,"wednesday":12,"thursday":13,"friday":14,"saturday":15},{"year":2020,"month":"february","sunday":16,"monday":17,"tuesday":18,"wednesday":19,"thursday":20,"friday":21,"saturday":22},{"year":2020,"month":"february","sunday":23,"monday":24,"tuesday":25,"wednesday":26,"thursday":27,"friday":28,"saturday":29}]"#;
|
||||
=======
|
||||
cal -ym --full-year 2020 --month-names | where month == "february" | to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
let cal_february_json = r#"[{"year": 2020,"month": "february","sunday": null,"monday": null,"tuesday": null,"wednesday": null,"thursday": null,"friday": null,"saturday": 1},{"year": 2020,"month": "february","sunday": 2,"monday": 3,"tuesday": 4,"wednesday": 5,"thursday": 6,"friday": 7,"saturday": 8},{"year": 2020,"month": "february","sunday": 9,"monday": 10,"tuesday": 11,"wednesday": 12,"thursday": 13,"friday": 14,"saturday": 15},{"year": 2020,"month": "february","sunday": 16,"monday": 17,"tuesday": 18,"wednesday": 19,"thursday": 20,"friday": 21,"saturday": 22},{"year": 2020,"month": "february","sunday": 23,"monday": 24,"tuesday": 25,"wednesday": 26,"thursday": 27,"friday": 28,"saturday": 29}]"#;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
||||
assert_eq!(actual.out, cal_february_json);
|
||||
}
|
||||
@ -73,19 +57,11 @@ fn cal_week_day_start_monday() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
cal --full-year 2020 -m --month-names --week-start monday | where month == january | to json
|
||||
"#
|
||||
));
|
||||
|
||||
let cal_january_json = r#"[{"month":"january","monday":null,"tuesday":null,"wednesday":1,"thursday":2,"friday":3,"saturday":4,"sunday":5},{"month":"january","monday":6,"tuesday":7,"wednesday":8,"thursday":9,"friday":10,"saturday":11,"sunday":12},{"month":"january","monday":13,"tuesday":14,"wednesday":15,"thursday":16,"friday":17,"saturday":18,"sunday":19},{"month":"january","monday":20,"tuesday":21,"wednesday":22,"thursday":23,"friday":24,"saturday":25,"sunday":26},{"month":"january","monday":27,"tuesday":28,"wednesday":29,"thursday":30,"friday":31,"saturday":null,"sunday":null}]"#;
|
||||
=======
|
||||
cal --full-year 2020 -m --month-names --week-start monday | where month == january | to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
let cal_january_json = r#"[{"month": "january","monday": null,"tuesday": null,"wednesday": 1,"thursday": 2,"friday": 3,"saturday": 4,"sunday": 5},{"month": "january","monday": 6,"tuesday": 7,"wednesday": 8,"thursday": 9,"friday": 10,"saturday": 11,"sunday": 12},{"month": "january","monday": 13,"tuesday": 14,"wednesday": 15,"thursday": 16,"friday": 17,"saturday": 18,"sunday": 19},{"month": "january","monday": 20,"tuesday": 21,"wednesday": 22,"thursday": 23,"friday": 24,"saturday": 25,"sunday": 26},{"month": "january","monday": 27,"tuesday": 28,"wednesday": 29,"thursday": 30,"friday": 31,"saturday": null,"sunday": null}]"#;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
||||
assert_eq!(actual.out, cal_january_json);
|
||||
}
|
||||
@ -95,17 +71,9 @@ fn cal_sees_pipeline_year() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
cal --full-year 1020 | get monday | first 3 | to json
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "[3,10,17]");
|
||||
=======
|
||||
cal --full-year 1020 | get monday | first 4 | to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "[null,3,10,17]");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
@ -1,17 +1,10 @@
|
||||
<<<<<<< HEAD
|
||||
use nu_test_support::fs::{Stub::EmptyFile, Stub::FileWithContent};
|
||||
=======
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
use std::path::PathBuf;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_from_current_directory_using_relative_path() {
|
||||
Playground::setup("cd_test_1", |dirs, _| {
|
||||
@ -27,11 +20,8 @@ fn filesystem_change_from_current_directory_using_relative_path() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_from_current_directory_using_absolute_path() {
|
||||
Playground::setup("cd_test_2", |dirs, _| {
|
||||
@ -48,11 +38,8 @@ fn filesystem_change_from_current_directory_using_absolute_path() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_switch_back_to_previous_working_directory() {
|
||||
Playground::setup("cd_test_3", |dirs, sandbox| {
|
||||
@ -72,11 +59,8 @@ fn filesystem_switch_back_to_previous_working_directory() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesytem_change_from_current_directory_using_relative_path_and_dash() {
|
||||
Playground::setup("cd_test_4", |dirs, sandbox| {
|
||||
@ -97,11 +81,8 @@ fn filesytem_change_from_current_directory_using_relative_path_and_dash() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_current_directory_to_parent_directory() {
|
||||
Playground::setup("cd_test_5", |dirs, _| {
|
||||
@ -117,11 +98,8 @@ fn filesystem_change_current_directory_to_parent_directory() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_current_directory_to_two_parents_up_using_multiple_dots() {
|
||||
Playground::setup("cd_test_6", |dirs, sandbox| {
|
||||
@ -139,11 +117,8 @@ fn filesystem_change_current_directory_to_two_parents_up_using_multiple_dots() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_current_directory_to_parent_directory_after_delete_cwd() {
|
||||
Playground::setup("cd_test_7", |dirs, sandbox| {
|
||||
@ -166,11 +141,8 @@ fn filesystem_change_current_directory_to_parent_directory_after_delete_cwd() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_to_home_directory() {
|
||||
Playground::setup("cd_test_8", |dirs, _| {
|
||||
@ -186,11 +158,8 @@ fn filesystem_change_to_home_directory() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_to_a_directory_containing_spaces() {
|
||||
Playground::setup("cd_test_9", |dirs, sandbox| {
|
||||
@ -211,11 +180,8 @@ fn filesystem_change_to_a_directory_containing_spaces() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_not_a_directory() {
|
||||
Playground::setup("cd_test_10", |dirs, sandbox| {
|
||||
@ -239,11 +205,8 @@ fn filesystem_not_a_directory() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_directory_not_found() {
|
||||
Playground::setup("cd_test_11", |dirs, _| {
|
||||
@ -266,11 +229,8 @@ fn filesystem_directory_not_found() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn filesystem_change_directory_to_symlink_relative() {
|
||||
Playground::setup("cd_test_12", |dirs, sandbox| {
|
||||
@ -290,218 +250,8 @@ fn filesystem_change_directory_to_symlink_relative() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
#[test]
|
||||
fn valuesystem_change_from_current_path_using_relative_path() {
|
||||
Playground::setup("cd_test_13", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[[bin]]
|
||||
path = "src/plugins/turner.rs"
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/robalino.rs"
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/katz.rs"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
r#"
|
||||
enter sample.toml
|
||||
cd bin
|
||||
pwd
|
||||
exit
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), PathBuf::from("/bin"));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valuesystem_change_from_current_path_using_absolute_path() {
|
||||
Playground::setup("cd_test_14", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[dependencies]
|
||||
turner-ts = "0.1.1"
|
||||
robalino-tkd = "0.0.1"
|
||||
katz-ember = "0.2.3"
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/arepa.rs"
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/bbq.rs"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
r#"
|
||||
enter sample.toml
|
||||
cd bin
|
||||
cd /dependencies
|
||||
pwd
|
||||
exit
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), PathBuf::from("/dependencies"));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valuesystem_switch_back_to_previous_working_path() {
|
||||
Playground::setup("cd_test_15", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[dependencies]
|
||||
turner-ts = "0.1.1"
|
||||
robalino-tkd = "0.0.1"
|
||||
katz-ember = "0.2.3"
|
||||
odin-gf = "0.2.1"
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/arepa.rs"
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/bbq.rs"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
r#"
|
||||
enter sample.toml
|
||||
cd dependencies
|
||||
cd /bin
|
||||
cd -
|
||||
pwd
|
||||
exit
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), PathBuf::from("/dependencies"));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valuesystem_change_from_current_path_using_relative_path_and_dash() {
|
||||
Playground::setup("cd_test_16", |dirs, sandbox| {
|
||||
sandbox
|
||||
.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
- = ["Yehuda Katz <wycats@gmail.com>", "Jonathan Turner <jonathan.d.turner@gmail.com>", "Andrés N. Robalino <andres@androbtech.com>"]
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/arepa.rs"
|
||||
|
||||
[[bin]]
|
||||
path = "src/plugins/bbq.rs"
|
||||
"#
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
r#"
|
||||
enter sample.toml
|
||||
cd package/-
|
||||
cd /bin
|
||||
cd -
|
||||
pwd
|
||||
exit
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), PathBuf::from("/package/-"));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valuesystem_change_current_path_to_parent_path() {
|
||||
Playground::setup("cd_test_17", |dirs, sandbox| {
|
||||
sandbox
|
||||
.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
emberenios = ["Yehuda Katz <wycats@gmail.com>", "Jonathan Turner <jonathan.d.turner@gmail.com>", "Andrés N. Robalino <andres@androbtech.com>"]
|
||||
"#
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
r#"
|
||||
enter sample.toml
|
||||
cd package/emberenios
|
||||
cd ..
|
||||
pwd
|
||||
exit
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), PathBuf::from("/package"));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valuesystem_change_to_a_path_containing_spaces() {
|
||||
Playground::setup("cd_test_18", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
["pa que te"]
|
||||
el = "pollo loco"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
r#"
|
||||
enter sample.toml
|
||||
cd "pa que te"
|
||||
pwd
|
||||
exit
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
PathBuf::from(actual.out),
|
||||
PathBuf::from("/").join("pa que te")
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valuesystem_path_not_found() {
|
||||
Playground::setup("cd_test_19", |dirs, _| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.formats(),
|
||||
r#"
|
||||
enter cargo_sample.toml
|
||||
cd im_a_path_that_does_not_exist
|
||||
exit
|
||||
"#
|
||||
);
|
||||
|
||||
assert!(actual.err.contains("Can not change to path inside"));
|
||||
assert!(actual.err.contains("No such path exists"));
|
||||
})
|
||||
}
|
||||
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[cfg(target_os = "windows")]
|
||||
#[test]
|
||||
fn test_change_windows_drive() {
|
||||
|
50
crates/nu-command/tests/commands/compact.rs
Normal file
50
crates/nu-command/tests/commands/compact.rs
Normal file
@ -0,0 +1,50 @@
|
||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn discards_rows_where_given_column_is_empty() {
|
||||
Playground::setup("compact_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"los_tres_amigos.json",
|
||||
r#"
|
||||
{
|
||||
"amigos": [
|
||||
{"name": "Yehuda", "rusty_luck": 1},
|
||||
{"name": "Jonathan", "rusty_luck": 1},
|
||||
{"name": "Andres", "rusty_luck": 1},
|
||||
{"name":"GorbyPuff"}
|
||||
]
|
||||
}
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open los_tres_amigos.json
|
||||
| get amigos
|
||||
| compact rusty_luck
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "3");
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn discards_empty_rows_by_default() {
|
||||
Playground::setup("compact_test_2", |dirs, _| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
echo "[1,2,3,14,null]"
|
||||
| from json
|
||||
| compact
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4");
|
||||
});
|
||||
}
|
@ -31,11 +31,8 @@ fn copies_the_file_inside_directory_if_path_to_copy_is_directory() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn error_if_attempting_to_copy_a_directory_to_another_directory() {
|
||||
Playground::setup("cp_test_3", |dirs, _| {
|
||||
@ -80,11 +77,8 @@ fn copies_the_directory_inside_directory_if_path_to_copy_is_directory_and_with_r
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn deep_copies_with_recursive_flag() {
|
||||
Playground::setup("cp_test_5", |dirs, sandbox| {
|
||||
|
@ -1,12 +1,9 @@
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
use std::fs;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn def_with_comment() {
|
||||
Playground::setup("def_with_comment", |dirs, _| {
|
||||
|
35
crates/nu-command/tests/commands/default.rs
Normal file
35
crates/nu-command/tests/commands/default.rs
Normal file
@ -0,0 +1,35 @@
|
||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn adds_row_data_if_column_missing() {
|
||||
Playground::setup("default_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"los_tres_amigos.json",
|
||||
r#"
|
||||
{
|
||||
"amigos": [
|
||||
{"name": "Yehuda"},
|
||||
{"name": "Jonathan", "rusty_luck": 0},
|
||||
{"name": "Andres", "rusty_luck": 0},
|
||||
{"name":"GorbyPuff"}
|
||||
]
|
||||
}
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open los_tres_amigos.json
|
||||
| get amigos
|
||||
| default rusty_luck 1
|
||||
| where rusty_luck == 1
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "2");
|
||||
});
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn columns() {
|
||||
let actual = nu!(
|
||||
@ -25,11 +22,8 @@ fn columns() {
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn more_columns_than_table_has() {
|
||||
let actual = nu!(
|
||||
@ -76,18 +70,17 @@ fn more_rows_than_table_has() {
|
||||
|
||||
assert_eq!(actual.out, "0");
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
#[test]
|
||||
fn nth_range_inclusive() {
|
||||
let actual = nu!(cwd: ".", "echo 10..15 | drop nth (2..3) | to json");
|
||||
let actual = nu!(cwd: ".", "echo 10..15 | drop nth (2..3) | to json --raw");
|
||||
|
||||
assert_eq!(actual.out, "[10,11,14,15]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nth_range_exclusive() {
|
||||
let actual = nu!(cwd: ".", "echo 10..15 | drop nth (1..<3) | to json");
|
||||
let actual = nu!(cwd: ".", "echo 10..15 | drop nth (1..<3) | to json --raw");
|
||||
|
||||
assert_eq!(actual.out, "[10,13,14,15]");
|
||||
}
|
||||
@ -96,8 +89,5 @@ fn nth_range_exclusive() {
|
||||
fn nth_missing_first_argument() {
|
||||
let actual = nu!(cwd: ".", "echo 10..15 | drop nth \"\"");
|
||||
|
||||
assert!(actual.err.contains("Expected int or range"));
|
||||
assert!(actual.err.contains("found string"));
|
||||
assert!(actual.err.contains("int or range"));
|
||||
}
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
@ -5,11 +5,7 @@ fn each_works_separately() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo [1 2 3] | each { echo $it 10 | math sum } | to json
|
||||
=======
|
||||
echo [1 2 3] | each { echo $it 10 | math sum } | to json -r
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -21,11 +17,7 @@ fn each_group_works() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo [1 2 3 4 5 6] | each group 3 { $it } | to json
|
||||
=======
|
||||
echo [1 2 3 4 5 6] | each group 3 { $it } | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -37,11 +29,7 @@ fn each_window() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo [1 2 3 4] | each window 3 { $it } | to json
|
||||
=======
|
||||
echo [1 2 3 4] | each window 3 { $it } | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -53,11 +41,7 @@ fn each_window_stride() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo [1 2 3 4 5 6] | each window 3 -s 2 { echo $it } | to json
|
||||
=======
|
||||
echo [1 2 3 4 5 6] | each window 3 -s 2 { echo $it } | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -69,19 +53,11 @@ fn each_no_args_in_block() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo [[foo bar]; [a b] [c d] [e f]] | each { to json } | nth 1 | str collect
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#"{"foo":"c","bar":"d"}"#);
|
||||
=======
|
||||
echo [[foo bar]; [a b] [c d] [e f]] | each {|i| $i | to json -r } | nth 1
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#"{"foo": "c","bar": "d"}"#);
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -5,11 +5,7 @@ fn echo_range_is_lazy() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 1..10000000000 | first 3 | to json
|
||||
=======
|
||||
echo 1..10000000000 | first 3 | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -21,11 +17,7 @@ fn echo_range_handles_inclusive() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 1..3 | to json
|
||||
=======
|
||||
echo 1..3 | each { $it } | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -37,11 +29,7 @@ fn echo_range_handles_exclusive() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 1..<3 | to json
|
||||
=======
|
||||
echo 1..<3 | each { $it } | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -53,11 +41,7 @@ fn echo_range_handles_inclusive_down() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 3..1 | to json
|
||||
=======
|
||||
echo 3..1 | each { $it } | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -69,11 +53,7 @@ fn echo_range_handles_exclusive_down() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 3..<1 | to json
|
||||
=======
|
||||
echo 3..<1 | each { $it } | to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn reports_emptiness() {
|
||||
let actual = nu!(
|
||||
@ -25,11 +22,8 @@ fn reports_emptiness() {
|
||||
assert_eq!(actual.out, "3");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn sets_block_run_value_for_an_empty_column() {
|
||||
let actual = nu!(
|
||||
@ -51,11 +45,8 @@ fn sets_block_run_value_for_an_empty_column() {
|
||||
assert_eq!(actual.out, "4");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn sets_block_run_value_for_many_empty_columns() {
|
||||
let actual = nu!(
|
||||
@ -76,11 +67,8 @@ fn sets_block_run_value_for_many_empty_columns() {
|
||||
assert_eq!(actual.out, "6");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn passing_a_block_will_set_contents_on_empty_cells_and_leave_non_empty_ones_untouched() {
|
||||
let actual = nu!(
|
||||
|
@ -71,18 +71,3 @@ fn knows_the_filesystems_entered() {
|
||||
));
|
||||
})
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
#[test]
|
||||
fn errors_if_file_not_found() {
|
||||
Playground::setup("enter_test_2", |dirs, _| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"enter i_dont_exist.csv"
|
||||
);
|
||||
|
||||
assert!(actual.err.contains("Cannot find file"));
|
||||
})
|
||||
}
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
@ -18,11 +18,7 @@ fn gets_all_rows_by_every_zero() {
|
||||
ls
|
||||
| get name
|
||||
| every 0
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -49,19 +45,11 @@ fn gets_no_rows_by_every_skip_zero() {
|
||||
ls
|
||||
| get name
|
||||
| every 0 --skip
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "");
|
||||
=======
|
||||
| to json --raw
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "[]");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
})
|
||||
}
|
||||
|
||||
@ -81,11 +69,7 @@ fn gets_all_rows_by_every_one() {
|
||||
ls
|
||||
| get name
|
||||
| every 1
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -96,11 +80,8 @@ fn gets_all_rows_by_every_one() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn gets_no_rows_by_every_skip_one() {
|
||||
Playground::setup("every_test_4", |dirs, sandbox| {
|
||||
@ -117,11 +98,7 @@ fn gets_no_rows_by_every_skip_one() {
|
||||
ls
|
||||
| get name
|
||||
| every 1 --skip
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -175,11 +152,7 @@ fn gets_all_rows_except_first_by_every_skip_too_much() {
|
||||
ls
|
||||
| get name
|
||||
| every 999 --skip
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -204,11 +177,7 @@ fn gets_every_third_row() {
|
||||
ls
|
||||
| get name
|
||||
| every 3
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -233,11 +202,7 @@ fn skips_every_third_row() {
|
||||
ls
|
||||
| get name
|
||||
| every 3 --skip
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json --raw
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
|
@ -19,11 +19,7 @@ fn find_with_list_search_with_char() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
[moe larry curly] | find l | to json
|
||||
=======
|
||||
[moe larry curly] | find l | to json -r
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -82,19 +78,11 @@ fn find_with_filepath_search_with_string() {
|
||||
ls
|
||||
| get name
|
||||
| find arep
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#""arepas.clu""#);
|
||||
=======
|
||||
| to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#"["arepas.clu"]"#);
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
})
|
||||
}
|
||||
|
||||
@ -114,11 +102,7 @@ fn find_with_filepath_search_with_multiple_patterns() {
|
||||
ls
|
||||
| get name
|
||||
| find arep ami
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json -r
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
|
67
crates/nu-command/tests/commands/first.rs
Normal file
67
crates/nu-command/tests/commands/first.rs
Normal file
@ -0,0 +1,67 @@
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn gets_first_rows_by_amount() {
|
||||
Playground::setup("first_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("los.txt"),
|
||||
EmptyFile("tres.txt"),
|
||||
EmptyFile("amigos.txt"),
|
||||
EmptyFile("arepas.clu"),
|
||||
]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| first 3
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "3");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gets_all_rows_if_amount_higher_than_all_rows() {
|
||||
Playground::setup("first_test_2", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("los.txt"),
|
||||
EmptyFile("tres.txt"),
|
||||
EmptyFile("amigos.txt"),
|
||||
EmptyFile("arepas.clu"),
|
||||
]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| first 99
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gets_first_row_when_no_amount_given() {
|
||||
Playground::setup("first_test_3", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("caballeros.txt"), EmptyFile("arepas.clu")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| first
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
})
|
||||
}
|
@ -2,11 +2,8 @@ use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn flatten_nested_tables_with_columns() {
|
||||
let actual = nu!(
|
||||
@ -23,11 +20,8 @@ fn flatten_nested_tables_with_columns() {
|
||||
assert_eq!(actual.out, "Andres,nuno");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn flatten_nested_tables_that_have_many_columns() {
|
||||
let actual = nu!(
|
||||
@ -88,11 +82,8 @@ fn flatten_row_column_explicitly() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn flatten_row_columns_having_same_column_names_flats_separately() {
|
||||
Playground::setup("flatten_test_2", |dirs, sandbox| {
|
||||
@ -127,11 +118,8 @@ fn flatten_row_columns_having_same_column_names_flats_separately() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn flatten_table_columns_explicitly() {
|
||||
Playground::setup("flatten_test_3", |dirs, sandbox| {
|
||||
|
@ -16,11 +16,8 @@ fn creates_the_resulting_string_from_the_given_fields() {
|
||||
assert_eq!(actual.out, "nu has license ISC");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn given_fields_can_be_column_paths() {
|
||||
let actual = nu!(
|
||||
@ -34,11 +31,8 @@ fn given_fields_can_be_column_paths() {
|
||||
assert_eq!(actual.out, "nu is a new type of shell");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn can_use_variables() {
|
||||
let actual = nu!(
|
||||
@ -52,11 +46,8 @@ fn can_use_variables() {
|
||||
assert_eq!(actual.out, "nu is a new type of shell");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn format_filesize_works() {
|
||||
Playground::setup("format_filesize_test_1", |dirs, sandbox| {
|
||||
@ -80,11 +71,8 @@ fn format_filesize_works() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn format_filesize_works_with_nonempty_files() {
|
||||
Playground::setup(
|
||||
|
@ -130,11 +130,8 @@ fn fetches_more_than_one_column_path() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_fetching_by_column_not_present() {
|
||||
Playground::setup("get_test_6", |dirs, sandbox| {
|
||||
@ -165,11 +162,8 @@ fn errors_fetching_by_column_not_present() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_fetching_by_column_using_a_number() {
|
||||
Playground::setup("get_test_7", |dirs, sandbox| {
|
||||
@ -196,12 +190,9 @@ fn errors_fetching_by_column_using_a_number() {
|
||||
.contains("Appears to contain columns. Columns available: 0"),)
|
||||
})
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_fetching_by_index_out_of_bounds() {
|
||||
Playground::setup("get_test_8", |dirs, sandbox| {
|
||||
|
@ -71,11 +71,8 @@ fn errors_if_given_unknown_column_name() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_block_given_evaluates_more_than_one_row() {
|
||||
Playground::setup("group_by_test_3", |dirs, sandbox| {
|
||||
|
@ -26,11 +26,8 @@ fn base64_encode_characterset_binhex() {
|
||||
assert_eq!(actual.out, "F@0NEPjJD97kE\'&bEhFZEP3");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn error_when_invalid_character_set_given() {
|
||||
let actual = nu!(
|
||||
@ -46,11 +43,8 @@ fn error_when_invalid_character_set_given() {
|
||||
.contains("this is invalid is not a valid character-set"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn base64_decode_characterset_binhex() {
|
||||
let actual = nu!(
|
||||
@ -94,11 +88,8 @@ fn error_use_both_flags() {
|
||||
.contains("only one of --decode and --encode flags can be used"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn md5_works_with_file() {
|
||||
let actual = nu!(
|
||||
@ -112,11 +103,8 @@ fn md5_works_with_file() {
|
||||
assert_eq!(actual.out, "4de97601d232c427977ef11db396c951");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn sha256_works_with_file() {
|
||||
let actual = nu!(
|
||||
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn headers_uses_first_row_as_header() {
|
||||
let actual = nu!(
|
||||
@ -20,11 +17,8 @@ fn headers_uses_first_row_as_header() {
|
||||
assert_eq!(actual.out, "r1c0r2c0")
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn headers_adds_missing_column_name() {
|
||||
let actual = nu!(
|
||||
|
@ -15,11 +15,8 @@ fn help_commands_length() {
|
||||
assert!(is_positive);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn help_generate_docs_length() {
|
||||
let actual = nu!(
|
||||
|
@ -2,11 +2,8 @@ use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn summarizes_by_column_given() {
|
||||
Playground::setup("histogram_test_1", |dirs, sandbox| {
|
||||
@ -38,11 +35,8 @@ fn summarizes_by_column_given() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn summarizes_by_values() {
|
||||
Playground::setup("histogram_test_2", |dirs, sandbox| {
|
||||
@ -71,11 +65,8 @@ fn summarizes_by_values() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn help() {
|
||||
Playground::setup("histogram_test_3", |dirs, _sandbox| {
|
||||
@ -105,11 +96,8 @@ fn help() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn count() {
|
||||
let actual = nu!(
|
||||
|
@ -33,11 +33,7 @@ fn into_filesize_str() {
|
||||
"#
|
||||
));
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert!(actual.out.contains("2.0 KB"));
|
||||
=======
|
||||
assert!(actual.out.contains("2.0 KiB"));
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -45,21 +41,12 @@ fn into_filesize_str_newline() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
'2000
|
||||
' | into filesize
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("2.0 KB"));
|
||||
=======
|
||||
"2000
|
||||
" | into filesize
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("2.0 KiB"));
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -67,15 +54,6 @@ fn into_filesize_str_many_newlines() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
'2000
|
||||
|
||||
' | into filesize
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("2.0 KB"));
|
||||
=======
|
||||
"2000
|
||||
|
||||
" | into filesize
|
||||
@ -83,7 +61,6 @@ fn into_filesize_str_many_newlines() {
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("2.0 KiB"));
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -91,17 +68,9 @@ fn into_filesize_filesize() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
3kb | into filesize
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("3.0 KB"));
|
||||
=======
|
||||
3kib | into filesize
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("3.0 KiB"));
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
37
crates/nu-command/tests/commands/into_int.rs
Normal file
37
crates/nu-command/tests/commands/into_int.rs
Normal file
@ -0,0 +1,37 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn into_int_filesize() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 1kb | into int | each { $it / 1000 }
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains('1'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn into_int_filesize2() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 1kib | into int | each { $it / 1024 }
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains('1'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn into_int_int() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 1024 | into int | each { $it / 1024 }
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains('1'));
|
||||
}
|
3
crates/nu-command/tests/commands/keep/mod.rs
Normal file
3
crates/nu-command/tests/commands/keep/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
mod rows;
|
||||
mod until;
|
||||
mod while_;
|
31
crates/nu-command/tests/commands/keep/rows.rs
Normal file
31
crates/nu-command/tests/commands/keep/rows.rs
Normal file
@ -0,0 +1,31 @@
|
||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn rows() {
|
||||
Playground::setup("keep_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"caballeros.csv",
|
||||
r#"
|
||||
name,lucky_code
|
||||
Andrés,1
|
||||
Jonathan,1
|
||||
Jason,2
|
||||
Yehuda,1
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open caballeros.csv
|
||||
| keep 3
|
||||
| get lucky_code
|
||||
| math sum
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4");
|
||||
})
|
||||
}
|
@ -10,11 +10,7 @@ fn condition_is_met() {
|
||||
r#"
|
||||
CHICKEN SUMMARY report date: April 29th, 2020
|
||||
--------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020,
|
||||
=======
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
Yellow Chickens,,,
|
||||
Andrés,1,1,1
|
||||
Jonathan,1,1,1
|
||||
@ -37,16 +33,6 @@ fn condition_is_met() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open --raw caballeros.txt
|
||||
<<<<<<< HEAD
|
||||
| lines
|
||||
| skip 2
|
||||
| split column ','
|
||||
| headers
|
||||
| skip while "Chicken Collection" != "Blue Chickens"
|
||||
| keep until "Chicken Collection" == "Red Chickens"
|
||||
| skip 1
|
||||
| str to-int "31/04/2020"
|
||||
=======
|
||||
| lines
|
||||
| skip 2
|
||||
| str trim
|
||||
@ -56,7 +42,6 @@ fn condition_is_met() {
|
||||
| keep until "Chicken Collection" == "Red Chickens"
|
||||
| skip 1
|
||||
| into int "31/04/2020"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get "31/04/2020"
|
||||
| math sum
|
||||
"#
|
||||
|
@ -10,11 +10,7 @@ fn condition_is_met() {
|
||||
r#"
|
||||
CHICKEN SUMMARY report date: April 29th, 2020
|
||||
--------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020,
|
||||
=======
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
Yellow Chickens,,,
|
||||
Andrés,1,1,1
|
||||
Jonathan,1,1,1
|
||||
@ -37,15 +33,6 @@ fn condition_is_met() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open --raw caballeros.txt
|
||||
<<<<<<< HEAD
|
||||
| lines
|
||||
| skip 2
|
||||
| split column ','
|
||||
| headers
|
||||
| skip 1
|
||||
| keep while "Chicken Collection" != "Blue Chickens"
|
||||
| str to-int "31/04/2020"
|
||||
=======
|
||||
| lines
|
||||
| skip 2
|
||||
| str trim
|
||||
@ -54,7 +41,6 @@ fn condition_is_met() {
|
||||
| skip 1
|
||||
| keep while "Chicken Collection" != "Blue Chickens"
|
||||
| into int "31/04/2020"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get "31/04/2020"
|
||||
| math sum
|
||||
"#
|
||||
|
66
crates/nu-command/tests/commands/last.rs
Normal file
66
crates/nu-command/tests/commands/last.rs
Normal file
@ -0,0 +1,66 @@
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn gets_the_last_row() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
"ls | sort-by name | last 1 | get name | str trim"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "utf16.ini");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gets_last_rows_by_amount() {
|
||||
Playground::setup("last_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("los.txt"),
|
||||
EmptyFile("tres.txt"),
|
||||
EmptyFile("amigos.txt"),
|
||||
EmptyFile("arepas.clu"),
|
||||
]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| last 3
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "3");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gets_last_row_when_no_amount_given() {
|
||||
Playground::setup("last_test_2", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("caballeros.txt"), EmptyFile("arepas.clu")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| last
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn requests_more_rows_than_table_has() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
date | last 50 | length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
25
crates/nu-command/tests/commands/length.rs
Normal file
25
crates/nu-command/tests/commands/length.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn length_columns_in_cal_table() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
cal | length -c
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "7");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn length_columns_no_rows() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [] | length -c
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "0");
|
||||
}
|
@ -27,11 +27,7 @@ fn lines_proper_buffering() {
|
||||
open lines_test.txt -r
|
||||
| lines
|
||||
| str length
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
=======
|
||||
| to json -r
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -50,9 +46,5 @@ fn lines_multi_value_split() {
|
||||
"#
|
||||
));
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert_eq!(actual.out, "5");
|
||||
=======
|
||||
assert_eq!(actual.out, "6");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
@ -88,11 +88,7 @@ fn lists_all_files_in_directories_from_stream() {
|
||||
r#"
|
||||
echo dir_a dir_b
|
||||
| each { ls $it }
|
||||
<<<<<<< HEAD
|
||||
| length
|
||||
=======
|
||||
| flatten | length
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
));
|
||||
|
||||
@ -304,22 +300,14 @@ fn list_all_columns() {
|
||||
// Normal Operation
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
<<<<<<< HEAD
|
||||
"ls | get | to md"
|
||||
=======
|
||||
"ls | columns | to md"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
);
|
||||
let expected = ["name", "type", "size", "modified"].join("");
|
||||
assert_eq!(actual.out, expected, "column names are incorrect for ls");
|
||||
// Long
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
<<<<<<< HEAD
|
||||
"ls -l | get | to md"
|
||||
=======
|
||||
"ls -l | columns | to md"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
);
|
||||
let expected = {
|
||||
#[cfg(unix)]
|
||||
@ -328,17 +316,10 @@ fn list_all_columns() {
|
||||
"name",
|
||||
"type",
|
||||
"target",
|
||||
<<<<<<< HEAD
|
||||
"num_links",
|
||||
"inode",
|
||||
"readonly",
|
||||
"mode",
|
||||
=======
|
||||
"readonly",
|
||||
"mode",
|
||||
"num_links",
|
||||
"inode",
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"uid",
|
||||
"group",
|
||||
"size",
|
||||
|
@ -18,15 +18,8 @@ fn can_average_numbers() {
|
||||
fn can_average_bytes() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
<<<<<<< HEAD
|
||||
"ls | sort-by name | skip 1 | first 2 | get size | math avg | format \"{$it}\" "
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "1.6 KB");
|
||||
=======
|
||||
"ls | sort-by name | skip 1 | first 2 | get size | math avg | to json -r"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "1600");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn evaluates_two_plus_two() {
|
||||
let actual = nu!(
|
||||
@ -17,11 +14,8 @@ fn evaluates_two_plus_two() {
|
||||
assert!(actual.out.contains("4.0"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn evaluates_two_to_the_power_four() {
|
||||
let actual = nu!(
|
||||
@ -34,11 +28,8 @@ fn evaluates_two_to_the_power_four() {
|
||||
assert!(actual.out.contains("16.0"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn evaluates_three_multiplied_by_five() {
|
||||
let actual = nu!(
|
||||
@ -51,11 +42,8 @@ fn evaluates_three_multiplied_by_five() {
|
||||
assert!(actual.out.contains("15.0"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn evaluates_twenty_four_divided_by_two() {
|
||||
let actual = nu!(
|
||||
|
40
crates/nu-command/tests/commands/math/median.rs
Normal file
40
crates/nu-command/tests/commands/math/median.rs
Normal file
@ -0,0 +1,40 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn median_numbers_with_even_rows() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [10 6 19 21 4]
|
||||
| math median
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "10")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn median_numbers_with_odd_rows() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [3 8 9 12 12 15]
|
||||
| math median
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "10.5")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn median_mixed_numbers() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [-11.5 -13.5 10]
|
||||
| math median
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "-11.5")
|
||||
}
|
@ -236,21 +236,6 @@ fn duration_math_with_negative() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
<<<<<<< HEAD
|
||||
fn duration_math_shell_error_on_big_numbers() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
(date now) + 100000000000000day
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.err.contains("Duration overflow"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
fn compound_comparison() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
@ -279,19 +264,11 @@ fn compound_where() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo '[{"a": 1, "b": 1}, {"a": 2, "b": 1}, {"a": 2, "b": 2}]' | from json | where a == 2 && b == 1 | to json
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#"{"a":2,"b":1}"#);
|
||||
=======
|
||||
echo '[{"a": 1, "b": 1}, {"a": 2, "b": 1}, {"a": 2, "b": 2}]' | from json | where a == 2 && b == 1 | to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#"[{"a": 2,"b": 1}]"#);
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -299,17 +276,9 @@ fn compound_where_paren() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo '[{"a": 1, "b": 1}, {"a": 2, "b": 1}, {"a": 2, "b": 2}]' | from json | where ($it.a == 2 && $it.b == 1) || $it.b == 2 | to json
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#"[{"a":2,"b":1},{"a":2,"b":2}]"#);
|
||||
=======
|
||||
echo '[{"a": 1, "b": 1}, {"a": 2, "b": 1}, {"a": 2, "b": 2}]' | from json | where ($it.a == 2 && $it.b == 1) || $it.b == 2 | to json -r
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, r#"[{"a": 2,"b": 1},{"a": 2,"b": 2}]"#);
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
21
crates/nu-command/tests/commands/math/round.rs
Normal file
21
crates/nu-command/tests/commands/math/round.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[test]
|
||||
fn can_round_very_large_numbers() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"echo 18.1372544780074142289927665486772012345 | math round"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "18")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_round_very_large_numbers_with_precision() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"echo 18.13725447800741422899276654867720121457878988 | math round -p 10"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "18.137254478")
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn can_sqrt_numbers() {
|
||||
let actual = nu!(
|
||||
@ -15,11 +12,8 @@ fn can_sqrt_numbers() {
|
||||
assert_eq!(actual.out, "3.914213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn can_sqrt_irrational() {
|
||||
let actual = nu!(
|
||||
|
@ -75,11 +75,8 @@ fn compute_sum_of_table() -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn sum_of_a_row_containing_a_table_is_an_error() {
|
||||
let actual = nu!(
|
||||
|
@ -2,11 +2,8 @@ use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn row() {
|
||||
Playground::setup("merge_test_1", |dirs, sandbox| {
|
||||
|
84
crates/nu-command/tests/commands/mkdir.rs
Normal file
84
crates/nu-command/tests/commands/mkdir.rs
Normal file
@ -0,0 +1,84 @@
|
||||
use nu_test_support::fs::files_exist_at;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
use std::path::Path;
|
||||
|
||||
#[test]
|
||||
fn creates_directory() {
|
||||
Playground::setup("mkdir_test_1", |dirs, _| {
|
||||
nu!(
|
||||
cwd: dirs.test(),
|
||||
"mkdir my_new_directory"
|
||||
);
|
||||
|
||||
let expected = dirs.test().join("my_new_directory");
|
||||
|
||||
assert!(expected.exists());
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn accepts_and_creates_directories() {
|
||||
Playground::setup("mkdir_test_2", |dirs, _| {
|
||||
nu!(
|
||||
cwd: dirs.test(),
|
||||
"mkdir dir_1 dir_2 dir_3"
|
||||
);
|
||||
|
||||
assert!(files_exist_at(
|
||||
vec![Path::new("dir_1"), Path::new("dir_2"), Path::new("dir_3")],
|
||||
dirs.test()
|
||||
));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn creates_intermediary_directories() {
|
||||
Playground::setup("mkdir_test_3", |dirs, _| {
|
||||
nu!(
|
||||
cwd: dirs.test(),
|
||||
"mkdir some_folder/another/deeper_one"
|
||||
);
|
||||
|
||||
let expected = dirs.test().join("some_folder/another/deeper_one");
|
||||
|
||||
assert!(expected.exists());
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_directory_two_parents_up_using_multiple_dots() {
|
||||
Playground::setup("mkdir_test_4", |dirs, sandbox| {
|
||||
sandbox.within("foo").mkdir("bar");
|
||||
|
||||
nu!(
|
||||
cwd: dirs.test().join("foo/bar"),
|
||||
"mkdir .../boo"
|
||||
);
|
||||
|
||||
let expected = dirs.test().join("boo");
|
||||
|
||||
assert!(expected.exists());
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn show_created_paths() {
|
||||
Playground::setup("mkdir_test_2", |dirs, _| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
pipeline(
|
||||
r#"
|
||||
mkdir -s dir_1 dir_2 dir_3
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(files_exist_at(
|
||||
vec![Path::new("dir_1"), Path::new("dir_2"), Path::new("dir_3")],
|
||||
dirs.test()
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "3");
|
||||
})
|
||||
}
|
@ -4,10 +4,6 @@ mod append;
|
||||
mod cal;
|
||||
mod cd;
|
||||
mod compact;
|
||||
<<<<<<< HEAD
|
||||
mod config;
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
mod cp;
|
||||
mod def;
|
||||
mod default;
|
||||
@ -27,10 +23,6 @@ mod hash_;
|
||||
mod headers;
|
||||
mod help;
|
||||
mod histogram;
|
||||
<<<<<<< HEAD
|
||||
mod insert;
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
mod into_filesize;
|
||||
mod into_int;
|
||||
mod keep;
|
||||
@ -42,17 +34,10 @@ mod math;
|
||||
mod merge;
|
||||
mod mkdir;
|
||||
mod move_;
|
||||
<<<<<<< HEAD
|
||||
mod open;
|
||||
mod parse;
|
||||
mod path;
|
||||
mod pathvar;
|
||||
=======
|
||||
mod nth;
|
||||
mod open;
|
||||
mod parse;
|
||||
mod path;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
mod prepend;
|
||||
mod random;
|
||||
mod range;
|
||||
|
@ -34,11 +34,8 @@ fn moves_a_column_before() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn moves_columns_before() {
|
||||
Playground::setup("move_column_test_2", |dirs, sandbox| {
|
||||
@ -73,11 +70,8 @@ fn moves_columns_before() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn moves_a_column_after() {
|
||||
Playground::setup("move_column_test_3", |dirs, sandbox| {
|
||||
@ -113,11 +107,8 @@ fn moves_a_column_after() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn moves_columns_after() {
|
||||
Playground::setup("move_column_test_4", |dirs, sandbox| {
|
||||
|
2
crates/nu-command/tests/commands/move_/mod.rs
Normal file
2
crates/nu-command/tests/commands/move_/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
mod column;
|
||||
mod mv;
|
@ -195,11 +195,8 @@ fn moves_a_directory_with_files() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_source_doesnt_exist() {
|
||||
Playground::setup("mv_test_10", |dirs, sandbox| {
|
||||
@ -212,11 +209,8 @@ fn errors_if_source_doesnt_exist() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_destination_doesnt_exist() {
|
||||
Playground::setup("mv_test_10_1", |dirs, sandbox| {
|
||||
@ -231,11 +225,8 @@ fn errors_if_destination_doesnt_exist() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_multiple_sources_but_destination_not_a_directory() {
|
||||
Playground::setup("mv_test_10_2", |dirs, sandbox| {
|
||||
@ -256,11 +247,8 @@ fn errors_if_multiple_sources_but_destination_not_a_directory() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_renaming_directory_to_an_existing_file() {
|
||||
Playground::setup("mv_test_10_3", |dirs, sandbox| {
|
||||
@ -277,11 +265,8 @@ fn errors_if_renaming_directory_to_an_existing_file() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_moving_to_itself() {
|
||||
Playground::setup("mv_test_10_4", |dirs, sandbox| {
|
||||
|
@ -1,10 +1,7 @@
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn selects_a_row() {
|
||||
Playground::setup("nth_test_1", |dirs, sandbox| {
|
||||
|
@ -185,22 +185,6 @@ fn parses_json() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
<<<<<<< HEAD
|
||||
fn parses_xml() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
"open jonathan.xml | get rss.children.channel.children | get item.children | get link.children.0"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"http://www.jonathanturner.org/2015/10/off-to-new-adventures.html"
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
=======
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
fn parses_ini() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
@ -214,21 +198,14 @@ fn parses_ini() {
|
||||
fn parses_utf16_ini() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
<<<<<<< HEAD
|
||||
"open utf16.ini | rename info | get info | get IconIndex"
|
||||
=======
|
||||
"open ./utf16.ini --raw | decode utf-16 | from ini | rename info | get info | get IconIndex"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "-236")
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_file_not_found() {
|
||||
let actual = nu!(
|
||||
@ -244,11 +221,8 @@ fn errors_if_file_not_found() {
|
||||
);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: I think `open` on a directory is confusing. We should make discuss this one a bit more
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn open_dir_is_ls() {
|
||||
Playground::setup("open_dir", |dirs, sandbox| {
|
||||
|
@ -5,11 +5,8 @@ use nu_test_support::{nu, pipeline};
|
||||
mod simple {
|
||||
use super::*;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn extracts_fields_from_the_given_the_pattern() {
|
||||
Playground::setup("parse_test_1", |dirs, sandbox| {
|
||||
@ -86,11 +83,8 @@ mod simple {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_when_missing_closing_brace() {
|
||||
Playground::setup("parse_test_regex_5", |dirs, _sandbox| {
|
||||
|
83
crates/nu-command/tests/commands/path/basename.rs
Normal file
83
crates/nu-command/tests/commands/path/basename.rs
Normal file
@ -0,0 +1,83 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
use super::join_path_sep;
|
||||
|
||||
#[test]
|
||||
fn returns_basename_of_empty_input() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo ""
|
||||
| path basename
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_basename_of_empty_input() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo ""
|
||||
| path basename -r newname.txt
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "newname.txt");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_basename_of_path_ending_with_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/file.txt/."
|
||||
| path basename
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "file.txt");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_basename_of_path_ending_with_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/file.txt/."
|
||||
| path basename -r viking.txt
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["some", "viking.txt"]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_basename_of_path_ending_with_double_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/file.txt/.."
|
||||
| path basename
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_basename_of_path_ending_with_double_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/file.txt/.."
|
||||
| path basename -r eggs
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["some/file.txt/..", "eggs"]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
137
crates/nu-command/tests/commands/path/dirname.rs
Normal file
137
crates/nu-command/tests/commands/path/dirname.rs
Normal file
@ -0,0 +1,137 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
use super::join_path_sep;
|
||||
|
||||
#[test]
|
||||
fn returns_dirname_of_empty_input() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo ""
|
||||
| path dirname
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_dirname_of_empty_input() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo ""
|
||||
| path dirname -r newdir
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "newdir");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_dirname_of_path_ending_with_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/."
|
||||
| path dirname
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "some");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_dirname_of_path_ending_with_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/."
|
||||
| path dirname -r eggs
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["eggs", "dir"]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_dirname_of_path_ending_with_double_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/.."
|
||||
| path dirname
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "some/dir");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_dirname_of_path_with_double_dot() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/.."
|
||||
| path dirname -r eggs
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["eggs", ".."]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_dirname_of_zero_levels() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/with/spam.txt"
|
||||
| path dirname -n 0
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "some/dir/with/spam.txt");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_dirname_of_zero_levels_with_empty_string() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/with/spam.txt"
|
||||
| path dirname -n 0 -r ""
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_dirname_of_more_levels() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/with/spam.txt"
|
||||
| path dirname -r eggs -n 2
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["eggs", "with/spam.txt"]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaces_dirname_of_way_too_many_levels() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/with/spam.txt"
|
||||
| path dirname -r eggs -n 999
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["eggs", "some/dir/with/spam.txt"]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
@ -2,11 +2,8 @@ use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn checks_if_existing_file_exists() {
|
||||
Playground::setup("path_exists_1", |dirs, sandbox| {
|
||||
|
78
crates/nu-command/tests/commands/path/expand.rs
Normal file
78
crates/nu-command/tests/commands/path/expand.rs
Normal file
@ -0,0 +1,78 @@
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[test]
|
||||
fn expands_path_with_dot() {
|
||||
Playground::setup("path_expand_1", |dirs, sandbox| {
|
||||
sandbox
|
||||
.within("menu")
|
||||
.with_files(vec![EmptyFile("spam.txt")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
echo "menu/./spam.txt"
|
||||
| path expand
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = dirs.test.join("menu").join("spam.txt");
|
||||
assert_eq!(PathBuf::from(actual.out), expected);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn expands_path_with_double_dot() {
|
||||
Playground::setup("path_expand_2", |dirs, sandbox| {
|
||||
sandbox
|
||||
.within("menu")
|
||||
.with_files(vec![EmptyFile("spam.txt")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
echo "menu/../menu/spam.txt"
|
||||
| path expand
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = dirs.test.join("menu").join("spam.txt");
|
||||
assert_eq!(PathBuf::from(actual.out), expected);
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
mod windows {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn expands_path_with_tilde_backward_slash() {
|
||||
Playground::setup("path_expand_2", |dirs, _| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
echo "~\tmp.txt" | path expand
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(!PathBuf::from(actual.out).starts_with("~"));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn win_expands_path_with_tilde_forward_slash() {
|
||||
Playground::setup("path_expand_2", |dirs, _| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
echo "~/tmp.txt" | path expand
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(!PathBuf::from(actual.out).starts_with("~"));
|
||||
})
|
||||
}
|
||||
}
|
59
crates/nu-command/tests/commands/path/join.rs
Normal file
59
crates/nu-command/tests/commands/path/join.rs
Normal file
@ -0,0 +1,59 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
use super::join_path_sep;
|
||||
|
||||
#[test]
|
||||
fn returns_path_joined_with_column_path() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo [ [name]; [eggs] ]
|
||||
| path join spam.txt -c [ name ]
|
||||
| get name
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["eggs", "spam.txt"]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_path_joined_from_list() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo [ home viking spam.txt ]
|
||||
| path join
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["home", "viking", "spam.txt"]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn appends_slash_when_joined_with_empty_path() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "/some/dir"
|
||||
| path join ''
|
||||
"#
|
||||
));
|
||||
|
||||
let expected = join_path_sep(&["/some/dir", ""]);
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_joined_path_when_joining_empty_path() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo ""
|
||||
| path join foo.txt
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "foo.txt");
|
||||
}
|
34
crates/nu-command/tests/commands/path/mod.rs
Normal file
34
crates/nu-command/tests/commands/path/mod.rs
Normal file
@ -0,0 +1,34 @@
|
||||
mod basename;
|
||||
mod dirname;
|
||||
mod exists;
|
||||
mod expand;
|
||||
mod join;
|
||||
mod parse;
|
||||
mod split;
|
||||
mod type_;
|
||||
|
||||
use std::path::MAIN_SEPARATOR;
|
||||
|
||||
/// Helper function that joins string literals with '/' or '\', based on host OS
|
||||
fn join_path_sep(pieces: &[&str]) -> String {
|
||||
let sep_string = String::from(MAIN_SEPARATOR);
|
||||
pieces.join(&sep_string)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
#[test]
|
||||
fn joins_path_on_windows() {
|
||||
let pieces = ["sausage", "bacon", "spam"];
|
||||
let actual = join_path_sep(&pieces);
|
||||
|
||||
assert_eq!(&actual, "sausage\\bacon\\spam");
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
#[test]
|
||||
fn joins_path_on_other_than_windows() {
|
||||
let pieces = ["sausage", "bacon", "spam"];
|
||||
let actual = join_path_sep(&pieces);
|
||||
|
||||
assert_eq!(&actual, "sausage/bacon/spam");
|
||||
}
|
@ -114,11 +114,8 @@ fn parses_column_path_extension() {
|
||||
assert_eq!(actual.out, "png");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn parses_into_correct_number_of_columns() {
|
||||
let actual = nu!(
|
||||
|
@ -17,11 +17,7 @@ fn splits_correctly_single_path() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo ['home/viking/spam.txt']
|
||||
=======
|
||||
'home/viking/spam.txt'
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| path split
|
||||
| last
|
||||
"#
|
||||
@ -43,10 +39,7 @@ fn splits_correctly_with_column_path() {
|
||||
]
|
||||
| path split -c [ home barn ]
|
||||
| get barn
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
| flatten
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
@ -15,11 +15,8 @@ fn returns_type_of_missing_file() {
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn returns_type_of_existing_file() {
|
||||
Playground::setup("path_expand_1", |dirs, sandbox| {
|
||||
@ -35,19 +32,12 @@ fn returns_type_of_existing_file() {
|
||||
"#
|
||||
));
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert_eq!(actual.out, "Dir");
|
||||
})
|
||||
}
|
||||
|
||||
=======
|
||||
assert_eq!(actual.out, "dir");
|
||||
})
|
||||
}
|
||||
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn returns_type_of_existing_directory() {
|
||||
Playground::setup("path_expand_1", |dirs, sandbox| {
|
||||
@ -63,10 +53,6 @@ fn returns_type_of_existing_directory() {
|
||||
"#
|
||||
));
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert_eq!(actual.out, "File");
|
||||
=======
|
||||
assert_eq!(actual.out, "file");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
})
|
||||
}
|
||||
|
29
crates/nu-command/tests/commands/prepend.rs
Normal file
29
crates/nu-command/tests/commands/prepend.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn adds_a_row_to_the_beginning() {
|
||||
Playground::setup("prepend_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"los_tres_caballeros.txt",
|
||||
r#"
|
||||
Andrés N. Robalino
|
||||
Jonathan Turner
|
||||
Yehuda Katz
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open los_tres_caballeros.txt
|
||||
| lines
|
||||
| prepend "pollo loco"
|
||||
| nth 0
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "pollo loco");
|
||||
})
|
||||
}
|
16
crates/nu-command/tests/commands/random/bool.rs
Normal file
16
crates/nu-command/tests/commands/random/bool.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn generates_a_bool() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
random bool
|
||||
"#
|
||||
));
|
||||
|
||||
let output = actual.out;
|
||||
let is_boolean_output = output == "true" || output == "false";
|
||||
|
||||
assert!(is_boolean_output);
|
||||
}
|
14
crates/nu-command/tests/commands/random/chars.rs
Normal file
14
crates/nu-command/tests/commands/random/chars.rs
Normal file
@ -0,0 +1,14 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn generates_chars_of_specified_length() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
random chars -l 15 | size | get chars
|
||||
"#
|
||||
));
|
||||
|
||||
let result = actual.out;
|
||||
assert_eq!(result, "15");
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn generates_an_decimal() {
|
||||
let actual = nu!(
|
||||
@ -17,11 +14,8 @@ fn generates_an_decimal() {
|
||||
assert!(actual.out.contains("42") || actual.out.contains("43"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn generates_55() {
|
||||
let actual = nu!(
|
||||
@ -34,11 +28,8 @@ fn generates_55() {
|
||||
assert!(actual.out.contains("55"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn generates_0() {
|
||||
let actual = nu!(
|
||||
|
13
crates/nu-command/tests/commands/random/dice.rs
Normal file
13
crates/nu-command/tests/commands/random/dice.rs
Normal file
@ -0,0 +1,13 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn rolls_4_roll() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
random dice -d 4 -s 10 | length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4");
|
||||
}
|
@ -24,11 +24,8 @@ fn generates_55() {
|
||||
assert!(actual.out.contains("55"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn generates_0() {
|
||||
let actual = nu!(
|
||||
|
7
crates/nu-command/tests/commands/random/mod.rs
Normal file
7
crates/nu-command/tests/commands/random/mod.rs
Normal file
@ -0,0 +1,7 @@
|
||||
mod bool;
|
||||
mod chars;
|
||||
mod decimal;
|
||||
mod dice;
|
||||
mod integer;
|
||||
#[cfg(feature = "uuid_crate")]
|
||||
mod uuid;
|
16
crates/nu-command/tests/commands/random/uuid.rs
Normal file
16
crates/nu-command/tests/commands/random/uuid.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
use uuid_crate::Uuid;
|
||||
|
||||
#[test]
|
||||
fn generates_valid_uuid4() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
random uuid
|
||||
"#
|
||||
));
|
||||
|
||||
let result = Uuid::parse_str(actual.out.as_str());
|
||||
|
||||
assert!(result.is_ok());
|
||||
}
|
68
crates/nu-command/tests/commands/range.rs
Normal file
68
crates/nu-command/tests/commands/range.rs
Normal file
@ -0,0 +1,68 @@
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn selects_a_row() {
|
||||
Playground::setup("range_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("notes.txt"), EmptyFile("tests.txt")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| sort-by name
|
||||
| range 0..0
|
||||
| get name
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "notes.txt");
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn selects_some_rows() {
|
||||
Playground::setup("range_test_2", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("notes.txt"),
|
||||
EmptyFile("tests.txt"),
|
||||
EmptyFile("persons.txt"),
|
||||
]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| get name
|
||||
| range 1..2
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "2");
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn negative_indices() {
|
||||
Playground::setup("range_test_negative_indices", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("notes.txt"),
|
||||
EmptyFile("tests.txt"),
|
||||
EmptyFile("persons.txt"),
|
||||
]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| get name
|
||||
| range (-1..)
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
});
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn reduce_table_column() {
|
||||
let actual = nu!(
|
||||
@ -13,11 +10,7 @@ fn reduce_table_column() {
|
||||
echo "[{month:2,total:30}, {month:3,total:10}, {month:4,total:3}, {month:5,total:60}]"
|
||||
| from json
|
||||
| get total
|
||||
<<<<<<< HEAD
|
||||
| reduce -f 20 { $it + (math eval $"($acc)^1.05")}
|
||||
=======
|
||||
| reduce -f 20 { $it.item + (math eval $"($item.acc)^1.05")}
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| into string -d 1
|
||||
"#
|
||||
)
|
||||
@ -26,24 +19,15 @@ fn reduce_table_column() {
|
||||
assert_eq!(actual.out, "180.6");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn reduce_table_column_with_path() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo "[{month:2,total:30}, {month:3,total:10}, {month:4,total:3}, {month:5,total:60}]"
|
||||
| from json
|
||||
| reduce -f 20 { $it.total + (math eval $"($acc)^1.05")}
|
||||
=======
|
||||
[{month:2,total:30}, {month:3,total:10}, {month:4,total:3}, {month:5,total:60}]
|
||||
| reduce -f 20 { $it.item.total + (math eval $"($item.acc)^1.05")}
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| into string -d 1
|
||||
"#
|
||||
)
|
||||
@ -52,25 +36,15 @@ fn reduce_table_column_with_path() {
|
||||
assert_eq!(actual.out, "180.6");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn reduce_rows_example() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo a,b 1,2 3,4
|
||||
| split column ,
|
||||
| headers
|
||||
| reduce -f 1.6 { $acc * ($it.a | str to-int) + ($it.b | str to-int) }
|
||||
=======
|
||||
[[a,b]; [1,2] [3,4]]
|
||||
| reduce -f 1.6 { $it.acc * ($it.item.a | into int) + ($it.item.b | into int) }
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
)
|
||||
);
|
||||
@ -78,22 +52,15 @@ fn reduce_rows_example() {
|
||||
assert_eq!(actual.out, "14.8");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn reduce_numbered_example() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo one longest three bar
|
||||
<<<<<<< HEAD
|
||||
| reduce -n { if ($it.item | str length) > ($acc.item | str length) {echo $it} {echo $acc}}
|
||||
=======
|
||||
| reduce -n { if ($it.item.item | str length) > ($it.acc.item | str length) {echo $it.item} else {echo $it.acc}}
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get index
|
||||
"#
|
||||
)
|
||||
@ -102,22 +69,15 @@ fn reduce_numbered_example() {
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn reduce_numbered_integer_addition_example() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [1 2 3 4]
|
||||
<<<<<<< HEAD
|
||||
| reduce -n { $acc.item + $it.item }
|
||||
=======
|
||||
| reduce -n { $it.acc.item + $it.item.item }
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get item
|
||||
"#
|
||||
)
|
||||
@ -126,11 +86,8 @@ fn reduce_numbered_integer_addition_example() {
|
||||
assert_eq!(actual.out, "10");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn folding_with_tables() {
|
||||
let actual = nu!(
|
||||
@ -138,13 +95,8 @@ fn folding_with_tables() {
|
||||
r#"
|
||||
echo [10 20 30 40]
|
||||
| reduce -f [] {
|
||||
<<<<<<< HEAD
|
||||
with-env [value $it] {
|
||||
echo $acc | append (10 * ($nu.env.value | str to-int))
|
||||
=======
|
||||
with-env [value $it.item] {
|
||||
echo $acc | append (10 * ($env.value | into int))
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
}
|
||||
| math sum
|
||||
@ -155,46 +107,29 @@ fn folding_with_tables() {
|
||||
assert_eq!(actual.out, "1000");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn error_reduce_fold_type_mismatch() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo a b c | reduce -f 0 { $acc + $it }
|
||||
=======
|
||||
echo a b c | reduce -f 0 { $it.acc + $it.item }
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert!(actual.err.contains("Coercion"));
|
||||
}
|
||||
|
||||
=======
|
||||
assert!(actual.err.contains("mismatch"));
|
||||
}
|
||||
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn error_reduce_empty() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
reduce { $acc + $it }
|
||||
=======
|
||||
reduce { $it.$acc + $it.item }
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
@ -61,11 +61,8 @@ fn keeps_remaining_original_names_given_less_new_names_than_total_original_names
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_no_columns_present() {
|
||||
Playground::setup("rename_test_3", |dirs, sandbox| {
|
||||
|
11
crates/nu-command/tests/commands/reverse.rs
Normal file
11
crates/nu-command/tests/commands/reverse.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[test]
|
||||
fn can_get_reverse_first() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
"ls | sort-by name | reverse | first 1 | get name | str trim "
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "utf16.ini");
|
||||
}
|
@ -121,11 +121,8 @@ fn removes_directory_contents_with_recursive_flag() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_attempting_to_delete_a_directory_with_content_without_recursive_flag() {
|
||||
Playground::setup("rm_test_6", |dirs, sandbox| {
|
||||
@ -140,11 +137,8 @@ fn errors_if_attempting_to_delete_a_directory_with_content_without_recursive_fla
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_attempting_to_delete_single_dot_as_argument() {
|
||||
Playground::setup("rm_test_7", |dirs, _| {
|
||||
@ -157,11 +151,8 @@ fn errors_if_attempting_to_delete_single_dot_as_argument() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn errors_if_attempting_to_delete_two_dot_as_argument() {
|
||||
Playground::setup("rm_test_8", |dirs, _| {
|
||||
@ -292,11 +283,8 @@ fn no_errors_if_attempting_to_delete_non_existent_file_with_f_flag() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn rm_wildcard_keeps_dotfiles() {
|
||||
Playground::setup("rm_test_15", |dirs, sandbox| {
|
||||
|
@ -17,11 +17,8 @@ mod rows {
|
||||
)
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn roll_down_by_default() {
|
||||
let actual = nu!(
|
||||
@ -35,11 +32,8 @@ mod rows {
|
||||
assert_eq!(actual.out, "HERE");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn can_roll_up() {
|
||||
let actual = nu!(
|
||||
@ -72,11 +66,8 @@ mod columns {
|
||||
)
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn roll_left_by_default() {
|
||||
let actual = nu!(
|
||||
@ -90,11 +81,8 @@ mod columns {
|
||||
assert_eq!(actual.out, "origin-stars-commit_author");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn can_roll_in_the_opposite_direction() {
|
||||
let actual = nu!(
|
||||
@ -110,11 +98,8 @@ mod columns {
|
||||
|
||||
struct ThirtieTwo<'a>(usize, &'a str);
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn can_roll_the_cells_only_keeping_the_header_names() {
|
||||
let four_bitstring = bitstring_to_nu_row_pipeline("00000100");
|
||||
@ -128,11 +113,8 @@ mod columns {
|
||||
assert_eq!(actual.out, expected_value.1);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn four_in_bitstring_left_shifted_with_three_bits_should_be_32_in_decimal() {
|
||||
let four_bitstring = "00000100";
|
||||
@ -185,11 +167,7 @@ mod columns {
|
||||
pipeline(
|
||||
r#"
|
||||
split chars
|
||||
<<<<<<< HEAD
|
||||
| each { str to-int }
|
||||
=======
|
||||
| each { into int }
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| rotate counter-clockwise _
|
||||
| reject _
|
||||
| rename bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit8
|
||||
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn counter_clockwise() {
|
||||
let table = pipeline(
|
||||
|
@ -48,11 +48,8 @@ fn writes_out_csv() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn save_append_will_create_file_if_not_exists() {
|
||||
Playground::setup("save_test_3", |dirs, sandbox| {
|
||||
|
@ -22,11 +22,8 @@ fn regular_columns() {
|
||||
assert_eq!(actual.out, "Robalino");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn complex_nested_columns() {
|
||||
Playground::setup("select_test_2", |dirs, sandbox| {
|
||||
@ -69,11 +66,8 @@ fn complex_nested_columns() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn allows_if_given_unknown_column_name_is_missing() {
|
||||
let actual = nu!(cwd: ".", pipeline(
|
||||
@ -112,11 +106,8 @@ fn column_names_with_spaces() {
|
||||
assert_eq!(actual.out, "Robalino Jnth");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn ignores_duplicate_columns_selected() {
|
||||
let actual = nu!(cwd: ".", pipeline(
|
||||
|
29
crates/nu-command/tests/commands/semicolon.rs
Normal file
29
crates/nu-command/tests/commands/semicolon.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn semicolon_allows_lhs_to_complete() {
|
||||
Playground::setup("create_test_1", |dirs, _sandbox| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"touch i_will_be_created_semi.txt; echo done"
|
||||
);
|
||||
|
||||
let path = dirs.test().join("i_will_be_created_semi.txt");
|
||||
|
||||
assert!(path.exists());
|
||||
assert_eq!(actual.out, "done");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn semicolon_lhs_error_stops_processing() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
where 1 1; echo done
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(!actual.out.contains("done"));
|
||||
}
|
2
crates/nu-command/tests/commands/skip/mod.rs
Normal file
2
crates/nu-command/tests/commands/skip/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
mod until;
|
||||
mod while_;
|
@ -10,11 +10,7 @@ fn condition_is_met() {
|
||||
r#"
|
||||
CHICKEN SUMMARY report date: April 29th, 2020
|
||||
--------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020,
|
||||
=======
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
Yellow Chickens,,,
|
||||
Andrés,0,0,1
|
||||
Jonathan,0,0,1
|
||||
@ -36,16 +32,6 @@ fn condition_is_met() {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
open --raw caballeros.txt
|
||||
| lines
|
||||
| skip 2
|
||||
| split column ','
|
||||
| headers
|
||||
| skip until "Chicken Collection" == "Red Chickens"
|
||||
| skip 1
|
||||
| str to-int "31/04/2020"
|
||||
=======
|
||||
open --raw ./caballeros.txt
|
||||
| lines
|
||||
| skip 2
|
||||
@ -55,7 +41,6 @@ fn condition_is_met() {
|
||||
| skip until "Chicken Collection" == "Red Chickens"
|
||||
| skip 1
|
||||
| into int "31/04/2020"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get "31/04/2020"
|
||||
| math sum
|
||||
"#
|
||||
|
@ -10,11 +10,7 @@ fn condition_is_met() {
|
||||
r#"
|
||||
CHICKEN SUMMARY report date: April 29th, 2020
|
||||
--------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020,
|
||||
=======
|
||||
Chicken Collection,29/04/2020,30/04/2020,31/04/2020
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
Yellow Chickens,,,
|
||||
Andrés,0,0,1
|
||||
Jonathan,0,0,1
|
||||
@ -37,15 +33,6 @@ fn condition_is_met() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open --raw caballeros.txt
|
||||
<<<<<<< HEAD
|
||||
| lines
|
||||
| skip 2
|
||||
| split column ','
|
||||
| headers
|
||||
| skip while "Chicken Collection" != "Red Chickens"
|
||||
| skip 1
|
||||
| str to-int "31/04/2020"
|
||||
=======
|
||||
| lines
|
||||
| skip 2
|
||||
| str trim
|
||||
@ -54,7 +41,6 @@ fn condition_is_met() {
|
||||
| skip while "Chicken Collection" != "Red Chickens"
|
||||
| skip 1
|
||||
| into int "31/04/2020"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| get "31/04/2020"
|
||||
| math sum
|
||||
"#
|
||||
|
@ -1,10 +1,7 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn by_column() {
|
||||
let actual = nu!(
|
||||
@ -26,11 +23,8 @@ fn by_column() {
|
||||
assert_eq!(actual.out, "description");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn by_invalid_column() {
|
||||
let actual = nu!(
|
||||
@ -53,11 +47,8 @@ fn by_invalid_column() {
|
||||
assert!(actual.err.contains("invalid column"));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn by_invalid_types() {
|
||||
let actual = nu!(
|
||||
@ -100,20 +91,12 @@ fn ls_sort_by_name_sensitive() {
|
||||
open sample-ls-output.json
|
||||
| sort-by name
|
||||
| select name
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
"#
|
||||
));
|
||||
|
||||
let json_output = r#"[{"name":"B.txt"},{"name":"C"},{"name":"a.txt"}]"#;
|
||||
=======
|
||||
| to json --raw
|
||||
"#
|
||||
));
|
||||
|
||||
//let json_output = r#"[{"name":"B.txt"},{"name":"C"},{"name":"a.txt"}]"#;
|
||||
let json_output = r#"[{"name": "B.txt"},{"name": "C"},{"name": "a.txt"}]"#;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
||||
assert_eq!(actual.out, json_output);
|
||||
}
|
||||
@ -126,20 +109,11 @@ fn ls_sort_by_name_insensitive() {
|
||||
open sample-ls-output.json
|
||||
| sort-by -i name
|
||||
| select name
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
"#
|
||||
));
|
||||
|
||||
let json_output = r#"[{"name":"a.txt"},{"name":"B.txt"},{"name":"C"}]"#;
|
||||
|
||||
=======
|
||||
| to json --raw
|
||||
"#
|
||||
));
|
||||
|
||||
let json_output = r#"[{"name": "B.txt"},{"name": "C"},{"name": "a.txt"}]"#;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
assert_eq!(actual.out, json_output);
|
||||
}
|
||||
|
||||
@ -151,20 +125,11 @@ fn ls_sort_by_type_name_sensitive() {
|
||||
open sample-ls-output.json
|
||||
| sort-by type name
|
||||
| select name type
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
"#
|
||||
));
|
||||
|
||||
let json_output = r#"[{"name":"C","type":"Dir"},{"name":"B.txt","type":"File"},{"name":"a.txt","type":"File"}]"#;
|
||||
|
||||
=======
|
||||
| to json --raw
|
||||
"#
|
||||
));
|
||||
|
||||
let json_output = r#"[{"name": "C","type": "Dir"},{"name": "a.txt","type": "File"},{"name": "B.txt","type": "File"}]"#;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
assert_eq!(actual.out, json_output);
|
||||
}
|
||||
|
||||
@ -176,19 +141,10 @@ fn ls_sort_by_type_name_insensitive() {
|
||||
open sample-ls-output.json
|
||||
| sort-by -i type name
|
||||
| select name type
|
||||
<<<<<<< HEAD
|
||||
| to json
|
||||
"#
|
||||
));
|
||||
|
||||
let json_output = r#"[{"name":"C","type":"Dir"},{"name":"a.txt","type":"File"},{"name":"B.txt","type":"File"}]"#;
|
||||
|
||||
=======
|
||||
| to json --raw
|
||||
"#
|
||||
));
|
||||
|
||||
let json_output = r#"[{"name": "C","type": "Dir"},{"name": "a.txt","type": "File"},{"name": "B.txt","type": "File"}]"#;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
assert_eq!(actual.out, json_output);
|
||||
}
|
||||
|
@ -1,15 +1,7 @@
|
||||
use nu_test_support::fs::{AbsolutePath, DisplayPath, Stub::FileWithContent};
|
||||
use nu_test_support::nu;
|
||||
<<<<<<< HEAD
|
||||
use nu_test_support::pipeline as input;
|
||||
use nu_test_support::playground::{says, Playground};
|
||||
|
||||
use hamcrest2::assert_that;
|
||||
use hamcrest2::prelude::*;
|
||||
=======
|
||||
use nu_test_support::pipeline;
|
||||
use nu_test_support::playground::Playground;
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
|
||||
#[should_panic]
|
||||
#[test]
|
||||
@ -45,18 +37,6 @@ fn sources_also_files_under_custom_lib_dirs_path() {
|
||||
"#,
|
||||
)]);
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert_that!(
|
||||
nu.pipeline(&input(
|
||||
r#"
|
||||
source my_library.nu ;
|
||||
|
||||
hello
|
||||
"#,
|
||||
)),
|
||||
says().stdout("hello nu")
|
||||
);
|
||||
=======
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
@ -67,7 +47,6 @@ fn sources_also_files_under_custom_lib_dirs_path() {
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "hello nu");
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
})
|
||||
}
|
||||
|
||||
@ -122,11 +101,8 @@ fn try_source_foo_without_quotes_in(testdir: &str, playdir: &str) {
|
||||
});
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn sources_unicode_file_in_normal_dir() {
|
||||
try_source_foo_with_single_quotes_in("foo", "source_test_1");
|
||||
@ -134,11 +110,8 @@ fn sources_unicode_file_in_normal_dir() {
|
||||
try_source_foo_without_quotes_in("foo", "source_test_3");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn sources_unicode_file_in_unicode_dir_without_spaces_1() {
|
||||
try_source_foo_with_single_quotes_in("🚒", "source_test_4");
|
||||
@ -146,11 +119,8 @@ fn sources_unicode_file_in_unicode_dir_without_spaces_1() {
|
||||
try_source_foo_without_quotes_in("🚒", "source_test_6");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[cfg(not(windows))] // ':' is not allowed in Windows paths
|
||||
#[test]
|
||||
fn sources_unicode_file_in_unicode_dir_without_spaces_2() {
|
||||
@ -159,22 +129,16 @@ fn sources_unicode_file_in_unicode_dir_without_spaces_2() {
|
||||
try_source_foo_without_quotes_in(":fire_engine:", "source_test_9");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn sources_unicode_file_in_unicode_dir_with_spaces_1() {
|
||||
try_source_foo_with_single_quotes_in("e-$ èрт🚒♞中片-j", "source_test_8");
|
||||
try_source_foo_with_double_quotes_in("e-$ èрт🚒♞中片-j", "source_test_9");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[cfg(not(windows))] // ':' is not allowed in Windows paths
|
||||
#[test]
|
||||
fn sources_unicode_file_in_unicode_dir_with_spaces_2() {
|
||||
|
@ -49,10 +49,6 @@ fn errors_if_no_table_given_as_input() {
|
||||
"#
|
||||
));
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert!(actual.err.contains("Expected table from pipeline"));
|
||||
=======
|
||||
assert!(actual.err.contains("requires a table"));
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
})
|
||||
}
|
||||
|
28
crates/nu-command/tests/commands/split_column.rs
Normal file
28
crates/nu-command/tests/commands/split_column.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn to_column() {
|
||||
Playground::setup("split_column_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"sample.txt",
|
||||
r#"
|
||||
importer,shipper,tariff_item,name,origin
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open sample.txt
|
||||
| lines
|
||||
| str trim
|
||||
| split column ","
|
||||
| get Column2
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("shipper"));
|
||||
})
|
||||
}
|
28
crates/nu-command/tests/commands/split_row.rs
Normal file
28
crates/nu-command/tests/commands/split_row.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn to_row() {
|
||||
Playground::setup("split_row_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"sample.txt",
|
||||
r#"
|
||||
importer,shipper,tariff_item,name,origin
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open sample.txt
|
||||
| lines
|
||||
| str trim
|
||||
| split row ","
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains('5'));
|
||||
})
|
||||
}
|
@ -44,18 +44,10 @@ fn sum_one_to_four() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 1..4 | into string | str collect "+" | math eval
|
||||
=======
|
||||
1..4 | each { $it } | into string | str collect "+" | math eval
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert!(actual.out.contains("10.0"));
|
||||
=======
|
||||
assert!(actual.out.contains("10"));
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
158
crates/nu-command/tests/commands/str_/into_string.rs
Normal file
158
crates/nu-command/tests/commands/str_/into_string.rs
Normal file
@ -0,0 +1,158 @@
|
||||
use nu_test_support::playground::{Dirs, Playground};
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn from_range() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 1..5 | into string | to json
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "[\"1\",\"2\",\"3\",\"4\",\"5\"]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_number() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 5 | into string
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "5");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_decimal() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 1.5 | into string
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "1.5");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_boolean() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo $true | into string
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_string() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo "one" | into string
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "one");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_filename() {
|
||||
Playground::setup("from_filename", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[dependency]
|
||||
name = "nu"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"ls sample.toml | get name | into string"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "sample.toml");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_filesize() {
|
||||
Playground::setup("from_filesize", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[dependency]
|
||||
name = "nu"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"ls sample.toml | get size | into string"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "25 B");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_decimal_correct_trailing_zeros() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
= 1.23000 | into string -d 3
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("1.230"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_int_decimal_correct_trailing_zeros() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
= 1.00000 | into string -d 3
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("1.000"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_int_decimal_trim_trailing_zeros() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
= 1.00000 | into string | format "{$it} flat"
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("1 flat")); // "1" would match "1.0"
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_table() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo '[{"name": "foo", "weight": 32.377}, {"name": "bar", "weight": 15.2}]'
|
||||
| from json
|
||||
| into string weight -d 2
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("32.38"));
|
||||
assert!(actual.out.contains("15.20"));
|
||||
}
|
@ -29,11 +29,7 @@ fn error_trim_multiple_chars() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 'does it work now?!' | str trim -c '?!'
|
||||
=======
|
||||
echo "does it work now?!" | str trim -c "?!"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
)
|
||||
);
|
||||
@ -128,11 +124,7 @@ fn converts_to_int() {
|
||||
r#"
|
||||
echo '{number_as_string: "1"}'
|
||||
| from json
|
||||
<<<<<<< HEAD
|
||||
| str to-int number_as_string
|
||||
=======
|
||||
| into int number_as_string
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| rename number
|
||||
| where number == 1
|
||||
| get number
|
||||
@ -150,11 +142,7 @@ fn converts_to_decimal() {
|
||||
r#"
|
||||
echo "3.1, 0.0415"
|
||||
| split row ","
|
||||
<<<<<<< HEAD
|
||||
| str to-decimal
|
||||
=======
|
||||
| into decimal
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| math sum
|
||||
"#
|
||||
));
|
||||
|
31
crates/nu-command/tests/commands/touch.rs
Normal file
31
crates/nu-command/tests/commands/touch.rs
Normal file
@ -0,0 +1,31 @@
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
|
||||
#[test]
|
||||
fn creates_a_file_when_it_doesnt_exist() {
|
||||
Playground::setup("create_test_1", |dirs, _sandbox| {
|
||||
nu!(
|
||||
cwd: dirs.test(),
|
||||
"touch i_will_be_created.txt"
|
||||
);
|
||||
|
||||
let path = dirs.test().join("i_will_be_created.txt");
|
||||
assert!(path.exists());
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn creates_two_files() {
|
||||
Playground::setup("create_test_2", |dirs, _sandbox| {
|
||||
nu!(
|
||||
cwd: dirs.test(),
|
||||
"touch a b"
|
||||
);
|
||||
|
||||
let path = dirs.test().join("a");
|
||||
assert!(path.exists());
|
||||
|
||||
let path2 = dirs.test().join("b");
|
||||
assert!(path2.exists());
|
||||
})
|
||||
}
|
@ -61,11 +61,8 @@ fn uniq_values() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn nested_json_structures() {
|
||||
Playground::setup("uniq_test_3", |dirs, sandbox| {
|
||||
@ -130,22 +127,14 @@ fn nested_json_structures() {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn uniq_when_keys_out_of_order() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo '[{"a": "a", "b": [1,2,3]},{"b": [1,2,3], "a": "a"}]'
|
||||
| from json
|
||||
=======
|
||||
[{"a": "a", "b": [1,2,3]}, {"b": [1,2,3], "a": "a"}]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| uniq
|
||||
| length
|
||||
|
||||
@ -155,22 +144,14 @@ fn uniq_when_keys_out_of_order() {
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
#[test]
|
||||
fn uniq_counting() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo '["A", "B", "A"]'
|
||||
| from json
|
||||
=======
|
||||
["A", "B", "A"]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| wrap item
|
||||
| uniq --count
|
||||
| where item == A
|
||||
@ -182,12 +163,7 @@ fn uniq_counting() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo '["A", "B", "A"]'
|
||||
| from json
|
||||
=======
|
||||
echo ["A", "B", "A"]
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| wrap item
|
||||
| uniq --count
|
||||
| where item == B
|
||||
|
60
crates/nu-command/tests/commands/update.rs
Normal file
60
crates/nu-command/tests/commands/update.rs
Normal file
@ -0,0 +1,60 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn sets_the_column() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open cargo_sample.toml
|
||||
| update dev-dependencies.pretty_assertions "0.7.0"
|
||||
| get dev-dependencies.pretty_assertions
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "0.7.0");
|
||||
}
|
||||
|
||||
#[cfg(features = "inc")]
|
||||
#[test]
|
||||
fn sets_the_column_from_a_block_run_output() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open cargo_sample.toml
|
||||
| update dev-dependencies.pretty_assertions { open cargo_sample.toml | get dev-dependencies.pretty_assertions | inc --minor }
|
||||
| get dev-dependencies.pretty_assertions
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "0.7.0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sets_the_column_from_a_block_full_stream_output() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
wrap content
|
||||
| update content { open --raw cargo_sample.toml | lines | first 5 }
|
||||
| get content.1
|
||||
| str contains "nu"
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sets_the_column_from_a_subexpression() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
wrap content
|
||||
| update content (open --raw cargo_sample.toml | lines | first 5)
|
||||
| get content.1
|
||||
| str contains "nu"
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
}
|
166
crates/nu-command/tests/commands/where_.rs
Normal file
166
crates/nu-command/tests/commands/where_.rs
Normal file
@ -0,0 +1,166 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
use nu_test_support::pipeline;
|
||||
|
||||
#[test]
|
||||
fn filters_by_unit_size_comparison() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
"ls | where size > 1kib | sort-by size | get name | first 1 | str trim"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "cargo_sample.toml");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn filters_with_nothing_comparison() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
r#"echo '[{"foo": 3}, {"foo": null}, {"foo": 4}]' | from json | get foo | compact | where $it > 1 | math sum"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "7");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn where_in_table() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
r#"echo '[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name in ["foo"] | get size | math sum"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "5");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn where_not_in_table() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
r#"echo '[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name not-in ["foo"] | get size | math sum"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "4");
|
||||
}
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
#[test]
|
||||
fn explicit_block_condition() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| first 4
|
||||
| where {= $it.z > 4200}
|
||||
| get z
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4253");
|
||||
}
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
#[test]
|
||||
fn binary_operator_comparisons() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| first 4
|
||||
| where z > 4200
|
||||
| get z
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4253");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| first 4
|
||||
| where z >= 4253
|
||||
| get z
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4253");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| first 4
|
||||
| where z < 10
|
||||
| get z
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| first 4
|
||||
| where z <= 1
|
||||
| get z
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| where z != 1
|
||||
| first 1
|
||||
| get z
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "42");
|
||||
}
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
#[test]
|
||||
fn contains_operator() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == strings
|
||||
| get table_values
|
||||
| where x =~ ell
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == strings
|
||||
| get table_values
|
||||
| where x !~ ell
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "2");
|
||||
}
|
96
crates/nu-command/tests/commands/which.rs
Normal file
96
crates/nu-command/tests/commands/which.rs
Normal file
@ -0,0 +1,96 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[test]
|
||||
fn which_ls() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"which ls | get path | str trim"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "Nushell built-in command");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn which_alias_ls() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"alias ls = ls -a; which ls | get path | str trim"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "Nushell alias: ls -a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn which_def_ls() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"def ls [] {echo def}; which ls | get path | str trim"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "Nushell custom command");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn correct_precedence_alias_def_custom() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"def ls [] {echo def}; alias ls = echo alias; which ls | get path | str trim"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "Nushell alias: echo alias");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiple_reports_for_alias_def_custom() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"def ls [] {echo def}; alias ls = echo alias; which -a ls | length"
|
||||
);
|
||||
|
||||
let length: i32 = actual.out.parse().unwrap();
|
||||
assert!(length >= 3);
|
||||
}
|
||||
|
||||
// `get_aliases_with_name` and `get_custom_commands_with_name` don't return the correct count of
|
||||
// values
|
||||
// I suspect this is due to the ScopeFrame getting discarded at '}' and the command is then
|
||||
// executed in the parent scope
|
||||
// See: parse_definition, line 2187 for reference.
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn multiple_reports_of_multiple_alias() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"alias xaz = echo alias1; def helper [] {alias xaz = echo alias2; which -a xaz}; helper | length"
|
||||
);
|
||||
|
||||
let length: i32 = actual.out.parse().unwrap();
|
||||
assert_eq!(length, 2);
|
||||
}
|
||||
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn multiple_reports_of_multiple_defs() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"def xaz [] {echo def1}; def helper [] { def xaz [] { echo def2 }; which -a xaz }; helper | length"
|
||||
);
|
||||
|
||||
let length: i32 = actual.out.parse().unwrap();
|
||||
assert_eq!(length, 2);
|
||||
}
|
||||
|
||||
//Fails due to ParserScope::add_definition
|
||||
// frame.custom_commands.insert(name.clone(), block.clone());
|
||||
// frame.commands.insert(name, whole_stream_command(block));
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn def_only_seen_once() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"def xaz [] {echo def1}; which -a xaz | length"
|
||||
);
|
||||
//length is 2. One custom_command (def) one built in ("wrongly" added)
|
||||
let length: i32 = actual.out.parse().unwrap();
|
||||
assert_eq!(length, 1);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user