Remove it expansion (#2701)

* Remove it-expansion, take 2

* Cleanup

* silly update to test CI
This commit is contained in:
Jonathan Turner 2020-10-26 19:55:52 +13:00 committed by GitHub
parent 502c9ea706
commit 6951fb440c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
95 changed files with 175 additions and 642 deletions

View File

@ -219,15 +219,15 @@ We can pipeline this into a command that gets the contents of one of the columns
name │ nu name │ nu
readme │ README.md readme │ README.md
repository │ https://github.com/nushell/nushell repository │ https://github.com/nushell/nushell
version │ 0.15.1 version │ 0.21.0
───────────────┴──────────────────────────────────── ───────────────┴────────────────────────────────────
``` ```
Finally, we can use commands outside of Nu once we have the data we want: Finally, we can use commands outside of Nu once we have the data we want:
```shell ```shell
> open Cargo.toml | get package.version | echo $it > open Cargo.toml | get package.version
0.15.1 0.21.0
``` ```
Here we use the variable `$it` to refer to the value being piped to the external command. Here we use the variable `$it` to refer to the value being piped to the external command.

View File

@ -393,13 +393,10 @@ pub async fn cli(mut context: EvaluationContext) -> Result<(), Box<dyn Error>> {
match nu_parser::lite_parse(&prompt_line, 0).map_err(ShellError::from) { match nu_parser::lite_parse(&prompt_line, 0).map_err(ShellError::from) {
Ok(result) => { Ok(result) => {
let mut prompt_block = let prompt_block = nu_parser::classify_block(&result, context.registry());
nu_parser::classify_block(&result, context.registry());
let env = context.get_env(); let env = context.get_env();
prompt_block.block.expand_it_usage();
match run_block( match run_block(
&prompt_block.block, &prompt_block.block,
&mut context, &mut context,
@ -862,8 +859,7 @@ pub async fn parse_and_eval(line: &str, ctx: &mut EvaluationContext) -> Result<S
let lite_result = nu_parser::lite_parse(&line, 0)?; let lite_result = nu_parser::lite_parse(&line, 0)?;
// TODO ensure the command whose examples we're testing is actually in the pipeline // TODO ensure the command whose examples we're testing is actually in the pipeline
let mut classified_block = nu_parser::classify_block(&lite_result, ctx.registry()); let classified_block = nu_parser::classify_block(&lite_result, ctx.registry());
classified_block.block.expand_it_usage();
let input_stream = InputStream::empty(); let input_stream = InputStream::empty();
let env = ctx.get_env(); let env = ctx.get_env();
@ -904,7 +900,7 @@ pub async fn process_line(
debug!("=== Parsed ==="); debug!("=== Parsed ===");
debug!("{:#?}", result); debug!("{:#?}", result);
let mut classified_block = nu_parser::classify_block(&result, ctx.registry()); let classified_block = nu_parser::classify_block(&result, ctx.registry());
debug!("{:#?}", classified_block); debug!("{:#?}", classified_block);
//println!("{:#?}", pipeline); //println!("{:#?}", pipeline);
@ -1021,8 +1017,6 @@ pub async fn process_line(
InputStream::empty() InputStream::empty()
}; };
classified_block.block.expand_it_usage();
trace!("{:#?}", classified_block); trace!("{:#?}", classified_block);
let env = ctx.get_env(); let env = ctx.get_env();
match run_block( match run_block(

View File

@ -4,7 +4,7 @@ use crate::prelude::*;
use nu_data::config; use nu_data::config;
use nu_errors::ShellError; use nu_errors::ShellError;
use nu_parser::SignatureRegistry; use nu_parser::SignatureRegistry;
use nu_protocol::hir::{ClassifiedCommand, Expression, NamedValue, SpannedExpression, Variable}; use nu_protocol::hir::{ClassifiedCommand, Expression, NamedValue, SpannedExpression};
use nu_protocol::{ use nu_protocol::{
hir::Block, CommandAction, NamedType, PositionalType, ReturnSuccess, Signature, SyntaxShape, hir::Block, CommandAction, NamedType, PositionalType, ReturnSuccess, Signature, SyntaxShape,
UntaggedValue, Value, UntaggedValue, Value,
@ -243,7 +243,7 @@ fn find_expr_shapes(
Expression::Block(b) => find_block_shapes(&b, registry), Expression::Block(b) => find_block_shapes(&b, registry),
Expression::Path(path) => match &path.head.expr { Expression::Path(path) => match &path.head.expr {
Expression::Invocation(b) => find_block_shapes(&b, registry), Expression::Invocation(b) => find_block_shapes(&b, registry),
Expression::Variable(Variable::Other(var, _)) => { Expression::Variable(var, _) => {
let mut result = HashMap::new(); let mut result = HashMap::new();
result.insert(var.to_string(), (spanned_expr.span, None)); result.insert(var.to_string(), (spanned_expr.span, None));
Ok(result) Ok(result)

View File

@ -219,33 +219,15 @@ fn spawn(
UntaggedValue::Primitive(Primitive::Nothing) => continue, UntaggedValue::Primitive(Primitive::Nothing) => continue,
UntaggedValue::Primitive(Primitive::String(s)) UntaggedValue::Primitive(Primitive::String(s))
| UntaggedValue::Primitive(Primitive::Line(s)) => { | UntaggedValue::Primitive(Primitive::Line(s)) => {
if let Err(e) = stdin_write.write(s.as_bytes()) { if stdin_write.write(s.as_bytes()).is_err() {
let message = format!("Unable to write to stdin (error = {})", e); // Other side has closed, so exit
return Ok(());
let _ = stdin_write_tx.send(Ok(Value {
value: UntaggedValue::Error(ShellError::labeled_error(
message,
"application may have closed before completing pipeline",
&stdin_name_tag,
)),
tag: stdin_name_tag,
}));
return Err(());
} }
} }
UntaggedValue::Primitive(Primitive::Binary(b)) => { UntaggedValue::Primitive(Primitive::Binary(b)) => {
if let Err(e) = stdin_write.write(b) { if stdin_write.write(b).is_err() {
let message = format!("Unable to write to stdin (error = {})", e); // Other side has closed, so exit
return Ok(());
let _ = stdin_write_tx.send(Ok(Value {
value: UntaggedValue::Error(ShellError::labeled_error(
message,
"application may have closed before completing pipeline",
&stdin_name_tag,
)),
tag: stdin_name_tag,
}));
return Err(());
} }
} }
unsupported => { unsupported => {

View File

@ -97,7 +97,7 @@ pub async fn process_row(
&block, &block,
Arc::make_mut(&mut context), Arc::make_mut(&mut context),
input_stream, input_stream,
Scope::append_it(scope, input), Scope::append_var(scope, "$it", input),
) )
.await? .await?
.to_output_stream()) .to_output_stream())

View File

@ -187,7 +187,7 @@ async fn process_row(
let for_block = input.clone(); let for_block = input.clone();
let input_stream = once(async { Ok(for_block) }).to_input_stream(); let input_stream = once(async { Ok(for_block) }).to_input_stream();
let scope = Scope::append_it(scope, input.clone()); let scope = Scope::append_var(scope, "$it", input.clone());
let mut stream = run_block( let mut stream = run_block(
&default_block, &default_block,

View File

@ -50,7 +50,7 @@ impl WholeStreamCommand for Command {
}, },
Example { Example {
description: "restrict the flattening by passing column names", description: "restrict the flattening by passing column names",
example: "echo [[origin, crate, versions]; [World, $(echo [[name]; ['nu-cli']]), ['0.21', '0.22']]] | flatten versions | last | = $it.versions", example: "echo [[origin, crate, versions]; [World, $(echo [[name]; ['nu-cli']]), ['0.21', '0.22']]] | flatten versions | last | get versions",
result: Some(vec![Value::from("0.22")]), result: Some(vec![Value::from("0.22")]),
} }
] ]

View File

@ -83,7 +83,7 @@ async fn format_command(
let result = evaluate_baseline_expr( let result = evaluate_baseline_expr(
&full_column_path.0, &full_column_path.0,
&registry, &registry,
Scope::append_it(scope.clone(), value.clone()), Scope::append_var(scope.clone(), "$it", value.clone()),
) )
.await; .await;

View File

@ -121,7 +121,7 @@ async fn if_command(
let then_case = then_case.clone(); let then_case = then_case.clone();
let else_case = else_case.clone(); let else_case = else_case.clone();
let registry = registry.clone(); let registry = registry.clone();
let scope = Scope::append_it(scope.clone(), input); let scope = Scope::append_var(scope.clone(), "$it", input);
let mut context = context.clone(); let mut context = context.clone();
async move { async move {

View File

@ -87,7 +87,7 @@ async fn process_row(
let for_block = input.clone(); let for_block = input.clone();
let input_stream = once(async { Ok(for_block) }).to_input_stream(); let input_stream = once(async { Ok(for_block) }).to_input_stream();
let scope = Scope::append_it(scope, input.clone()); let scope = Scope::append_var(scope, "$it", input.clone());
let result = run_block(&block, Arc::make_mut(&mut context), input_stream, scope).await; let result = run_block(&block, Arc::make_mut(&mut context), input_stream, scope).await;
@ -140,7 +140,7 @@ async fn process_row(
value: UntaggedValue::Primitive(Primitive::Nothing), value: UntaggedValue::Primitive(Primitive::Nothing),
.. ..
} => match scope } => match scope
.it() .var("$it")
.unwrap_or_else(|| UntaggedValue::nothing().into_untagged_value()) .unwrap_or_else(|| UntaggedValue::nothing().into_untagged_value())
.insert_data_at_column_path(&field, value.clone()) .insert_data_at_column_path(&field, value.clone())
{ {

View File

@ -37,7 +37,7 @@ impl WholeStreamCommand for IntoInt {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Convert filesize to integer", description: "Convert filesize to integer",
example: "echo 1kb | into-int $it | = $it / 1024", example: "into-int 1kb | each { = $it / 1024 }",
result: Some(vec![UntaggedValue::int(1).into()]), result: Some(vec![UntaggedValue::int(1).into()]),
}] }]
} }

View File

@ -85,7 +85,7 @@ impl WholeStreamCommand for SubCommand {
.take_while(move |item| { .take_while(move |item| {
let condition = condition.clone(); let condition = condition.clone();
let registry = registry.clone(); let registry = registry.clone();
let scope = Scope::append_it(scope.clone(), item.clone()); let scope = Scope::append_var(scope.clone(), "$it", item.clone());
trace!("ITEM = {:?}", item); trace!("ITEM = {:?}", item);
async move { async move {

View File

@ -84,7 +84,7 @@ impl WholeStreamCommand for SubCommand {
.take_while(move |item| { .take_while(move |item| {
let condition = condition.clone(); let condition = condition.clone();
let registry = registry.clone(); let registry = registry.clone();
let scope = Scope::append_it(scope.clone(), item.clone()); let scope = Scope::append_var(scope.clone(), "$it", item.clone());
trace!("ITEM = {:?}", item); trace!("ITEM = {:?}", item);
async move { async move {

View File

@ -213,7 +213,8 @@ pub async fn fetch(
)), )),
}; };
let res = std::fs::read(location)?; let res = std::fs::read(location)
.map_err(|_| ShellError::labeled_error("Can't open filename given", "can't open", span))?;
// If no encoding is provided we try to guess the encoding to read the file with // If no encoding is provided we try to guess the encoding to read the file with
let encoding = if encoding_choice.is_none() { let encoding = if encoding_choice.is_none() {

View File

@ -87,7 +87,7 @@ async fn process_row(
let row_clone = row.clone(); let row_clone = row.clone();
let input_stream = once(async { Ok(row_clone) }).to_input_stream(); let input_stream = once(async { Ok(row_clone) }).to_input_stream();
let scope = Scope::append_it(scope, row); let scope = Scope::append_var(scope, "$it", row);
Ok(run_block(&block, Arc::make_mut(&mut context), input_stream, scope).await?) Ok(run_block(&block, Arc::make_mut(&mut context), input_stream, scope).await?)
} }
@ -145,7 +145,7 @@ async fn reduce(
UntaggedValue::table(&values).into_untagged_value() UntaggedValue::table(&values).into_untagged_value()
}; };
let scope = Scope::append_var(scope, "$acc".into(), f); let scope = Scope::append_var(scope, "$acc", f);
process_row(block, scope, context, row).await process_row(block, scope, context, row).await
} }
}) })
@ -173,7 +173,7 @@ async fn reduce(
UntaggedValue::table(&values).into_untagged_value() UntaggedValue::table(&values).into_untagged_value()
}; };
let scope = Scope::append_var(scope, "$acc".into(), f); let scope = Scope::append_var(scope, "$acc", f);
process_row(block, scope, context, row).await process_row(block, scope, context, row).await
} }
}) })

View File

@ -84,7 +84,7 @@ impl WholeStreamCommand for SubCommand {
.skip_while(move |item| { .skip_while(move |item| {
let condition = condition.clone(); let condition = condition.clone();
let registry = registry.clone(); let registry = registry.clone();
let scope = Scope::append_it(scope.clone(), item.clone()); let scope = Scope::append_var(scope.clone(), "$it", item.clone());
trace!("ITEM = {:?}", item); trace!("ITEM = {:?}", item);
async move { async move {

View File

@ -85,7 +85,7 @@ impl WholeStreamCommand for SubCommand {
let item = item.clone(); let item = item.clone();
let condition = condition.clone(); let condition = condition.clone();
let registry = registry.clone(); let registry = registry.clone();
let scope = Scope::append_it(scope.clone(), item.clone()); let scope = Scope::append_var(scope.clone(), "$it", item.clone());
trace!("ITEM = {:?}", item); trace!("ITEM = {:?}", item);
async move { async move {

View File

@ -92,7 +92,7 @@ async fn process_row(
let for_block = input.clone(); let for_block = input.clone();
let input_stream = once(async { Ok(for_block) }).to_input_stream(); let input_stream = once(async { Ok(for_block) }).to_input_stream();
let scope = Scope::append_it(scope, input.clone()); let scope = Scope::append_var(scope, "$it", input.clone());
let result = run_block(&block, Arc::make_mut(&mut context), input_stream, scope).await; let result = run_block(&block, Arc::make_mut(&mut context), input_stream, scope).await;
@ -149,7 +149,7 @@ async fn process_row(
value: UntaggedValue::Primitive(Primitive::Nothing), value: UntaggedValue::Primitive(Primitive::Nothing),
.. ..
} => match scope } => match scope
.it() .var("$it")
.unwrap_or_else(|| UntaggedValue::nothing().into_untagged_value()) .unwrap_or_else(|| UntaggedValue::nothing().into_untagged_value())
.replace_data_at_column_path(&field, replacement.clone()) .replace_data_at_column_path(&field, replacement.clone())
{ {

View File

@ -106,7 +106,7 @@ async fn where_command(
.filter_map(move |input| { .filter_map(move |input| {
let condition = condition.clone(); let condition = condition.clone();
let registry = registry.clone(); let registry = registry.clone();
let scope = Scope::append_it(scope.clone(), input.clone()); let scope = Scope::append_var(scope.clone(), "$it", input.clone());
async move { async move {
//FIXME: should we use the scope that's brought in as well? //FIXME: should we use the scope that's brought in as well?

View File

@ -38,7 +38,7 @@ impl<'s> Flatten<'s> {
.collect(), .collect(),
Expression::Command => vec![LocationType::Command.spanned(e.span)], Expression::Command => vec![LocationType::Command.spanned(e.span)],
Expression::Path(path) => self.expression(&path.head), Expression::Path(path) => self.expression(&path.head),
Expression::Variable(_) => vec![LocationType::Variable.spanned(e.span)], Expression::Variable(_, _) => vec![LocationType::Variable.spanned(e.span)],
Expression::Boolean(_) Expression::Boolean(_)
| Expression::FilePath(_) | Expression::FilePath(_)

View File

@ -32,7 +32,7 @@ pub(crate) async fn evaluate_baseline_expr(
Expression::Synthetic(hir::Synthetic::String(s)) => { Expression::Synthetic(hir::Synthetic::String(s)) => {
Ok(UntaggedValue::string(s).into_untagged_value()) Ok(UntaggedValue::string(s).into_untagged_value())
} }
Expression::Variable(var) => evaluate_reference(&var, scope, tag), Expression::Variable(var, _) => evaluate_reference(&var, scope, tag),
Expression::Command => unimplemented!(), Expression::Command => unimplemented!(),
Expression::Invocation(block) => evaluate_invocation(block, registry, scope).await, Expression::Invocation(block) => evaluate_invocation(block, registry, scope).await,
Expression::ExternalCommand(_) => unimplemented!(), Expression::ExternalCommand(_) => unimplemented!(),
@ -199,30 +199,29 @@ fn evaluate_literal(literal: &hir::Literal, span: Span) -> Value {
} }
} }
fn evaluate_reference( fn evaluate_reference(name: &str, scope: Arc<Scope>, tag: Tag) -> Result<Value, ShellError> {
name: &hir::Variable,
scope: Arc<Scope>,
tag: Tag,
) -> Result<Value, ShellError> {
match name { match name {
hir::Variable::It(_) => match scope.it() { "$nu" => crate::evaluate::variables::nu(&scope.env(), tag),
Some(v) => Ok(v),
None => Err(ShellError::labeled_error( "$true" => Ok(Value {
"$it variable not in scope",
"not in scope (are you missing an 'each'?)",
tag.span,
)),
},
hir::Variable::Other(name, _) => match name {
x if x == "$nu" => crate::evaluate::variables::nu(&scope.env(), tag),
x if x == "$true" => Ok(Value {
value: UntaggedValue::boolean(true), value: UntaggedValue::boolean(true),
tag, tag,
}), }),
x if x == "$false" => Ok(Value {
"$false" => Ok(Value {
value: UntaggedValue::boolean(false), value: UntaggedValue::boolean(false),
tag, tag,
}), }),
"$it" => match scope.var("$it") {
Some(v) => Ok(v),
None => Err(ShellError::labeled_error(
"Variable not in scope",
"missing '$it' (note: $it is only available inside of a block)",
tag.span,
)),
},
x => match scope.var(x) { x => match scope.var(x) {
Some(v) => Ok(v), Some(v) => Ok(v),
None => Err(ShellError::labeled_error( None => Err(ShellError::labeled_error(
@ -231,7 +230,6 @@ fn evaluate_reference(
tag.span, tag.span,
)), )),
}, },
},
} }
} }
@ -244,7 +242,7 @@ async fn evaluate_invocation(
let mut context = EvaluationContext::basic()?; let mut context = EvaluationContext::basic()?;
context.registry = registry.clone(); context.registry = registry.clone();
let input = match scope.it() { let input = match scope.var("$it") {
Some(it) => InputStream::one(it), Some(it) => InputStream::one(it),
None => InputStream::empty(), None => InputStream::empty(),
}; };

View File

@ -200,8 +200,7 @@ fn parse_line(line: &str, ctx: &mut EvaluationContext) -> Result<ClassifiedBlock
let lite_result = nu_parser::lite_parse(&line, 0)?; let lite_result = nu_parser::lite_parse(&line, 0)?;
// TODO ensure the command whose examples we're testing is actually in the pipeline // TODO ensure the command whose examples we're testing is actually in the pipeline
let mut classified_block = nu_parser::classify_block(&lite_result, ctx.registry()); let classified_block = nu_parser::classify_block(&lite_result, ctx.registry());
classified_block.block.expand_it_usage();
Ok(classified_block) Ok(classified_block)
} }

View File

@ -737,15 +737,14 @@ impl Shell for FilesystemShell {
let mut codec = MaybeTextCodec::new(with_encoding); let mut codec = MaybeTextCodec::new(with_encoding);
match codec.decode(&mut bytes_mut).map_err(|e| { match codec.decode(&mut bytes_mut).map_err(|_| {
ShellError::unexpected(format!("AsyncRead failed in open function: {:?}", e)) ShellError::labeled_error("Error opening file", "error opening file", name)
})? { })? {
Some(sb) => Ok(futures::stream::iter(vec![Ok(sb)].into_iter()).boxed()), Some(sb) => Ok(futures::stream::iter(vec![Ok(sb)].into_iter()).boxed()),
None => Ok(futures::stream::iter(vec![].into_iter()).boxed()), None => Ok(futures::stream::iter(vec![].into_iter()).boxed()),
} }
} else { } else {
// We don't know that this is a finite file, so treat it as a stream // We don't know that this is a finite file, so treat it as a stream
let f = std::fs::File::open(&path).map_err(|e| { let f = std::fs::File::open(&path).map_err(|e| {
ShellError::labeled_error( ShellError::labeled_error(
format!("Error opening file: {:?}", e), format!("Error opening file: {:?}", e),
@ -755,8 +754,8 @@ impl Shell for FilesystemShell {
})?; })?;
let async_reader = futures::io::AllowStdIo::new(f); let async_reader = futures::io::AllowStdIo::new(f);
let sob_stream = FramedRead::new(async_reader, MaybeTextCodec::new(with_encoding)) let sob_stream = FramedRead::new(async_reader, MaybeTextCodec::new(with_encoding))
.map_err(|e| { .map_err(move |_| {
ShellError::unexpected(format!("AsyncRead failed in open function: {:?}", e)) ShellError::labeled_error("Error opening file", "error opening file", name)
}) })
.into_stream(); .into_stream();

View File

@ -21,7 +21,6 @@ fn adds_a_row_to_the_end() {
| lines | lines
| append "pollo loco" | append "pollo loco"
| nth 3 | nth 3
| echo $it
"# "#
)); ));

View File

@ -71,7 +71,7 @@ fn cal_sees_pipeline_year() {
let actual = nu!( let actual = nu!(
cwd: ".", pipeline( cwd: ".", pipeline(
r#" r#"
echo 1020 | cal --full-year $it | get monday | first 3 | to json cal --full-year 1020 | get monday | first 3 | to json
"# "#
)); ));

View File

@ -10,7 +10,7 @@ fn filesystem_change_from_current_directory_using_relative_path() {
cwd: dirs.root(), cwd: dirs.root(),
r#" r#"
cd cd_test_1 cd cd_test_1
pwd | echo $it echo $(pwd)
"# "#
); );
@ -25,7 +25,7 @@ fn filesystem_change_from_current_directory_using_absolute_path() {
cwd: dirs.test(), cwd: dirs.test(),
r#" r#"
cd "{}" cd "{}"
pwd | echo $it echo $(pwd)
"#, "#,
dirs.formats() dirs.formats()
); );
@ -44,7 +44,7 @@ fn filesystem_switch_back_to_previous_working_directory() {
r#" r#"
cd {} cd {}
cd - cd -
pwd | echo $it echo $(pwd)
"#, "#,
dirs.test() dirs.test()
); );
@ -62,7 +62,7 @@ fn filesytem_change_from_current_directory_using_relative_path_and_dash() {
cwd: dirs.test(), cwd: dirs.test(),
r#" r#"
cd odin/- cd odin/-
pwd | echo $it echo $(pwd)
"# "#
); );
@ -80,7 +80,7 @@ fn filesystem_change_current_directory_to_parent_directory() {
cwd: dirs.test(), cwd: dirs.test(),
r#" r#"
cd .. cd ..
pwd | echo $it echo $(pwd)
"# "#
); );
@ -97,7 +97,7 @@ fn filesystem_change_current_directory_to_two_parents_up_using_multiple_dots() {
cwd: dirs.test().join("foo/bar"), cwd: dirs.test().join("foo/bar"),
r#" r#"
cd ... cd ...
pwd | echo $it echo $(pwd)
"# "#
); );
@ -116,7 +116,7 @@ fn filesystem_change_current_directory_to_parent_directory_after_delete_cwd() {
rm {}/foo/bar rm {}/foo/bar
echo "," echo ","
cd .. cd ..
pwd | echo $it echo $(pwd)
"#, "#,
dirs.test() dirs.test()
); );
@ -135,7 +135,7 @@ fn filesystem_change_to_home_directory() {
cwd: dirs.test(), cwd: dirs.test(),
r#" r#"
cd ~ cd ~
pwd | echo $it echo $(pwd)
"# "#
); );
@ -152,7 +152,7 @@ fn filesystem_change_to_a_directory_containing_spaces() {
cwd: dirs.test(), cwd: dirs.test(),
r#" r#"
cd "robalino turner katz" cd "robalino turner katz"
pwd | echo $it echo $(pwd)
"# "#
); );
@ -219,7 +219,7 @@ fn filesystem_change_directory_to_symlink_relative() {
cwd: dirs.test().join("boo"), cwd: dirs.test().join("boo"),
r#" r#"
cd ../foo_link cd ../foo_link
pwd | echo $it echo $(pwd)
"# "#
); );
@ -249,7 +249,7 @@ fn valuesystem_change_from_current_path_using_relative_path() {
r#" r#"
enter sample.toml enter sample.toml
cd bin cd bin
pwd | echo $it pwd
exit exit
"# "#
); );
@ -283,7 +283,7 @@ fn valuesystem_change_from_current_path_using_absolute_path() {
enter sample.toml enter sample.toml
cd bin cd bin
cd /dependencies cd /dependencies
pwd | echo $it pwd
exit exit
"# "#
); );
@ -319,7 +319,7 @@ fn valuesystem_switch_back_to_previous_working_path() {
cd dependencies cd dependencies
cd /bin cd /bin
cd - cd -
pwd | echo $it pwd
exit exit
"# "#
); );
@ -353,7 +353,7 @@ fn valuesystem_change_from_current_path_using_relative_path_and_dash() {
cd package/- cd package/-
cd /bin cd /bin
cd - cd -
pwd | echo $it pwd
exit exit
"# "#
); );
@ -380,7 +380,7 @@ fn valuesystem_change_current_path_to_parent_path() {
enter sample.toml enter sample.toml
cd package/emberenios cd package/emberenios
cd .. cd ..
pwd | echo $it pwd
exit exit
"# "#
); );
@ -405,7 +405,7 @@ fn valuesystem_change_to_a_path_containing_spaces() {
r#" r#"
enter sample.toml enter sample.toml
cd "pa que te" cd "pa que te"
pwd | echo $it pwd
exit exit
"# "#
); );

View File

@ -26,7 +26,6 @@ fn discards_rows_where_given_column_is_empty() {
| get amigos | get amigos
| compact rusty_luck | compact rusty_luck
| count | count
| echo $it
"# "#
)); ));
@ -43,7 +42,6 @@ fn discards_empty_rows_by_default() {
| from json | from json
| compact | compact
| count | count
| echo $it
"# "#
)); ));

View File

@ -27,7 +27,6 @@ fn adds_row_data_if_column_missing() {
| default rusty_luck 1 | default rusty_luck 1
| where rusty_luck == 1 | where rusty_luck == 1
| count | count
| echo $it
"# "#
)); ));

View File

@ -4,7 +4,7 @@ use nu_test_support::{nu, pipeline};
fn drop_rows() { fn drop_rows() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", cwd: "tests/fixtures/formats",
r#"echo '[{"foo": 3}, {"foo": 8}, {"foo": 4}]' | from json | drop 2 | get foo | math sum | echo $it"# r#"echo '[{"foo": 3}, {"foo": 8}, {"foo": 4}]' | from json | drop 2 | get foo | math sum "#
); );
assert_eq!(actual.out, "3"); assert_eq!(actual.out, "3");

View File

@ -5,7 +5,7 @@ fn each_works_separately() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", pipeline( cwd: "tests/fixtures/formats", pipeline(
r#" r#"
echo [1 2 3] | each { echo $it 10 | math sum } | to json | echo $it echo [1 2 3] | each { echo $it 10 | math sum } | to json
"# "#
)); ));

View File

@ -5,7 +5,7 @@ fn echo_range_is_lazy() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", pipeline( cwd: "tests/fixtures/formats", pipeline(
r#" r#"
echo 1..10000000000 | first 3 | echo $it | to json echo 1..10000000000 | first 3 | to json
"# "#
)); ));

