aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/lemon.rb
diff options
context:
space:
mode:
authorBaptiste Fontaine2015-04-12 12:59:32 +0200
committerXu Cheng2015-04-12 19:51:18 +0800
commitfa127ac487efe6b997760c7128ea515117c67b1f (patch)
tree30f6f2251894bf19f10a3e24632cdbeaf9537c2a /Library/Formula/lemon.rb
parent447dfe45b6b8f847d3cb67ffc032346384ee646b (diff)
downloadhomebrew-fa127ac487efe6b997760c7128ea515117c67b1f.tar.bz2
lemon: test added
Closes #38585. Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library/Formula/lemon.rb')
-rw-r--r--Library/Formula/lemon.rb36
1 files changed, 27 insertions, 9 deletions
diff --git a/Library/Formula/lemon.rb b/Library/Formula/lemon.rb
index 438569888..22f65af3e 100644
--- a/Library/Formula/lemon.rb
+++ b/Library/Formula/lemon.rb
@@ -1,17 +1,35 @@
-require 'formula'
-
class Lemon < Formula
- homepage 'http://www.hwaci.com/sw/lemon/'
- url 'http://tx97.net/pub/distfiles/lemon-1.69.tar.bz2'
- sha1 '3f368f5f93c37890a025c3d803b3598a939d615f'
+ homepage "http://www.hwaci.com/sw/lemon/"
+ url "http://tx97.net/pub/distfiles/lemon-1.69.tar.bz2"
+ sha256 "bc7c1cae233b6af48f4b436ee900843106a15bdb1dc810bc463d8c6aad0dd916"
def install
- (share/'lemon').install 'lempar.c'
+ (share/"lemon").install "lempar.c"
# patch the parser generator to look for the 'lempar.c' template file where we've installed it
- inreplace 'lemon.c', / = pathsearch\([^)]*\);/, " = \"#{share}/lemon/lempar.c\";"
+ inreplace "lemon.c", / = pathsearch\([^)]*\);/, " = \"#{share}/lemon/lempar.c\";"
+
+ system ENV.cc, "-o", "lemon", "lemon.c"
+ bin.install "lemon"
+ end
+
+ test do
+ (testpath/"gram.y").write <<-EOS.undent
+ %token_type {int}
+ %left PLUS.
+ %include {
+ #include <iostream>
+ #include "example1.h"
+ }
+ %syntax_error {
+ std::cout << "Syntax error!" << std::endl;
+ }
+ program ::= expr(A). { std::cout << "Result=" << A << std::endl; }
+ expr(A) ::= expr(B) PLUS expr(C). { A = B + C; }
+ expr(A) ::= INTEGER(B). { A = B; }
+ EOS
- system ENV.cc, '-o', 'lemon', 'lemon.c'
- bin.install 'lemon'
+ system "#{bin}/lemon", "gram.y"
+ assert File.exist? "gram.c"
end
end