From fa127ac487efe6b997760c7128ea515117c67b1f Mon Sep 17 00:00:00 2001 From: Baptiste Fontaine Date: Sun, 12 Apr 2015 12:59:32 +0200 Subject: lemon: test added Closes #38585. Signed-off-by: Xu Cheng --- Library/Formula/lemon.rb | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'Library') 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 + #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 -- cgit v1.2.3