View File

@ -75,7 +75,7 @@ fn passing_a_block_will_set_contents_on_empty_cells_and_leave_non_empty_ones_unt
] ]
| empty? LVL { = 9 } | empty? LVL { = 9 }
| empty? HP { | empty? HP {
get LVL | = $it * 1000 = $it.LVL * 1000
} }
| math sum | math sum
| get HP | get HP

View File

@ -18,7 +18,6 @@ fn gets_first_rows_by_amount() {
ls ls
| first 3 | first 3
| count | count
| echo $it
"# "#
)); ));
@ -42,7 +41,6 @@ fn gets_all_rows_if_amount_higher_than_all_rows() {
ls ls
| first 99 | first 99
| count | count
| echo $it
"# "#
)); ));
@ -61,7 +59,6 @@ fn gets_first_row_when_no_amount_given() {
ls ls
| first | first
| count | count
| echo $it
"# "#
)); ));

View File

@ -10,7 +10,6 @@ fn creates_the_resulting_string_from_the_given_fields() {
open cargo_sample.toml open cargo_sample.toml
| get package | get package
| format "{name} has license {license}" | format "{name} has license {license}"
| echo $it
"# "#
)); ));
@ -24,7 +23,6 @@ fn given_fields_can_be_column_paths() {
r#" r#"
open cargo_sample.toml open cargo_sample.toml
| format "{package.name} is {package.description}" | format "{package.name} is {package.description}"
| echo $it
"# "#
)); ));
@ -38,7 +36,6 @@ fn can_use_variables() {
r#" r#"
open cargo_sample.toml open cargo_sample.toml
| format "{$it.package.name} is {$it.package.description}" | format "{$it.package.name} is {$it.package.description}"
| echo $it
"# "#
)); ));

