Add row conditions

This commit is contained in:
JT
2021-09-10 09:47:20 +12:00
parent b821b14987
commit bb6781a3b1
11 changed files with 195 additions and 22 deletions

View File

@ -1,4 +1,4 @@
use std::{arch::x86_64::_CMP_EQ_OQ, cell::RefCell, rc::Rc};
use std::{cell::RefCell, rc::Rc};
use nu_cli::{report_parsing_error, report_shell_error, NuHighlighter};
use nu_command::create_default_context;
@ -164,7 +164,7 @@ impl Completer for EQCompleter {
let mut working_set = StateWorkingSet::new(&*engine_state);
let offset = working_set.next_span_start();
let pos = offset + pos;
let (output, err) = parse(&mut working_set, Some("completer"), line.as_bytes(), false);
let (output, _err) = parse(&mut working_set, Some("completer"), line.as_bytes(), false);
let flattened = flatten_block(&working_set, &output);

View File

@ -292,3 +292,19 @@ fn row_iteration() -> TestResult {
fn record_iteration() -> TestResult {
run_test("([[name, level]; [aa, 100], [bb, 200]] | each { $it | each { |x| if $x.column == \"level\" { $x.value + 100 } else { $x.value } } }).level", "[200, 300]")
}
#[test]
fn row_condition1() -> TestResult {
run_test(
"([[name, size]; [a, 1], [b, 2], [c, 3]] | where size < 3).name",
"[a, b]",
)
}
#[test]
fn row_condition2() -> TestResult {
run_test(
"[[name, size]; [a, 1], [b, 2], [c, 3]] | where $it.size > 2 | length",
"1",
)
}