From 84628f298d55618ba13eaa201356c23679353916 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sun, 8 Sep 2019 13:35:02 +1200 Subject: [PATCH] Finish fixing failing tests. --- src/commands/autoview.rs | 28 +++++++++++++++++++++++++++- tests/filters_test.rs | 8 ++++---- tests/tests.rs | 8 ++++++-- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/commands/autoview.rs b/src/commands/autoview.rs index f970d23e4f..adce1df402 100644 --- a/src/commands/autoview.rs +++ b/src/commands/autoview.rs @@ -58,7 +58,7 @@ pub fn autoview( } } }; - } else if is_single_text_value(&input) { + } else if is_single_origined_text_value(&input) { let text = context.get_command("textview"); if let Some(text) = text { let result = text.run(raw.with_input(input), &context.commands); @@ -73,6 +73,15 @@ pub fn autoview( } } } + } else if is_single_text_value(&input) { + for i in input { + match i.item { + Value::Primitive(Primitive::String(s)) => { + println!("{}", s); + } + _ => {} + } + } } else { let table = context.expect_command("table"); let result = table.run(raw.with_input(input), &context.commands); @@ -96,3 +105,20 @@ fn is_single_text_value(input: &Vec>) -> bool { false } } + +fn is_single_origined_text_value(input: &Vec>) -> bool { + if input.len() != 1 { + return false; + } + if let Tagged { + item: Value::Primitive(Primitive::String(_)), + tag: Tag { + origin: Some(_), .. + }, + } = input[0] + { + true + } else { + false + } +} diff --git a/tests/filters_test.rs b/tests/filters_test.rs index b44ac5c47d..b08115a9c0 100644 --- a/tests/filters_test.rs +++ b/tests/filters_test.rs @@ -35,7 +35,7 @@ fn converts_structured_table_to_csv_text() { | to-csv | lines | nth 1 - | echo "$it" + | echo $it "# )); @@ -63,7 +63,7 @@ fn converts_structured_table_to_csv_text_skipping_headers_after_conversion() { | split-column "," a b c d origin | last 1 | to-csv --headerless - | echo "$it" + | echo $it "# )); @@ -261,7 +261,7 @@ fn converts_structured_table_to_tsv_text() { | to-tsv | lines | nth 1 - | echo "$it" + | echo $it "# )); @@ -289,7 +289,7 @@ fn converts_structured_table_to_tsv_text_skipping_headers_after_conversion() { | split-column "\t" a b c d origin | last 1 | to-tsv --headerless - | echo "$it" + | echo $it "# )); diff --git a/tests/tests.rs b/tests/tests.rs index 4affb44223..f3f810eb09 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -12,9 +12,13 @@ fn pipeline_helper() { | str --to-int | sum | echo "$it" - "#); + "#, + ); - assert_eq!(actual, r#"open los_tres_amigos.txt | from-csv | get rusty_luck | str --to-int | sum | echo "$it""#); + assert_eq!( + actual, + r#"open los_tres_amigos.txt | from-csv | get rusty_luck | str --to-int | sum | echo "$it""# + ); } #[test]