View File

@ -17,7 +17,6 @@ fn fetches_a_row() {
r#" r#"
open sample.toml open sample.toml
| get nu_party_venue | get nu_party_venue
| echo $it
"# "#
)); ));
@ -44,7 +43,6 @@ fn fetches_by_index() {
r#" r#"
open sample.toml open sample.toml
| get package.authors.2 | get package.authors.2
| echo $it
"# "#
)); ));
@ -67,7 +65,6 @@ fn fetches_by_column_path() {
r#" r#"
open sample.toml open sample.toml
| get package.name | get package.name
| echo $it
"# "#
)); ));
@ -93,7 +90,6 @@ fn column_paths_are_either_double_quoted_or_regular_unquoted_words_separated_by_
open sample.toml open sample.toml
| get package."9999" | get package."9999"
| count | count
| echo $it
"# "#
)); ));
@ -127,7 +123,6 @@ fn fetches_more_than_one_column_path() {
open sample.toml open sample.toml
| get fortune_tellers.2.name fortune_tellers.0.name fortune_tellers.1.name | get fortune_tellers.2.name fortune_tellers.0.name fortune_tellers.1.name
| nth 2 | nth 2
| echo $it
"# "#
)); ));
@ -250,7 +245,7 @@ fn errors_fetching_by_index_out_of_bounds() {
fn quoted_column_access() { fn quoted_column_access() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", cwd: "tests/fixtures/formats",
r#"echo '[{"foo bar": {"baz": 4}}]' | from json | get "foo bar".baz | echo $it"# r#"echo '[{"foo bar": {"baz": 4}}]' | from json | get "foo bar".baz "#
); );
assert_eq!(actual.out, "4"); assert_eq!(actual.out, "4");

View File

@ -22,7 +22,6 @@ fn groups() {
| group-by rusty_at | group-by rusty_at
| get "10/11/2013" | get "10/11/2013"
| count | count
| echo $it
"# "#
)); ));

View File

@ -22,7 +22,6 @@ fn summarizes_by_column_given() {
| histogram rusty_at countries | histogram rusty_at countries
| where rusty_at == "Ecuador" | where rusty_at == "Ecuador"
| get countries | get countries
| echo $it
"# "#
)); ));
@ -55,7 +54,6 @@ fn summarizes_by_values() {
| histogram | histogram
| where value == "Estados Unidos" | where value == "Estados Unidos"
| get count | get count
| echo $it
"# "#
)); ));

View File

@ -8,7 +8,6 @@ fn sets_the_column_from_a_block_run_output() {
open cargo_sample.toml open cargo_sample.toml
| insert dev-dependencies.newdep "1" | insert dev-dependencies.newdep "1"
| get dev-dependencies.newdep | get dev-dependencies.newdep
| echo $it
"# "#
)); ));
@ -24,7 +23,6 @@ fn sets_the_column_from_a_block_full_stream_output() {
| insert content { open --raw cargo_sample.toml | lines | first 5 } | insert content { open --raw cargo_sample.toml | lines | first 5 }
| get content.1 | get content.1
| str contains "nu" | str contains "nu"
| echo $it
"# "#
)); ));
@ -40,7 +38,6 @@ fn sets_the_column_from_an_invocation() {
| insert content $(open --raw cargo_sample.toml | lines | first 5) | insert content $(open --raw cargo_sample.toml | lines | first 5)
| get content.1 | get content.1
| str contains "nu" | str contains "nu"
| echo $it
"# "#
)); ));

View File

@ -5,7 +5,7 @@ fn into_int_filesize() {
let actual = nu!( let actual = nu!(
cwd: ".", pipeline( cwd: ".", pipeline(
r#" r#"
into-int 1kb | = $it / 1024 into-int 1kb | each {= $it / 1024 }
"# "#
)); ));
@ -17,7 +17,7 @@ fn into_int_int() {
let actual = nu!( let actual = nu!(
cwd: ".", pipeline( cwd: ".", pipeline(
r#" r#"
into-int 1024 | = $it / 1024 into-int 1024 | each {= $it / 1024 }
"# "#
)); ));

View File

@ -23,7 +23,6 @@ fn rows() {
| keep 3 | keep 3
| get lucky_code | get lucky_code
| math sum | math sum
| echo $it
"# "#
)); ));

View File

@ -43,7 +43,6 @@ fn condition_is_met() {
| str to-int "31/04/2020" | str to-int "31/04/2020"
| get "31/04/2020" | get "31/04/2020"
| math sum | math sum
| echo $it
"# "#
)); ));

View File

@ -42,7 +42,6 @@ fn condition_is_met() {
| str to-int "31/04/2020" | str to-int "31/04/2020"
| get "31/04/2020" | get "31/04/2020"
| math sum | math sum
| echo $it
"# "#
)); ));

View File

@ -6,7 +6,7 @@ use nu_test_support::{nu, pipeline};
fn gets_the_last_row() { fn gets_the_last_row() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", cwd: "tests/fixtures/formats",
"ls | sort-by name | last 1 | get name | str trim | echo $it" "ls | sort-by name | last 1 | get name | str trim"
); );
assert_eq!(actual.out, "utf16.ini"); assert_eq!(actual.out, "utf16.ini");
@ -28,7 +28,6 @@ fn gets_last_rows_by_amount() {
ls ls
| last 3 | last 3
| count | count
| echo $it
"# "#
)); ));
@ -47,7 +46,6 @@ fn gets_last_row_when_no_amount_given() {
ls ls
| last | last
| count | count
| echo $it
"# "#
)); ));

View File

@ -13,7 +13,6 @@ fn lines() {
| split column "=" | split column "="
| get Column1 | get Column1
| str trim | str trim
| echo $it
"# "#
)); ));

View File

