aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula
diff options
context:
space:
mode:
authorXu Cheng2014-12-29 12:15:49 +0800
committerMike McQuaid2014-12-29 07:48:51 +0000
commitc34a3a15e28551bd22d38befbb0d543e1524e841 (patch)
tree3a9676a2c2863fa34fdd7bc6668db6dd456b68e0 /Library/Formula
parent7c51f06bb979c949c9458ad163e46777ffe367cc (diff)
downloadhomebrew-c34a3a15e28551bd22d38befbb0d543e1524e841.tar.bz2
bison: add test
Closes #35330. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Formula')
-rw-r--r--Library/Formula/bison.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/Library/Formula/bison.rb b/Library/Formula/bison.rb
index 87b2d6a95..e7a43cf09 100644
--- a/Library/Formula/bison.rb
+++ b/Library/Formula/bison.rb
@@ -18,4 +18,32 @@ class Bison < Formula
"--prefix=#{prefix}"
system "make", "install"
end
+
+ test do
+ (testpath/"test.y").write <<-EOS.undent
+ %{ #include <iostream>
+ using namespace std;
+ extern void yyerror (char *s);
+ extern int yylex ();
+ %}
+ %start prog
+ %%
+ prog: // empty
+ | prog expr '\\n' { cout << "pass"; exit(0); }
+ ;
+ expr: '(' ')'
+ | '(' expr ')'
+ | expr expr
+ ;
+ %%
+ char c;
+ void yyerror (char *s) { cout << "fail"; exit(0); }
+ int yylex () { cin.get(c); return c; }
+ int main() { yyparse(); }
+ EOS
+ system "#{bin}/bison", "test.y"
+ system ENV.cxx, "test.tab.c", "-o", "test"
+ assert_equal "pass", shell_output("echo \"((()(())))()\" | ./test")
+ assert_equal "fail", shell_output("echo \"())\" | ./test")
+ end
end