diff options
| author | Xu Cheng | 2014-12-29 12:15:49 +0800 |
|---|---|---|
| committer | Mike McQuaid | 2014-12-29 07:48:51 +0000 |
| commit | c34a3a15e28551bd22d38befbb0d543e1524e841 (patch) | |
| tree | 3a9676a2c2863fa34fdd7bc6668db6dd456b68e0 /Library/Formula | |
| parent | 7c51f06bb979c949c9458ad163e46777ffe367cc (diff) | |
| download | homebrew-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.rb | 28 |
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 |