@ -16,7 +16,6 @@ fn lists_regular_files() {
r#" r#"
ls ls
| count | count
| echo $it
"# "#
)); ));
@ -39,7 +38,6 @@ fn lists_regular_files_using_asterisk_wildcard() {
r#" r#"
ls *.txt ls *.txt
| count | count
| echo $it
"# "#
)); ));
@ -62,7 +60,6 @@ fn lists_regular_files_using_question_mark_wildcard() {
r#" r#"
ls *.??.txt ls *.??.txt
| count | count
| echo $it
"# "#
)); ));
@ -90,9 +87,8 @@ fn lists_all_files_in_directories_from_stream() {
cwd: dirs.test(), pipeline( cwd: dirs.test(), pipeline(
r#" r#"
echo dir_a dir_b echo dir_a dir_b
| ls $it | each { ls $it }
| count | count
| echo $it
"# "#
)); ));
@ -110,7 +106,6 @@ fn does_not_fail_if_glob_matches_empty_directory() {
r#" r#"
ls dir_a ls dir_a
| count | count
| echo $it
"# "#
)); ));
@ -147,7 +142,7 @@ fn list_files_from_two_parents_up_using_multiple_dots() {
let actual = nu!( let actual = nu!(
cwd: dirs.test().join("foo/bar"), cwd: dirs.test().join("foo/bar"),
r#" r#"
ls ... | count | echo $it ls ... | count
"# "#
); );
@ -171,7 +166,6 @@ fn lists_hidden_file_when_explicitly_specified() {
r#" r#"
ls .testdotfile ls .testdotfile
| count | count
| echo $it
"# "#
)); ));
@ -206,7 +200,6 @@ fn lists_all_hidden_files_when_glob_contains_dot() {
r#" r#"
ls **/.* ls **/.*
| count | count
| echo $it
"# "#
)); ));
@ -244,7 +237,6 @@ fn lists_all_hidden_files_when_glob_does_not_contain_dot() {
r#" r#"
ls **/* ls **/*
| count | count
| echo $it
"# "#
)); ));
@ -268,7 +260,6 @@ fn lists_files_including_starting_with_dot() {
r#" r#"
ls -a ls -a
| count | count
| echo $it
"# "#
)); ));

View File

@ -8,7 +8,6 @@ fn can_average_numbers() {
open sgml_description.json open sgml_description.json
| get glossary.GlossDiv.GlossList.GlossEntry.Sections | get glossary.GlossDiv.GlossList.GlossEntry.Sections
| math avg | math avg
| echo $it
"# "#
)); ));
@ -19,7 +18,7 @@ fn can_average_numbers() {
fn can_average_bytes() { fn can_average_bytes() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", cwd: "tests/fixtures/formats",
"ls | sort-by name | skip 1 | first 2 | get size | math avg | format \"{$it}\" | echo $it" "ls | sort-by name | skip 1 | first 2 | get size | math avg | format \"{$it}\" "
); );
assert_eq!(actual.out, "1.6 KB"); assert_eq!(actual.out, "1.6 KB");

View File

@ -7,7 +7,6 @@ fn median_numbers_with_even_rows() {
r#" r#"
echo [10 6 19 21 4] echo [10 6 19 21 4]
| math median | math median
| echo $it
"# "#
)); ));
@ -21,7 +20,6 @@ fn median_numbers_with_odd_rows() {
r#" r#"
echo [3 8 9 12 12 15] echo [3 8 9 12 12 15]
| math median | math median
| echo $it
"# "#
)); ));
@ -35,7 +33,6 @@ fn median_mixed_numbers() {
r#" r#"
echo [-11.5 -13.5 10] echo [-11.5 -13.5 10]
| math median | math median
| echo $it
"# "#
)); ));

View File

@ -209,18 +209,6 @@ fn duration_math_with_negative() {
assert_eq!(actual.out, "-6day"); assert_eq!(actual.out, "-6day");
} }
#[test]
fn it_math() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
echo 1020 | = $it + 10
"#
));
assert_eq!(actual.out, "1030");
}
#[test] #[test]
fn compound_comparison() { fn compound_comparison() {
let actual = nu!( let actual = nu!(

View File

@ -26,7 +26,6 @@ fn all() {
| get meals | get meals
| get calories | get calories
| math sum | math sum
| echo $it
"# "#
)); ));
@ -36,7 +35,7 @@ fn all() {
#[test] #[test]
fn outputs_zero_with_no_input() { fn outputs_zero_with_no_input() {
let actual = nu!(cwd: ".", "math sum | echo $it"); let actual = nu!(cwd: ".", "math sum");
assert_eq!(actual.out, "0"); assert_eq!(actual.out, "0");
} }

View File

@ -34,7 +34,6 @@ fn row() {
| where country in ["Guayaquil Ecuador" "New Zealand"] | where country in ["Guayaquil Ecuador" "New Zealand"]
| get luck | get luck
| math sum | math sum
| echo $it
"# "#
)); ));

View File

@ -71,7 +71,6 @@ fn show_created_paths() {
r#" r#"
mkdir -s dir_1 dir_2 dir_3 mkdir -s dir_1 dir_2 dir_3
| count | count
| echo $it
"# "#
)); ));

View File

@ -27,7 +27,6 @@ fn moves_a_column_before() {
| get chars | get chars
| str trim | str trim
| str collect | str collect
| echo $it
"# "#
)); ));
@ -62,7 +61,6 @@ fn moves_columns_before() {
| get chars_2 chars_1 | get chars_2 chars_1
| str trim | str trim
| str collect | str collect
| echo $it
"# "#
)); ));
@ -98,7 +96,6 @@ fn moves_a_column_after() {
| get chars_1 chars_2 | get chars_1 chars_2
| str trim | str trim
| str collect | str collect
| echo $it
"# "#
)); ));
@ -132,7 +129,6 @@ fn moves_columns_after() {
| get | get
| nth 1 2 | nth 1 2
| str collect | str collect
| echo $it
"# "#
)); ));

View File

@ -10,7 +10,6 @@ fn selects_a_row() {
| sort-by name | sort-by name
| nth 0 | nth 0
| get name | get name
| echo $it
"# "#
)); ));
@ -30,7 +29,6 @@ fn selects_many_rows() {
| get name | get name
| nth 1 0 | nth 1 0
| count | count
| echo $it
"# "#
)); ));

View File

@ -21,7 +21,6 @@ fn parses_csv() {
open nu.zion.csv open nu.zion.csv
| where author == "Andres N. Robalino" | where author == "Andres N. Robalino"
| get source | get source
| echo $it
"# "#
)); ));
@ -59,7 +58,7 @@ fn parses_csv() {
fn parses_bson() { fn parses_bson() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", cwd: "tests/fixtures/formats",
"open sample.bson | get root | nth 0 | get b | echo $it" "open sample.bson | get root | nth 0 | get b"
); );
assert_eq!(actual.out, "hello"); assert_eq!(actual.out, "hello");
@ -76,7 +75,6 @@ fn parses_more_bson_complexity() {
| nth 6 | nth 6
| get b | get b
| get '$binary_subtype' | get '$binary_subtype'
| echo $it
"# "#
)); ));
@ -142,7 +140,6 @@ fn parses_sqlite() {
| get table_values | get table_values
| nth 2 | nth 2
| get x | get x
| echo $it
"# "#
)); ));
@ -153,7 +150,7 @@ fn parses_sqlite() {
fn parses_toml() { fn parses_toml() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", cwd: "tests/fixtures/formats",
"open cargo_sample.toml | get package.edition | echo $it" "open cargo_sample.toml | get package.edition"
); );
assert_eq!(actual.out, "2018"); assert_eq!(actual.out, "2018");
@ -167,7 +164,6 @@ fn parses_tsv() {
open caco3_plastics.tsv open caco3_plastics.tsv
| first 1 | first 1
| get origin | get origin
| echo $it
"# "#
)); ));
@ -181,7 +177,6 @@ fn parses_json() {
r#" r#"
open sgml_description.json open sgml_description.json
| get glossary.GlossDiv.GlossList.GlossEntry.GlossSee | get glossary.GlossDiv.GlossList.GlossEntry.GlossSee
| echo $it
"# "#
)); ));
@ -192,7 +187,7 @@ fn parses_json() {
fn parses_xml() { fn parses_xml() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", cwd: "tests/fixtures/formats",
"open jonathan.xml | get rss.children.channel.children | get item.children | get link.children | echo $it" "open jonathan.xml | get rss.children.channel.children | get item.children | get link.children.0"
); );
assert_eq!( assert_eq!(
@ -205,7 +200,7 @@ fn parses_xml() {
fn parses_ini() { fn parses_ini() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", cwd: "tests/fixtures/formats",
"open sample.ini | get SectionOne.integer | echo $it" "open sample.ini | get SectionOne.integer"
); );
assert_eq!(actual.out, "1234") assert_eq!(actual.out, "1234")
@ -215,7 +210,7 @@ fn parses_ini() {
fn parses_utf16_ini() { fn parses_utf16_ini() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", cwd: "tests/fixtures/formats",
"open utf16.ini | get '.ShellClassInfo' | get IconIndex | echo $it" "open utf16.ini | get '.ShellClassInfo' | get IconIndex"
); );
assert_eq!(actual.out, "-236") assert_eq!(actual.out, "-236")

View File

@ -24,7 +24,7 @@ mod simple {
| lines | lines
| each { echo $it | parse "{Name}={Value}" } | each { echo $it | parse "{Name}={Value}" }
| nth 1 | nth 1
| echo $it.Value | get Value
"# "#
)); ));
@ -40,7 +40,7 @@ mod simple {
r#" r#"
echo "{abc}123" echo "{abc}123"
| parse "{{abc}{name}" | parse "{{abc}{name}"
| echo $it.name | get name
"# "#
)); ));
@ -56,7 +56,7 @@ mod simple {
r#" r#"
echo "(abc)123" echo "(abc)123"
| parse "(abc){name}" | parse "(abc){name}"
| echo $it.name | get name
"# "#
)); ));
@ -89,7 +89,7 @@ mod simple {
r#" r#"
echo "(abc)123" echo "(abc)123"
| parse "(abc){name" | parse "(abc){name"
| echo $it.name | get name
"# "#
)); ));
@ -123,7 +123,6 @@ mod regex {
| parse --regex "(?P<Hash>\w+) (?P<Message>.+) \(#(?P<PR>\d+)\)" | parse --regex "(?P<Hash>\w+) (?P<Message>.+) \(#(?P<PR>\d+)\)"
| nth 1 | nth 1
| get PR | get PR
| echo $it
"# "#
)); ));
@ -143,7 +142,6 @@ mod regex {
| parse --regex "(\w+) (.+) \(#(\d+)\)" | parse --regex "(\w+) (.+) \(#(\d+)\)"
| nth 1 | nth 1
| get Capture1 | get Capture1
| echo $it
"# "#
)); ));
@ -163,7 +161,6 @@ mod regex {
| parse --regex "(?P<Hash>\w+) (.+) \(#(?P<PR>\d+)\)" | parse --regex "(?P<Hash>\w+) (.+) \(#(?P<PR>\d+)\)"
| nth 1 | nth 1
| get Capture2 | get Capture2
| echo $it
"# "#
)); ));
@ -181,7 +178,6 @@ mod regex {
r#" r#"
open nushell_git_log_oneline.txt open nushell_git_log_oneline.txt
| parse --regex "(?P<Hash>\w+ unfinished capture group" | parse --regex "(?P<Hash>\w+ unfinished capture group"
| echo $it
"# "#
)); ));

View File

@ -21,7 +21,6 @@ fn adds_a_row_to_the_beginning() {
| lines | lines
| prepend "pollo loco" | prepend "pollo loco"
| nth 0 | nth 0
| echo $it
"# "#
)); ));

View File

@ -14,7 +14,6 @@ fn selects_a_row() {
| sort-by name | sort-by name
| range 0..0 | range 0..0
| get name | get name
| echo $it
"# "#
)); ));
@ -38,7 +37,6 @@ fn selects_some_rows() {
| get name | get name
| range 1..2 | range 1..2
| count | count
| echo $it
"# "#
)); ));

View File

@ -54,7 +54,6 @@ fn reduce_numbered_example() {
echo one longest three bar echo one longest three bar
| reduce -n { if $(echo $it.item | str length) > $(echo $acc.item | str length) {echo $it} {echo $acc}} | reduce -n { if $(echo $it.item | str length) > $(echo $acc.item | str length) {echo $it} {echo $acc}}
| get index | get index
| echo $it
"# "#
) )
); );
@ -74,7 +73,6 @@ fn folding_with_tables() {
} }
} }
| math sum | math sum
| echo $it
"# "#
) )
); );

View File

@ -24,7 +24,6 @@ fn changes_the_column_name() {
| rename mosqueteros | rename mosqueteros
| get mosqueteros | get mosqueteros
| count | count
| echo $it
"# "#
)); ));
@ -55,7 +54,6 @@ fn keeps_remaining_original_names_given_less_new_names_than_total_original_names
| rename mosqueteros | rename mosqueteros
| get hit | get hit
| count | count
| echo $it
"# "#
)); ));

View File

