Scripting bug fixes and more tests
This commit is contained in:
@@ -3,7 +3,9 @@ use super::super::*;
|
||||
#[test]
|
||||
fn parse_simple() {
|
||||
let input = "echo hello world";
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty()).collect();
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty())
|
||||
.map(|tk| tk.unwrap())
|
||||
.collect();
|
||||
let nodes: Vec<_> = ParseStream::new(tk_stream).collect();
|
||||
|
||||
insta::assert_debug_snapshot!(nodes)
|
||||
@@ -12,7 +14,9 @@ fn parse_simple() {
|
||||
#[test]
|
||||
fn parse_pipeline() {
|
||||
let input = "echo foo | sed s/foo/bar";
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty()).collect();
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty())
|
||||
.map(|tk| tk.unwrap())
|
||||
.collect();
|
||||
let nodes: Vec<_> = ParseStream::new(tk_stream).collect();
|
||||
|
||||
insta::assert_debug_snapshot!(nodes)
|
||||
@@ -21,7 +25,9 @@ fn parse_pipeline() {
|
||||
#[test]
|
||||
fn parse_conjunction() {
|
||||
let input = "echo foo && echo bar";
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty()).collect();
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty())
|
||||
.map(|tk| tk.unwrap())
|
||||
.collect();
|
||||
let nodes: Vec<_> = ParseStream::new(tk_stream).collect();
|
||||
|
||||
insta::assert_debug_snapshot!(nodes)
|
||||
@@ -30,7 +36,9 @@ fn parse_conjunction() {
|
||||
#[test]
|
||||
fn parse_conjunction_and_pipeline() {
|
||||
let input = "echo foo | sed s/foo/bar/ && echo bar | sed s/bar/foo/ || echo foo bar | sed s/foo bar/bar foo/";
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty()).collect();
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty())
|
||||
.map(|tk| tk.unwrap())
|
||||
.collect();
|
||||
let nodes: Vec<_> = ParseStream::new(tk_stream).collect();
|
||||
|
||||
insta::assert_debug_snapshot!(nodes)
|
||||
@@ -42,7 +50,90 @@ fn parse_multiline() {
|
||||
echo hello world
|
||||
echo foo bar
|
||||
echo boo biz";
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty()).collect();
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty())
|
||||
.map(|tk| tk.unwrap())
|
||||
.collect();
|
||||
let nodes: Vec<_> = ParseStream::new(tk_stream).collect();
|
||||
|
||||
insta::assert_debug_snapshot!(nodes)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_if_simple() {
|
||||
let input = "if foo; then echo bar; fi";
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty())
|
||||
.map(|tk| tk.unwrap())
|
||||
.collect();
|
||||
let nodes: Vec<_> = ParseStream::new(tk_stream).collect();
|
||||
|
||||
insta::assert_debug_snapshot!(nodes)
|
||||
}
|
||||
#[test]
|
||||
fn parse_if_with_elif() {
|
||||
let input = "if foo; then echo bar; elif bar; then echo foo; fi";
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty())
|
||||
.map(|tk| tk.unwrap())
|
||||
.collect();
|
||||
let nodes: Vec<_> = ParseStream::new(tk_stream).collect();
|
||||
|
||||
insta::assert_debug_snapshot!(nodes)
|
||||
}
|
||||
#[test]
|
||||
fn parse_if_multiple_elif() {
|
||||
let input = "if foo; then echo bar; elif bar; then echo foo; elif biz; then echo baz; fi";
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty())
|
||||
.map(|tk| tk.unwrap())
|
||||
.collect();
|
||||
let nodes: Vec<_> = ParseStream::new(tk_stream).collect();
|
||||
|
||||
insta::assert_debug_snapshot!(nodes)
|
||||
}
|
||||
#[test]
|
||||
fn parse_if_multiline() {
|
||||
let input = "
|
||||
if foo; then
|
||||
echo bar
|
||||
elif bar; then
|
||||
echo foo;
|
||||
elif biz; then
|
||||
echo baz
|
||||
fi";
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty())
|
||||
.map(|tk| tk.unwrap())
|
||||
.collect();
|
||||
let nodes: Vec<_> = ParseStream::new(tk_stream).collect();
|
||||
|
||||
insta::assert_debug_snapshot!(nodes)
|
||||
}
|
||||
#[test]
|
||||
fn parse_loop_simple() {
|
||||
let input = "while foo; do bar; done";
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty())
|
||||
.map(|tk| tk.unwrap())
|
||||
.collect();
|
||||
let nodes: Vec<_> = ParseStream::new(tk_stream).collect();
|
||||
|
||||
insta::assert_debug_snapshot!(nodes)
|
||||
}
|
||||
#[test]
|
||||
fn parse_loop_until() {
|
||||
let input = "until foo; do bar; done";
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty())
|
||||
.map(|tk| tk.unwrap())
|
||||
.collect();
|
||||
let nodes: Vec<_> = ParseStream::new(tk_stream).collect();
|
||||
|
||||
insta::assert_debug_snapshot!(nodes)
|
||||
}
|
||||
#[test]
|
||||
fn parse_loop_multiline() {
|
||||
let input = "
|
||||
until foo; do
|
||||
bar
|
||||
done";
|
||||
let tk_stream: Vec<_> = LexStream::new(input, LexFlags::empty())
|
||||
.map(|tk| tk.unwrap())
|
||||
.collect();
|
||||
let nodes: Vec<_> = ParseStream::new(tk_stream).collect();
|
||||
|
||||
insta::assert_debug_snapshot!(nodes)
|
||||
|
||||
Reference in New Issue
Block a user