Finish fixing failing tests.

This commit is contained in:
Jonathan Turner 2019-09-08 13:35:02 +12:00
parent 4cdaed1ad4
commit 84628f298d
3 changed files with 37 additions and 7 deletions

View File

@ -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"); let text = context.get_command("textview");
if let Some(text) = text { if let Some(text) = text {
let result = text.run(raw.with_input(input), &context.commands); 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 { } else {
let table = context.expect_command("table"); let table = context.expect_command("table");
let result = table.run(raw.with_input(input), &context.commands); let result = table.run(raw.with_input(input), &context.commands);
@ -96,3 +105,20 @@ fn is_single_text_value(input: &Vec<Tagged<Value>>) -> bool {
false false
} }
} }
fn is_single_origined_text_value(input: &Vec<Tagged<Value>>) -> bool {
if input.len() != 1 {
return false;
}
if let Tagged {
item: Value::Primitive(Primitive::String(_)),
tag: Tag {
origin: Some(_), ..
},
} = input[0]
{
true
} else {
false
}
}

View File

@ -35,7 +35,7 @@ fn converts_structured_table_to_csv_text() {
| to-csv | to-csv
| lines | lines
| nth 1 | 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 | split-column "," a b c d origin
| last 1 | last 1
| to-csv --headerless | to-csv --headerless
| echo "$it" | echo $it
"# "#
)); ));
@ -261,7 +261,7 @@ fn converts_structured_table_to_tsv_text() {
| to-tsv | to-tsv
| lines | lines
| nth 1 | 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 | split-column "\t" a b c d origin
| last 1 | last 1
| to-tsv --headerless | to-tsv --headerless
| echo "$it" | echo $it
"# "#
)); ));

View File

@ -12,9 +12,13 @@ fn pipeline_helper() {
| str --to-int | str --to-int
| sum | sum
| echo "$it" | 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] #[test]