@ -4,7 +4,7 @@ use nu_test_support::nu;
fn can_get_reverse_first() { fn can_get_reverse_first() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", cwd: "tests/fixtures/formats",
"ls | sort-by name | reverse | first 1 | get name | str trim | echo $it" "ls | sort-by name | reverse | first 1 | get name | str trim "
); );
assert_eq!(actual.out, "utf16.ini"); assert_eq!(actual.out, "utf16.ini");

View File

@ -22,7 +22,6 @@ fn regular_columns() {
| select rusty_at last_name | select rusty_at last_name
| nth 0 | nth 0
| get last_name | get last_name
| echo $it
"# "#
)); ));
@ -65,7 +64,6 @@ fn complex_nested_columns() {
| select nu."0xATYKARNU" nu.committers.name nu.releases.version | select nu."0xATYKARNU" nu.committers.name nu.releases.version
| where "nu.releases.version" > "0.8" | where "nu.releases.version" > "0.8"
| get "nu.releases.version" | get "nu.releases.version"
| echo $it
"# "#
)); ));
@ -92,7 +90,6 @@ fn allows_if_given_unknown_column_name_is_missing() {
open los_tres_caballeros.csv open los_tres_caballeros.csv
| select rrusty_at first_name | select rrusty_at first_name
| count | count
| echo $it
"# "#
)); ));

View File

@ -42,7 +42,6 @@ fn condition_is_met() {
| str to-int "31/04/2020" | str to-int "31/04/2020"
| get "31/04/2020" | get "31/04/2020"
| math sum | math sum
| echo $it
"# "#
)); ));

View File

@ -42,7 +42,6 @@ fn condition_is_met() {
| str to-int "31/04/2020" | str to-int "31/04/2020"
| get "31/04/2020" | get "31/04/2020"
| math sum | math sum
| echo $it
"# "#
)); ));

View File

@ -15,7 +15,6 @@ fn by_column() {
| first 1 | first 1
| get Column1 | get Column1
| str trim | str trim
| echo $it
"# "#
)); ));
@ -37,7 +36,6 @@ fn by_invalid_column() {
| first 1 | first 1
| get Column1 | get Column1
| str trim | str trim
| echo $it
"# "#
)); ));
@ -73,7 +71,6 @@ fn sort_primitive_values() {
| first 6 | first 6
| sort-by | sort-by
| first 1 | first 1
| echo $it
"# "#
)); ));

View File

@ -23,7 +23,6 @@ fn splits() {
| split-by type | split-by type
| get A."10/11/2013" | get A."10/11/2013"
| count | count
| echo $it
"# "#
)); ));

View File

@ -20,7 +20,6 @@ fn to_column() {
| str trim | str trim
| split column "," | split column ","
| get Column2 | get Column2
| echo $it
"# "#
)); ));

View File

@ -20,7 +20,6 @@ fn to_row() {
| str trim | str trim
| split row "," | split row ","
| count | count
| echo $it
"# "#
)); ));

View File

@ -17,7 +17,7 @@ fn trims() {
let actual = nu!( let actual = nu!(
cwd: dirs.test(), cwd: dirs.test(),
"open sample.toml | str trim dependency.name | get dependency.name | echo $it" "open sample.toml | str trim dependency.name | get dependency.name"
); );
assert_eq!(actual.out, "nu"); assert_eq!(actual.out, "nu");
@ -50,7 +50,7 @@ fn capitalizes() {
let actual = nu!( let actual = nu!(
cwd: dirs.test(), cwd: dirs.test(),
"open sample.toml | str capitalize dependency.name | get dependency.name | echo $it" "open sample.toml | str capitalize dependency.name | get dependency.name"
); );
assert_eq!(actual.out, "Nu"); assert_eq!(actual.out, "Nu");
@ -70,7 +70,7 @@ fn downcases() {
let actual = nu!( let actual = nu!(
cwd: dirs.test(), cwd: dirs.test(),
"open sample.toml | str downcase dependency.name | get dependency.name | echo $it" "open sample.toml | str downcase dependency.name | get dependency.name"
); );
assert_eq!(actual.out, "light"); assert_eq!(actual.out, "light");
@ -90,7 +90,7 @@ fn upcases() {
let actual = nu!( let actual = nu!(
cwd: dirs.test(), cwd: dirs.test(),
"open sample.toml | str upcase package.name | get package.name | echo $it" "open sample.toml | str upcase package.name | get package.name"
); );
assert_eq!(actual.out, "NUSHELL"); assert_eq!(actual.out, "NUSHELL");
@ -110,7 +110,7 @@ fn camelcases() {
let actual = nu!( let actual = nu!(
cwd: dirs.test(), cwd: dirs.test(),
"open sample.toml | str camel-case dependency.name | get dependency.name | echo $it" "open sample.toml | str camel-case dependency.name | get dependency.name"
); );
assert_eq!(actual.out, "thisIsATest"); assert_eq!(actual.out, "thisIsATest");
@ -128,7 +128,7 @@ fn converts_to_int() {
| rename number | rename number
| where number == 1 | where number == 1
| get number | get number
| echo $it
"# "#
)); ));
@ -167,7 +167,6 @@ fn sets() {
open sample.toml open sample.toml
| str set wykittenshell package.name | str set wykittenshell package.name
| get package.name | get package.name
| echo $it
"# "#
)); ));
@ -192,7 +191,6 @@ fn find_and_replaces() {
open sample.toml open sample.toml
| str find-replace KATZ "5289" fortune.teller.phone | str find-replace KATZ "5289" fortune.teller.phone
| get fortune.teller.phone | get fortune.teller.phone
| echo $it
"# "#
)); ));
@ -217,7 +215,6 @@ fn find_and_replaces_without_passing_field() {
open sample.toml open sample.toml
| get fortune.teller.phone | get fortune.teller.phone
| str find-replace KATZ "5289" | str find-replace KATZ "5289"
| echo $it
"# "#
)); ));
@ -242,7 +239,6 @@ fn substrings_the_input() {
open sample.toml open sample.toml
| str substring 6,14 fortune.teller.phone | str substring 6,14 fortune.teller.phone
| get fortune.teller.phone | get fortune.teller.phone
| echo $it
"# "#
)); ));
@ -266,7 +262,6 @@ fn substring_errors_if_start_index_is_greater_than_end_index() {
r#" r#"
open sample.toml open sample.toml
| str substring 6,5 fortune.teller.phone | str substring 6,5 fortune.teller.phone
| echo $it
"# "#
)); ));
@ -293,7 +288,6 @@ fn substrings_the_input_and_returns_the_string_if_end_index_exceeds_length() {
open sample.toml open sample.toml
| str substring 0,999 package.name | str substring 0,999 package.name
| get package.name | get package.name
| echo $it
"# "#
)); ));
@ -318,7 +312,6 @@ fn substrings_the_input_and_returns_blank_if_start_index_exceeds_length() {
open sample.toml open sample.toml
| str substring 50,999 package.name | str substring 50,999 package.name
| get package.name | get package.name
| echo $it
"# "#
)); ));
@ -343,7 +336,6 @@ fn substrings_the_input_and_treats_start_index_as_zero_if_blank_start_index_give
open sample.toml open sample.toml
| str substring ,2 package.name | str substring ,2 package.name
| get package.name | get package.name
| echo $it
"# "#
)); ));
@ -368,7 +360,6 @@ fn substrings_the_input_and_treats_end_index_as_length_if_blank_end_index_given(
open sample.toml open sample.toml
| str substring 3, package.name | str substring 3, package.name
| get package.name | get package.name
| echo $it
"# "#
)); ));

View File

@ -23,7 +23,7 @@ fn removes_duplicate_rows() {
open los_tres_caballeros.csv open los_tres_caballeros.csv
| uniq | uniq
| count | count
| echo $it
"# "#
)); ));
@ -53,7 +53,7 @@ fn uniq_values() {
| select type | select type
| uniq | uniq
| count | count
| echo $it
"# "#
)); ));
@ -118,7 +118,7 @@ fn nested_json_structures() {
open nested_json_structures.json open nested_json_structures.json
| uniq | uniq
| count | count
| echo $it
"# "#
)); ));
assert_eq!(actual.out, "3"); assert_eq!(actual.out, "3");
@ -134,7 +134,7 @@ fn uniq_when_keys_out_of_order() {
| from json | from json
| uniq | uniq
| count | count
| echo $it
"# "#
)); ));

View File

@ -8,7 +8,6 @@ fn sets_the_column() {
open cargo_sample.toml open cargo_sample.toml
| update dev-dependencies.pretty_assertions "0.7.0" | update dev-dependencies.pretty_assertions "0.7.0"
| get dev-dependencies.pretty_assertions | get dev-dependencies.pretty_assertions
| echo $it
"# "#
)); ));
@ -24,7 +23,6 @@ fn sets_the_column_from_a_block_run_output() {
open cargo_sample.toml open cargo_sample.toml
| update dev-dependencies.pretty_assertions { open cargo_sample.toml | get dev-dependencies.pretty_assertions | inc --minor } | update dev-dependencies.pretty_assertions { open cargo_sample.toml | get dev-dependencies.pretty_assertions | inc --minor }
| get dev-dependencies.pretty_assertions | get dev-dependencies.pretty_assertions
| echo $it
"# "#
)); ));
@ -40,7 +38,6 @@ fn sets_the_column_from_a_block_full_stream_output() {
| update content { open --raw cargo_sample.toml | lines | first 5 } | update content { open --raw cargo_sample.toml | lines | first 5 }
| get content.1 | get content.1
| str contains "nu" | str contains "nu"
| echo $it
"# "#
)); ));
@ -56,7 +53,6 @@ fn sets_the_column_from_an_invocation() {
| update content $(open --raw cargo_sample.toml | lines | first 5) | update content $(open --raw cargo_sample.toml | lines | first 5)
| get content.1 | get content.1
| str contains "nu" | str contains "nu"
| echo $it
"# "#
)); ));

View File

@ -7,7 +7,7 @@ use nu_test_support::pipeline;
fn filters_by_unit_size_comparison() { fn filters_by_unit_size_comparison() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", cwd: "tests/fixtures/formats",
"ls | where size > 1kb | sort-by size | get name | first 1 | str trim | echo $it" "ls | where size > 1kb | sort-by size | get name | first 1 | str trim"
); );
assert_eq!(actual.out, "cargo_sample.toml"); assert_eq!(actual.out, "cargo_sample.toml");
@ -17,7 +17,7 @@ fn filters_by_unit_size_comparison() {
fn filters_with_nothing_comparison() { fn filters_with_nothing_comparison() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", cwd: "tests/fixtures/formats",
r#"echo '[{"foo": 3}, {"foo": null}, {"foo": 4}]' | from json | get foo | compact | where $it > 1 | math sum | echo $it"# r#"echo '[{"foo": 3}, {"foo": null}, {"foo": 4}]' | from json | get foo | compact | where $it > 1 | math sum"#
); );
assert_eq!(actual.out, "7"); assert_eq!(actual.out, "7");
@ -27,7 +27,7 @@ fn filters_with_nothing_comparison() {
fn where_in_table() { fn where_in_table() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", 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 | echo $it"# 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"); assert_eq!(actual.out, "5");
@ -37,7 +37,7 @@ fn where_in_table() {
fn where_not_in_table() { fn where_not_in_table() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", 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 | echo $it"# 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"); assert_eq!(actual.out, "4");
@ -55,7 +55,6 @@ fn explicit_block_condition() {
| first 4 | first 4
| where {= $it.z > 4200} | where {= $it.z > 4200}
| get z | get z
| echo $it
"# "#
)); ));
@ -74,7 +73,6 @@ fn binary_operator_comparisons() {
| first 4 | first 4
| where z > 4200 | where z > 4200
| get z | get z
| echo $it
"# "#
)); ));
@ -89,7 +87,6 @@ fn binary_operator_comparisons() {
| first 4 | first 4
| where z >= 4253 | where z >= 4253
| get z | get z
| echo $it
"# "#
)); ));
@ -104,7 +101,6 @@ fn binary_operator_comparisons() {
| first 4 | first 4
| where z < 10 | where z < 10
| get z | get z
| echo $it
"# "#
)); ));
@ -119,7 +115,6 @@ fn binary_operator_comparisons() {
| first 4 | first 4
| where z <= 1 | where z <= 1
| get z | get z
| echo $it
"# "#
)); ));
@ -134,7 +129,6 @@ fn binary_operator_comparisons() {
| where z != 1 | where z != 1
| first 1 | first 1
| get z | get z
| echo $it
"# "#
)); ));
@ -152,7 +146,6 @@ fn contains_operator() {
| get table_values | get table_values
| where x =~ ell | where x =~ ell
| count | count
| echo $it
"# "#
)); ));
@ -166,7 +159,6 @@ fn contains_operator() {
| get table_values | get table_values
| where x !~ ell | where x !~ ell
| count | count
| echo $it
"# "#
)); ));

