From 4aee2f8ffa100acbf8892cc608d5c70bc47454df Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Mon, 29 Dec 2014 11:11:41 +0800 Subject: flex: add test Closes #35328. Signed-off-by: Mike McQuaid --- Library/Formula/flex.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Library/Formula') diff --git a/Library/Formula/flex.rb b/Library/Formula/flex.rb index 2eb6f096f..59ab1431e 100644 --- a/Library/Formula/flex.rb +++ b/Library/Formula/flex.rb @@ -19,4 +19,25 @@ class Flex < Formula "--prefix=#{prefix}" system "make", "install" end + + test do + (testpath/"test.flex").write <<-EOS.undent + CHAR [a-z][A-Z] + %% + {CHAR}+ printf("%s", yytext); + [ \\t\\n]+ printf("\\n"); + %% + int main() + { + yyin = stdin; + yylex(); + } + EOS + system "#{bin}/flex", "test.flex" + system ENV.cc, "lex.yy.c", "-L#{lib}", "-lfl", "-o", "test" + assert_equal shell_output("echo \"Hello World\" | ./test"), <<-EOS.undent + Hello + World + EOS + end end -- cgit v1.2.3