mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 02:55:07 +02:00
Convert more examples and tests to record!
macro (#10840)
# Description Use `record!` macro instead of defining two separate `vec!` for `cols` and `vals` when appropriate. This visually aligns the key with the value. Further more you don't have to deal with the construction of `Record { cols, vals }` so we can hide the implementation details in the future. ## State Not covering all possible commands yet, also some tests/examples are better expressed by creating cols and vals separately. # User/Developer-Facing Changes The examples and tests should read more natural. No relevant functional change # Bycatch Where I noticed it I replaced usage of `Value` constructors with `Span::test_data()` or `Span::unknown()` to the `Value::test_...` constructors. This should make things more readable and also simplify changes to the `Span` system in the future.
This commit is contained in:
committed by
GitHub
parent
7d67ca3652
commit
4b301710d3
@ -111,7 +111,7 @@ fn build_xpath(xpath_str: &str, span: Span) -> Result<sxd_xpath::XPath, LabeledE
|
||||
mod tests {
|
||||
use super::execute_xpath_query as query;
|
||||
use nu_plugin::EvaluatedCall;
|
||||
use nu_protocol::{Record, Span, Spanned, Value};
|
||||
use nu_protocol::{record, Span, Spanned, Value};
|
||||
|
||||
#[test]
|
||||
fn position_function_in_predicate() {
|
||||
@ -133,9 +133,8 @@ mod tests {
|
||||
|
||||
let actual = query("", &call, &text, Some(spanned_str)).expect("test should not fail");
|
||||
let expected = Value::list(
|
||||
vec![Value::test_record(Record {
|
||||
cols: vec!["count(//a/*[posit...".to_string()],
|
||||
vals: vec![Value::test_float(1.0)],
|
||||
vec![Value::test_record(record! {
|
||||
"count(//a/*[posit..." => Value::test_float(1.0),
|
||||
})],
|
||||
Span::test_data(),
|
||||
);
|
||||
@ -163,9 +162,8 @@ mod tests {
|
||||
|
||||
let actual = query("", &call, &text, Some(spanned_str)).expect("test should not fail");
|
||||
let expected = Value::list(
|
||||
vec![Value::test_record(Record {
|
||||
cols: vec!["count(//*[contain...".to_string()],
|
||||
vals: vec![Value::test_float(1.0)],
|
||||
vec![Value::test_record(record! {
|
||||
"count(//*[contain..." => Value::test_float(1.0),
|
||||
})],
|
||||
Span::test_data(),
|
||||
);
|
||||
|
Reference in New Issue
Block a user