View File

@ -24,7 +24,6 @@ fn wrap_rows_into_a_row() {
| get caballeros | get caballeros
| nth 0 | nth 0
| get last_name | get last_name
| echo $it
"# "#
)); ));
@ -54,7 +53,6 @@ fn wrap_rows_into_a_table() {
| wrap caballero | wrap caballero
| nth 2 | nth 2
| get caballero | get caballero
| echo $it
"# "#
)); ));

View File

@ -10,7 +10,6 @@ fn table_to_bson_and_back_into_table() {
| from bson | from bson
| get root | get root
| get 1.b | get 1.b
| echo $it
"# "#
)); ));

View File

@ -6,7 +6,7 @@ use nu_test_support::{nu, pipeline};
fn table_to_csv_text_and_from_csv_text_back_into_table() { fn table_to_csv_text_and_from_csv_text_back_into_table() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", cwd: "tests/fixtures/formats",
"open caco3_plastics.csv | to csv | from csv | first 1 | get origin | echo $it" "open caco3_plastics.csv | to csv | from csv | first 1 | get origin "
); );
assert_eq!(actual.out, "SPAIN"); assert_eq!(actual.out, "SPAIN");
@ -35,7 +35,6 @@ fn table_to_csv_text() {
| to csv | to csv
| lines | lines
| nth 1 | nth 1
| echo $it
"# "#
)); ));
@ -66,7 +65,6 @@ fn table_to_csv_text_skipping_headers_after_conversion() {
| split column "," a b c d origin | split column "," a b c d origin
| last 1 | last 1
| to csv --headerless | to csv --headerless
| echo $it
"# "#
)); ));
@ -96,7 +94,6 @@ fn infers_types() {
open los_cuatro_mosqueteros.csv open los_cuatro_mosqueteros.csv
| where rusty_luck > 0 | where rusty_luck > 0
| count | count
| echo $it
"# "#
)); ));
@ -124,7 +121,6 @@ fn from_csv_text_to_table() {
| from csv | from csv
| get rusty_luck | get rusty_luck
| count | count
| echo $it
"# "#
)); ));
@ -152,7 +148,6 @@ fn from_csv_text_with_separator_to_table() {
| from csv --separator ';' | from csv --separator ';'
| get rusty_luck | get rusty_luck
| count | count
| echo $it
"# "#
)); ));
@ -180,7 +175,6 @@ fn from_csv_text_with_tab_separator_to_table() {
| from csv --separator '\t' | from csv --separator '\t'
| get rusty_luck | get rusty_luck
| count | count
| echo $it
"# "#
)); ));
@ -207,7 +201,6 @@ fn from_csv_text_skipping_headers_to_table() {
| from csv --headerless | from csv --headerless
| get Column3 | get Column3
| count | count
| echo $it
"# "#
)); ));

View File

@ -12,7 +12,6 @@ fn from_eml_get_to_field() {
open sample.eml open sample.eml
| get To | get To
| get Address | get Address
| echo $it
"# "#
) )
); );
@ -26,7 +25,6 @@ fn from_eml_get_to_field() {
open sample.eml open sample.eml
| get To | get To
| get Name | get Name
| echo $it
"# "#
) )
); );
@ -44,7 +42,6 @@ fn from_eml_get_replyto_field() {
open sample.eml open sample.eml
| get Reply-To | get Reply-To
| get Address | get Address
| echo $it
"# "#
) )
); );
@ -58,7 +55,6 @@ fn from_eml_get_replyto_field() {
open sample.eml open sample.eml
| get Reply-To | get Reply-To
| get Name | get Name
| echo $it
"# "#
) )
); );
@ -74,7 +70,6 @@ fn from_eml_get_subject_field() {
r#" r#"
open sample.eml open sample.eml
| get Subject | get Subject
| echo $it
"# "#
) )
); );
@ -90,7 +85,6 @@ fn from_eml_get_another_header_field() {
r#" r#"
open sample.eml open sample.eml
| get MIME-Version | get MIME-Version
| echo $it
"# "#
) )
); );

View File

@ -49,7 +49,6 @@ fn infers_types() {
open calendar.ics open calendar.ics
| get events | get events
| count | count
| echo $it
"# "#
)); ));
@ -92,7 +91,6 @@ fn from_ics_text_to_table() {
| where name == "SUMMARY" | where name == "SUMMARY"
| first | first
| get value | get value
| echo $it
"# "#
)); ));

View File

@ -11,7 +11,6 @@ fn table_to_json_text_and_from_json_text_back_into_table() {
| to json | to json
| from json | from json
| get glossary.GlossDiv.GlossList.GlossEntry.GlossSee | get glossary.GlossDiv.GlossList.GlossEntry.GlossSee
| echo $it
"# "#
)); ));
@ -37,7 +36,7 @@ fn from_json_text_to_table() {
let actual = nu!( let actual = nu!(
cwd: dirs.test(), cwd: dirs.test(),
"open katz.txt | from json | get katz | get rusty_luck | count | echo $it" "open katz.txt | from json | get katz | get rusty_luck | count "
); );
assert_eq!(actual.out, "4"); assert_eq!(actual.out, "4");
@ -64,7 +63,6 @@ fn from_json_text_recognizing_objects_independently_to_table() {
| from json -o | from json -o
| where name == "GorbyPuff" | where name == "GorbyPuff"
| get rusty_luck | get rusty_luck
| echo $it
"# "#
)); ));
@ -94,7 +92,6 @@ fn table_to_json_text() {
| from json | from json
| nth 0 | nth 0
| get name | get name
| echo $it
"# "#
)); ));

View File

@ -9,7 +9,6 @@ fn from_ods_file_to_table() {
| get SalesOrders | get SalesOrders
| nth 4 | nth 4
| get Column2 | get Column2
| echo $it
"# "#
)); ));

View File

@ -13,7 +13,6 @@ fn table_to_sqlite_and_back_into_table() {
| get table_values | get table_values
| nth 2 | nth 2
| get x | get x
| echo $it
"# "#
)); ));

View File

@ -22,7 +22,6 @@ fn from_ssv_text_to_table() {
| from ssv | from ssv
| nth 0 | nth 0
| get IP | get IP
| echo $it
"# "#
)); ));
@ -50,7 +49,6 @@ fn from_ssv_text_to_table_with_separator_specified() {
| from ssv --minimum-spaces 3 | from ssv --minimum-spaces 3
| nth 0 | nth 0
| get IP | get IP
| echo $it
"# "#
)); ));
@ -77,7 +75,6 @@ fn from_ssv_text_treating_first_line_as_data_with_flag() {
| from ssv --headerless -a | from ssv --headerless -a
| first | first
| get Column1 | get Column1
| echo $it
"# "#
)); ));
@ -88,7 +85,7 @@ fn from_ssv_text_treating_first_line_as_data_with_flag() {
| from ssv --headerless | from ssv --headerless
| first | first
| get Column1 | get Column1
| echo $it
"# "#
)); ));

View File

@ -9,7 +9,6 @@ fn table_to_toml_text_and_from_toml_text_back_into_table() {
| to toml | to toml
| from toml | from toml
| get package.name | get package.name
| echo $it
"# "#
)); ));

View File

@ -6,7 +6,7 @@ use nu_test_support::{nu, pipeline};
fn table_to_tsv_text_and_from_tsv_text_back_into_table() { fn table_to_tsv_text_and_from_tsv_text_back_into_table() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", cwd: "tests/fixtures/formats",
"open caco3_plastics.tsv | to tsv | from tsv | first 1 | get origin | echo $it" "open caco3_plastics.tsv | to tsv | from tsv | first 1 | get origin"
); );
assert_eq!(actual.out, "SPAIN"); assert_eq!(actual.out, "SPAIN");
@ -16,7 +16,7 @@ fn table_to_tsv_text_and_from_tsv_text_back_into_table() {
fn table_to_tsv_text_and_from_tsv_text_back_into_table_using_csv_separator() { fn table_to_tsv_text_and_from_tsv_text_back_into_table_using_csv_separator() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats", cwd: "tests/fixtures/formats",
r"open caco3_plastics.tsv | to tsv | from csv --separator '\t' | first 1 | get origin | echo $it" r"open caco3_plastics.tsv | to tsv | from csv --separator '\t' | first 1 | get origin"
); );
assert_eq!(actual.out, "SPAIN"); assert_eq!(actual.out, "SPAIN");
@ -44,7 +44,6 @@ fn table_to_tsv_text() {
| to tsv | to tsv
| lines | lines
| nth 1 | nth 1
| echo $it
"# "#
)); ));
@ -72,7 +71,6 @@ fn table_to_tsv_text_skipping_headers_after_conversion() {
| split column "\t" a b c d origin | split column "\t" a b c d origin
| last 1 | last 1
| to tsv --headerless | to tsv --headerless
| echo $it
"# "#
)); ));
@ -100,7 +98,6 @@ fn from_tsv_text_to_table() {
| from tsv | from tsv
| get rusty_luck | get rusty_luck
| count | count
| echo $it
"# "#
)); ));
@ -127,7 +124,6 @@ fn from_tsv_text_skipping_headers_to_table() {
| from tsv --headerless | from tsv --headerless
| get Column3 | get Column3
| count | count
| echo $it
"# "#
)); ));

View File

@ -9,7 +9,6 @@ fn can_encode_and_decode_urlencoding() {
| to url | to url
| from url | from url
| get cheese | get cheese
| echo $it
"# "#
)); ));

View File

@ -36,7 +36,6 @@ fn infers_types() {
r#" r#"
open contacts.vcf open contacts.vcf
| count | count
| echo $it
"# "#
)); ));
@ -75,7 +74,6 @@ fn from_vcf_text_to_table() {
| where name == "EMAIL" | where name == "EMAIL"
| first | first
| get value | get value
| echo $it
"# "#
)); ));

View File

@ -9,7 +9,6 @@ fn from_excel_file_to_table() {
| get SalesOrders | get SalesOrders
| nth 4 | nth 4
| get Column2 | get Column2
| echo $it
"# "#
)); ));

View File

@ -9,7 +9,6 @@ fn table_to_xml_text_and_from_xml_text_back_into_table() {
| to xml | to xml
| from xml | from xml
| get rss.children.channel.children.0.item.children.0.guid.attributes.isPermaLink | get rss.children.channel.children.0.item.children.0.guid.attributes.isPermaLink
| echo $it
"# "#
)); ));

View File

@ -9,7 +9,6 @@ fn table_to_yaml_text_and_from_yaml_text_back_into_table() {
| to yaml | to yaml
| from yaml | from yaml
| get environment.global.PROJECT_NAME | get environment.global.PROJECT_NAME
| echo $it
"# "#
)); ));

View File

