package net.morilib.sh;

public class ShCommandOperatorExecuteTest extends ShCommandExecuteTest {

	public void testPipe001() {
		exe("echo aaa | cat", 0);
		eot("aaa");
	}

	public void testPipe002() {
		exe("echo aaa | cat | cat", 0);
		eot("aaa");
	}

	public void testPipe003() {
		exe("echo aaa | cat | cat | cat", 0);
		eot("aaa");
	}

	public void testOperator001() {
		exe("[ aaa ] && [ bbb ]", 0);
		exe("[ aaa ] && [ \"$em\" ]", 1);
		exe("[ \"$em\" ] && [ bbb ]", 1);
		exe("[ \"$em\" ] && [ \"$em\" ]", 1);
	}

	public void testOperator002() {
		exe("[ aaa ] || [ bbb ]", 0);
		exe("[ aaa ] || [ \"$em\" ]", 0);
		exe("[ \"$em\" ] || [ bbb ]", 0);
		exe("[ \"$em\" ] || [ \"$em\" ]", 1);
	}

	public void testOperator003() {
		exe("! [ aaa ]", 1);
		exe("! [ \"$em\" ]", 0);
	}

	public void testOperator004() {
		exe("[ aaa ] && [ bbb ] || [ aaa ] && [ \"$em\" ]", 0);
		exe("! [ aaa ] && ! [ aaa ]", 1);
		exe("! [ \"$em\" ] || ! [ \"$em\" ]", 0);
		exe("! [ \"$em\" ] && [ bbb ] || ! [ \"$em\" ] && [ \"$em\" ]", 0);
	}

}