@ -410,7 +410,7 @@ fn parse_variable(
registry: &dyn SignatureRegistry, registry: &dyn SignatureRegistry,
) -> (SpannedExpression, Option<ParseError>) { ) -> (SpannedExpression, Option<ParseError>) {
if lite_arg.item == "$it" { if lite_arg.item == "$it" {
trace!("parsin $it"); trace!("parsing $it");
parse_full_column_path(lite_arg, registry) parse_full_column_path(lite_arg, registry)
} else { } else {
( (
@ -603,10 +603,7 @@ fn parse_interpolated_string(
}]; }];
let call = SpannedExpression { let call = SpannedExpression {
expr: Expression::Invocation(Block { expr: Expression::Invocation(Block::new(None, block, lite_arg.span)),
block,
span: lite_arg.span,
}),
span: lite_arg.span, span: lite_arg.span,
}; };
@ -1375,7 +1372,7 @@ fn parse_positional_argument(
let span = arg.span; let span = arg.span;
let mut commands = hir::Commands::new(span); let mut commands = hir::Commands::new(span);
commands.push(ClassifiedCommand::Expr(Box::new(arg))); commands.push(ClassifiedCommand::Expr(Box::new(arg)));
let mut block = hir::Block::new(span); let mut block = hir::Block::new(None, vec![], span);
block.push(commands); block.push(commands);
let arg = SpannedExpression::new(Expression::Block(block), span); let arg = SpannedExpression::new(Expression::Block(block), span);
@ -1771,7 +1768,7 @@ fn expand_shorthand_forms(
} }
pub fn classify_block(lite_block: &LiteBlock, registry: &dyn SignatureRegistry) -> ClassifiedBlock { pub fn classify_block(lite_block: &LiteBlock, registry: &dyn SignatureRegistry) -> ClassifiedBlock {
let mut block = Block::new(lite_block.span()); let mut block = Block::new(None, vec![], lite_block.span());
let mut error = None; let mut error = None;
for lite_pipeline in &lite_block.block { for lite_pipeline in &lite_block.block {
@ -1784,10 +1781,7 @@ pub fn classify_block(lite_block: &LiteBlock, registry: &dyn SignatureRegistry)
let pipeline = if let Some(vars) = vars { let pipeline = if let Some(vars) = vars {
let span = pipeline.commands.span; let span = pipeline.commands.span;
let block = hir::Block { let block = hir::Block::new(None, vec![pipeline.commands.clone()], span);
block: vec![pipeline.commands.clone()],
span,
};
let mut call = hir::Call::new( let mut call = hir::Call::new(
Box::new(SpannedExpression { Box::new(SpannedExpression {
expr: Expression::string("with-env".to_string()), expr: Expression::string("with-env".to_string()),

View File

@ -55,7 +55,7 @@ pub fn expression_to_flat_shape(e: &SpannedExpression) -> Vec<Spanned<FlatShape>
Expression::ExternalWord => vec![FlatShape::ExternalWord.spanned(e.span)], Expression::ExternalWord => vec![FlatShape::ExternalWord.spanned(e.span)],
Expression::ExternalCommand(_) => vec![FlatShape::ExternalCommand.spanned(e.span)], Expression::ExternalCommand(_) => vec![FlatShape::ExternalCommand.spanned(e.span)],
Expression::Synthetic(_) => vec![FlatShape::BareMember.spanned(e.span)], Expression::Synthetic(_) => vec![FlatShape::BareMember.spanned(e.span)],
Expression::Variable(_) => vec![FlatShape::Variable.spanned(e.span)], Expression::Variable(_, _) => vec![FlatShape::Variable.spanned(e.span)],
Expression::Binary(binary) => { Expression::Binary(binary) => {
let mut output = vec![]; let mut output = vec![];
output.append(&mut expression_to_flat_shape(&binary.left)); output.append(&mut expression_to_flat_shape(&binary.left));

View File

@ -40,14 +40,6 @@ impl InternalCommand {
), ),
} }
} }
pub fn expand_it_usage(&mut self) {
if let Some(positionals) = &mut self.args.positional {
for arg in positionals {
arg.expand_it_usage();
}
}
}
} }
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
@ -84,42 +76,6 @@ pub enum ClassifiedCommand {
Error(ParseError), Error(ParseError),
} }
impl ClassifiedCommand {
pub fn has_it_iteration(&self) -> bool {
match self {
ClassifiedCommand::Internal(command) => {
let mut result = command.args.head.has_shallow_it_usage();
if let Some(positionals) = &command.args.positional {
for arg in positionals {
result = result || arg.has_shallow_it_usage();
}
}
if let Some(named) = &command.args.named {
for arg in named.iter() {
if let NamedValue::Value(_, value) = arg.1 {
result = result || value.has_shallow_it_usage();
}
}
}
result
}
ClassifiedCommand::Expr(expr) => expr.has_shallow_it_usage(),
_ => false,
}
}
pub fn expand_it_usage(&mut self) {
match self {
ClassifiedCommand::Internal(command) => command.expand_it_usage(),
ClassifiedCommand::Expr(expr) => expr.expand_it_usage(),
_ => {}
}
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
pub struct Commands { pub struct Commands {
pub list: Vec<ClassifiedCommand>, pub list: Vec<ClassifiedCommand>,
@ -134,55 +90,28 @@ impl Commands {
pub fn push(&mut self, command: ClassifiedCommand) { pub fn push(&mut self, command: ClassifiedCommand) {
self.list.push(command); self.list.push(command);
} }
/// Convert all shallow uses of $it to `each { use of $it }`, converting each to a per-row command
pub fn expand_it_usage(&mut self) {
for idx in 0..self.list.len() {
self.list[idx].expand_it_usage();
}
for idx in 1..self.list.len() {
if self.list[idx].has_it_iteration() {
self.list[idx] = ClassifiedCommand::Internal(InternalCommand {
name: "each".to_string(),
name_span: self.span,
args: hir::Call {
head: Box::new(SpannedExpression {
expr: Expression::Synthetic(Synthetic::String(
"expanded-each".to_string(),
)),
span: self.span,
}),
named: None,
span: self.span,
positional: Some(vec![SpannedExpression {
expr: Expression::Block(Block {
block: vec![Commands {
list: vec![self.list[idx].clone()],
span: self.span,
}],
span: self.span,
}),
span: self.span,
}]),
external_redirection: ExternalRedirection::Stdout, // FIXME
},
})
}
}
}
} }
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
pub struct Block { pub struct Block {
pub params: Vec<String>,
pub block: Vec<Commands>, pub block: Vec<Commands>,
pub span: Span, pub span: Span,
} }
impl Block { impl Block {
pub fn new(span: Span) -> Block { pub fn new(params: Option<Vec<String>>, block: Vec<Commands>, span: Span) -> Block {
Block { match params {
block: vec![], Some(params) => Block {
params,
block,
span, span,
},
None => Block {
params: vec!["$it".into()],
block,
span,
},
} }
} }
@ -190,13 +119,6 @@ impl Block {
self.block.push(commands); self.block.push(commands);
} }
/// Convert all shallow uses of $it to `each { use of $it }`, converting each to a per-row command
pub fn expand_it_usage(&mut self) {
for commands in &mut self.block {
commands.expand_it_usage();
}
}
pub fn set_redirect(&mut self, external_redirection: ExternalRedirection) { pub fn set_redirect(&mut self, external_redirection: ExternalRedirection) {
if let Some(pipeline) = self.block.last_mut() { if let Some(pipeline) = self.block.last_mut() {
if let Some(command) = pipeline.list.last_mut() { if let Some(command) = pipeline.list.last_mut() {
@ -250,7 +172,7 @@ impl ExternalCommand {
.. ..
} => { } => {
let Path { head, .. } = &**path; let Path { head, .. } = &**path;
matches!(head, SpannedExpression{expr: Expression::Variable(Variable::It(_)), ..}) matches!(head, SpannedExpression{expr: Expression::Variable(x, ..), ..} if x == "$it")
} }
_ => false, _ => false,
}) })
@ -594,118 +516,6 @@ impl SpannedExpression {
_ => 0, _ => 0,
} }
} }
pub fn has_shallow_it_usage(&self) -> bool {
match &self.expr {
Expression::Binary(binary) => {
binary.left.has_shallow_it_usage() || binary.right.has_shallow_it_usage()
}
Expression::Range(range) => {
let left = if let Some(left) = &range.left {
left.has_shallow_it_usage()
} else {
false
};
let right = if let Some(right) = &range.right {
right.has_shallow_it_usage()
} else {
false
};
left || right
}
Expression::Variable(Variable::It(_)) => true,
Expression::Path(path) => path.head.has_shallow_it_usage(),
Expression::List(list) => {
for l in list {
if l.has_shallow_it_usage() {
return true;
}
}
false
}
Expression::Table(headers, cells) => {
for l in headers {
if l.has_shallow_it_usage() {
return true;
}
}
for row in cells {
for cell in row {
if cell.has_shallow_it_usage() {
return true;
}
}
}
false
}
Expression::Invocation(block) => {
for commands in block.block.iter() {
for command in commands.list.iter() {
if command.has_it_iteration() {
return true;
}
}
}
false
}
_ => false,
}
}
pub fn expand_it_usage(&mut self) {
match self {
SpannedExpression {
expr: Expression::Block(block),
..
} => {
block.expand_it_usage();
}
SpannedExpression {
expr: Expression::Invocation(block),
..
} => {
block.expand_it_usage();
}
SpannedExpression {
expr: Expression::List(list),
..
} => {
for item in list.iter_mut() {
item.expand_it_usage();
}
}
SpannedExpression {
expr: Expression::Table(headers, cells),
..
} => {
for header in headers.iter_mut() {
header.expand_it_usage();
}
for row in cells.iter_mut() {
for cell in row {
cell.expand_it_usage()
}
}
}
SpannedExpression {
expr: Expression::Path(path),
..
} => {
if let SpannedExpression {
expr: Expression::Invocation(block),
..
} = &mut path.head
{
block.expand_it_usage();
}
}
_ => {}
}
}
} }
impl std::ops::Deref for SpannedExpression { impl std::ops::Deref for SpannedExpression {
@ -745,8 +555,7 @@ impl PrettyDebugWithSource for SpannedExpression {
b::delimit("s\"", b::primitive(self.span.slice(source)), "\"").group() b::delimit("s\"", b::primitive(self.span.slice(source)), "\"").group()
} }
}, },
Expression::Variable(Variable::Other(_, _)) => b::keyword(self.span.slice(source)), Expression::Variable(_, _) => b::keyword(self.span.slice(source)),
Expression::Variable(Variable::It(_)) => b::keyword("$it"),
Expression::Binary(binary) => binary.pretty_debug(source), Expression::Binary(binary) => binary.pretty_debug(source),
Expression::Range(range) => range.pretty_debug(source), Expression::Range(range) => range.pretty_debug(source),
Expression::Block(_) => b::opaque("block"), Expression::Block(_) => b::opaque("block"),
@ -800,8 +609,7 @@ impl PrettyDebugWithSource for SpannedExpression {
Expression::Synthetic(s) => match s { Expression::Synthetic(s) => match s {
Synthetic::String(s) => b::typed("synthetic", b::primitive(format!("{:?}", s))), Synthetic::String(s) => b::typed("synthetic", b::primitive(format!("{:?}", s))),
}, },
Expression::Variable(Variable::Other(_, _)) => b::keyword(self.span.slice(source)), Expression::Variable(_, _) => b::keyword(self.span.slice(source)),
Expression::Variable(Variable::It(_)) => b::keyword("$it"),
Expression::Binary(binary) => binary.pretty_debug(source), Expression::Binary(binary) => binary.pretty_debug(source),
Expression::Range(range) => range.pretty_debug(source), Expression::Range(range) => range.pretty_debug(source),
Expression::Block(_) => b::opaque("block"), Expression::Block(_) => b::opaque("block"),
@ -841,12 +649,6 @@ impl PrettyDebugWithSource for SpannedExpression {
} }
} }
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Clone, Hash, Deserialize, Serialize)]
pub enum Variable {
It(Span),
Other(String, Span),
}
#[derive(Debug, Clone, Copy, PartialOrd, Ord, Eq, Hash, PartialEq, Deserialize, Serialize)] #[derive(Debug, Clone, Copy, PartialOrd, Ord, Eq, Hash, PartialEq, Deserialize, Serialize)]
pub enum Operator { pub enum Operator {
Equal, Equal,
@ -1039,7 +841,7 @@ pub enum Expression {
Literal(Literal), Literal(Literal),
ExternalWord, ExternalWord,
Synthetic(Synthetic), Synthetic(Synthetic),
Variable(Variable), Variable(String, Span),
Binary(Box<Binary>), Binary(Box<Binary>),
Range(Box<Range>), Range(Box<Range>),
Block(hir::Block), Block(hir::Block),
@ -1148,11 +950,7 @@ impl Expression {
} }
pub fn variable(v: String, span: Span) -> Expression { pub fn variable(v: String, span: Span) -> Expression {
if v == "$it" { Expression::Variable(v, span)
Expression::Variable(Variable::It(span))
} else {
Expression::Variable(Variable::Other(v, span))
}
} }
pub fn boolean(b: bool) -> Expression { pub fn boolean(b: bool) -> Expression {

View File

@ -5,8 +5,6 @@ use std::fmt::Debug;
use std::sync::Arc; use std::sync::Arc;
/// An evaluation scope. Scopes map variable names to Values and aid in evaluating blocks and expressions. /// An evaluation scope. Scopes map variable names to Values and aid in evaluating blocks and expressions.
/// Additionally, holds the value for the special $it variable, a variable used to refer to the value passing
/// through the pipeline at that moment
#[derive(Deserialize, Serialize, Debug, Clone)] #[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Scope { pub struct Scope {
vars: IndexMap<String, Value>, vars: IndexMap<String, Value>,
@ -63,10 +61,6 @@ impl Scope {
} }
} }
pub fn it(&self) -> Option<Value> {
self.var("$it")
}
pub fn from_env(env: IndexMap<String, String>) -> Arc<Scope> { pub fn from_env(env: IndexMap<String, String>) -> Arc<Scope> {
Arc::new(Scope { Arc::new(Scope {
vars: IndexMap::new(), vars: IndexMap::new(),
@ -75,19 +69,9 @@ impl Scope {
}) })
} }
pub fn append_it(this: Arc<Self>, it: Value) -> Arc<Scope> { pub fn append_var(this: Arc<Self>, name: impl Into<String>, value: Value) -> Arc<Scope> {
let mut vars = IndexMap::new(); let mut vars = IndexMap::new();
vars.insert("$it".into(), it); vars.insert(name.into(), value);
Arc::new(Scope {
vars,
env: IndexMap::new(),
parent: Some(this),
})
}
pub fn append_var(this: Arc<Self>, name: String, value: Value) -> Arc<Scope> {
let mut vars = IndexMap::new();
vars.insert(name, value);
Arc::new(Scope { Arc::new(Scope {
vars, vars,
env: IndexMap::new(), env: IndexMap::new(),

View File

@ -14,4 +14,4 @@ RUN rustc -Vv && cargo build --release && \
debuild -b -us -uc -i && \ debuild -b -us -uc -i && \
dpkg -i ../nu_0.2.0-1_amd64.deb && \ dpkg -i ../nu_0.2.0-1_amd64.deb && \
chsh -s /usr/bin/nu && \ chsh -s /usr/bin/nu && \
echo 'ls | get name | echo $it' | /usr/bin/nu echo 'ls | get name ' | /usr/bin/nu

View File

@ -27,7 +27,7 @@ fn by_one_with_field_passed() {
let actual = nu_with_plugins!( let actual = nu_with_plugins!(
cwd: dirs.test(), cwd: dirs.test(),
"open sample.toml | inc package.edition | get package.edition | echo $it" "open sample.toml | inc package.edition | get package.edition"
); );
assert_eq!(actual.out, "2019"); assert_eq!(actual.out, "2019");
@ -47,7 +47,7 @@ fn by_one_with_no_field_passed() {
let actual = nu_with_plugins!( let actual = nu_with_plugins!(
cwd: dirs.test(), cwd: dirs.test(),
"open sample.toml | get package.contributors | inc | echo $it" "open sample.toml | get package.contributors | inc"
); );
assert_eq!(actual.out, "3"); assert_eq!(actual.out, "3");
@ -67,7 +67,7 @@ fn semversion_major_inc() {
let actual = nu_with_plugins!( let actual = nu_with_plugins!(
cwd: dirs.test(), cwd: dirs.test(),
"open sample.toml | inc package.version -M | get package.version | echo $it" "open sample.toml | inc package.version -M | get package.version"
); );
assert_eq!(actual.out, "1.0.0"); assert_eq!(actual.out, "1.0.0");
@ -87,7 +87,7 @@ fn semversion_minor_inc() {
let actual = nu_with_plugins!( let actual = nu_with_plugins!(
cwd: dirs.test(), cwd: dirs.test(),
"open sample.toml | inc package.version --minor | get package.version | echo $it" "open sample.toml | inc package.version --minor | get package.version"
); );
assert_eq!(actual.out, "0.2.0"); assert_eq!(actual.out, "0.2.0");
@ -107,7 +107,7 @@ fn semversion_patch_inc() {
let actual = nu_with_plugins!( let actual = nu_with_plugins!(
cwd: dirs.test(), cwd: dirs.test(),
"open sample.toml | inc package.version --patch | get package.version | echo $it" "open sample.toml | inc package.version --patch | get package.version"
); );
assert_eq!(actual.out, "0.1.4"); assert_eq!(actual.out, "0.1.4");
@ -127,7 +127,7 @@ fn semversion_without_passing_field() {
let actual = nu_with_plugins!( let actual = nu_with_plugins!(
cwd: dirs.test(), cwd: dirs.test(),
"open sample.toml | get package.version | inc --patch | echo $it" "open sample.toml | get package.version | inc --patch"
); );
assert_eq!(actual.out, "0.1.4"); assert_eq!(actual.out, "0.1.4");

View File

@ -34,7 +34,7 @@ fn automatically_change_directory() {
cwd: dirs.test(), cwd: dirs.test(),
r#" r#"
autodir autodir
pwd | echo $it echo $(pwd)
"# "#
); );
@ -53,7 +53,7 @@ fn automatically_change_directory_with_trailing_slash_and_same_name_as_command()
cwd: dirs.test(), cwd: dirs.test(),
r#" r#"
cd/ cd/
pwd | echo $it pwd
"# "#
); );
@ -87,10 +87,8 @@ mod it_evaluation {
ls ls
| sort-by name | sort-by name
| get name | get name
| nu --testbin cococo $it | each { nu --testbin cococo $it | lines }
| lines
| nth 1 | nth 1
| echo $it
"# "#
)); ));
@ -114,10 +112,8 @@ mod it_evaluation {
r#" r#"
open nu_candies.txt open nu_candies.txt
| lines | lines
| nu --testbin chop $it | each { nu --testbin chop $it | lines}
| lines
| nth 1 | nth 1
| echo $it
"# "#
)); ));
@ -139,8 +135,7 @@ mod it_evaluation {
cwd: dirs.test(), pipeline( cwd: dirs.test(), pipeline(
r#" r#"
open sample.toml open sample.toml
| nu --testbin cococo $it.nu_party_venue | each { nu --testbin cococo $it.nu_party_venue }
| echo $it
"# "#
)); ));

View File

@ -1,4 +1,3 @@
use nu_test_support::fs::Stub::EmptyFile;
#[cfg(feature = "which")] #[cfg(feature = "which")]
use nu_test_support::fs::Stub::FileWithContent; use nu_test_support::fs::Stub::FileWithContent;
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
@ -25,11 +24,8 @@ fn takes_rows_of_nu_value_strings_and_pipes_it_to_stdin_of_external() {
r#" r#"
open nu_times.csv open nu_times.csv
| get origin | get origin
| ^echo $it | each { ^echo $it | nu --testbin chop | lines }
| nu --testbin chop
| lines
| nth 2 | nth 2
| echo $it
"# "#
)); ));
@ -224,54 +220,6 @@ fn autoenv() {
}) })
} }
#[test]
fn proper_it_expansion() {
Playground::setup("ls_test_1", |dirs, sandbox| {
sandbox.with_files(vec![
EmptyFile("andres.txt"),
EmptyFile("gedge.txt"),
EmptyFile("jonathan.txt"),
EmptyFile("yehuda.txt"),
]);
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
ls | sort-by name | group-by type | each { get File.name | echo $it } | to json
"#
));
assert_eq!(
actual.out,
r#"["andres.txt","gedge.txt","jonathan.txt","yehuda.txt"]"#
);
})
}
#[test]
fn it_expansion_of_list() {
let actual = nu!(
cwd: ".",
r#"
echo "foo" | echo [bar $it] | to json
"#
);
assert_eq!(actual.out, "[\"bar\",\"foo\"]");
}
#[test]
fn it_expansion_of_invocation() {
let actual = nu!(
cwd: ".",
r#"
echo $(echo "4" | echo $it | str to-int )
"#
);
assert_eq!(actual.out, "4");
}
#[test] #[test]
fn invocation_properly_redirects() { fn invocation_properly_redirects() {
let actual = nu!( let actual = nu!(
@ -289,7 +237,7 @@ fn argument_invocation() {
let actual = nu!( let actual = nu!(
cwd: ".", cwd: ".",
r#" r#"
echo "foo" | echo $(echo $it) echo "foo" | each { echo $(echo $it) }
"# "#
); );
@ -315,9 +263,8 @@ fn invocation_handles_dot() {
r#" r#"
echo $(open nu_times.csv) echo $(open nu_times.csv)
| get name | get name
| nu --testbin chop $it | each { nu --testbin chop $it | lines }
| nth 3 | nth 3
| echo $it
"# "#
)); ));
@ -330,7 +277,7 @@ fn string_interpolation_with_it() {
let actual = nu!( let actual = nu!(
cwd: ".", cwd: ".",
r#" r#"
echo "foo" | echo `{{$it}}` echo "foo" | each { echo `{{$it}}` }
"# "#
); );
@ -342,7 +289,7 @@ fn string_interpolation_with_column() {
let actual = nu!( let actual = nu!(
cwd: ".", cwd: ".",
r#" r#"
echo '{"name": "bob"}' | from json | echo `{{name}} is cool` echo [[name]; [bob]] | each { echo `{{name}} is cool` }
"# "#
); );
@ -354,7 +301,7 @@ fn string_interpolation_with_column2() {
let actual = nu!( let actual = nu!(
cwd: ".", cwd: ".",
r#" r#"
echo '{"name": "fred"}' | from json | echo `also {{name}} is cool` echo [[name]; [fred]] | each { echo `also {{name}} is cool` }
"# "#
); );
@ -366,7 +313,7 @@ fn string_interpolation_with_column3() {
let actual = nu!( let actual = nu!(
cwd: ".", cwd: ".",
r#" r#"
echo '{"name": "sally"}' | from json | echo `also {{name}}` echo [[name]; [sally]] | each { echo `also {{name}}` }
"# "#
); );
@ -378,7 +325,7 @@ fn string_interpolation_with_it_column_path() {
let actual = nu!( let actual = nu!(
cwd: ".", cwd: ".",
r#" r#"
echo '{"name": "sammie"}' | from json | echo `{{$it.name}}` echo [[name]; [sammie]] | each { echo `{{$it.name}}` }
"# "#
); );
@ -471,7 +418,7 @@ fn range_with_left_var() {
let actual = nu!( let actual = nu!(
cwd: ".", cwd: ".",
r#" r#"
echo [[size]; [3]] | echo $it.size..10 | math sum echo [[size]; [3]] | each { echo $it.size..10 } | math sum
"# "#
); );
@ -483,7 +430,7 @@ fn range_with_right_var() {
let actual = nu!( let actual = nu!(
cwd: ".", cwd: ".",
r#" r#"
echo [[size]; [30]] | echo 4..$it.size | math sum echo [[size]; [30]] | each { echo 4..$it.size } | math sum
"# "#
); );
@ -562,18 +509,6 @@ fn exclusive_range_with_mixed_types() {
assert_eq!(actual.out, "55"); assert_eq!(actual.out, "55");
} }
#[test]
fn it_expansion_of_tables() {
let actual = nu!(
cwd: ".",
r#"
echo foo | echo [[`foo {{$it}} bar`]; [`{{$it}} foo`]] | get "foo foo bar"
"#
);
assert_eq!(actual.out, "foo foo");
}
#[test] #[test]
fn table_with_commas() { fn table_with_commas() {
let actual = nu!( let actual = nu!(
@ -591,7 +526,7 @@ fn duration_overflow() {
let actual = nu!( let actual = nu!(
cwd: ".", pipeline( cwd: ".", pipeline(
r#" r#"
ls | get modified | = $it + 1000000000000000000yr ls | get modified | each { = $it + 1000000000000000000yr }
"#) "#)
); );
@ -603,7 +538,7 @@ fn date_and_duration_overflow() {
let actual = nu!( let actual = nu!(
cwd: ".", pipeline( cwd: ".", pipeline(
r#" r#"
ls | get modified | = $it + 1000000yr ls | get modified | each { = $it + 1000000yr }
"#) "#)
); );