Skip to content

Commit

Permalink
Merge pull request #160 from yui-knk/h_option_test
Browse files Browse the repository at this point in the history
`h` option test
  • Loading branch information
yui-knk authored Oct 26, 2023
2 parents 281731d + 6e9e47a commit 8f92936
Showing 1 changed file with 27 additions and 34 deletions.
61 changes: 27 additions & 34 deletions spec/lrama/option_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,40 @@

describe "help option" do
it "print help and exit" do
result = Open3.popen3("ruby", exe_path("lrama"), "--help") do |stdin, stdout, stderr, wait_thr|
stdout.read
end
expect(result).to eq(<<~HELP)
Lrama is LALR (1) parser generator written by Ruby.
["--help", "-h"].each do |help|
result = Open3.popen3("ruby", exe_path("lrama"), help) do |stdin, stdout, stderr, wait_thr|
stdout.read
end
expect(result).to eq(<<~HELP)
Lrama is LALR (1) parser generator written by Ruby.
Usage: lrama [options] FILE
Usage: lrama [options] FILE
STDIN mode:
lrama [options] - FILE read grammar from STDIN
STDIN mode:
lrama [options] - FILE read grammar from STDIN
Tuning the Parser:
-S, --skeleton=FILE specify the skeleton to use
-t reserved, do nothing
Tuning the Parser:
-S, --skeleton=FILE specify the skeleton to use
-t reserved, do nothing
Output:
-H, --header=[FILE] also produce a header file named FILE
-d also produce a header file
-r, --report=THINGS also produce details on the automaton
--report-file=FILE also produce details on the automaton output to a file named FILE
-o, --output=FILE leave output to FILE
--trace=THINGS also output trace logs at runtime
-v reserved, do nothing
Output:
-H, --header=[FILE] also produce a header file named FILE
-d also produce a header file
-r, --report=THINGS also produce details on the automaton
--report-file=FILE also produce details on the automaton output to a file named FILE
-o, --output=FILE leave output to FILE
--trace=THINGS also output trace logs at runtime
-v reserved, do nothing
Error Recovery:
-e enable error recovery
Error Recovery:
-e enable error recovery
Other options:
-V, --version output version information and exit
-h, --help display this help and exit
Other options:
-V, --version output version information and exit
-h, --help display this help and exit
HELP
HELP
end
end
end

Expand Down Expand Up @@ -145,15 +147,6 @@
end
end

context "deprecated outfile option is passed" do
it "@header_file is set based on outfile" do
option_parser = Lrama::OptionParser.new
option_parser.send(:parse, ["-h", "-o", "parse.c", "-", "test.y"])
options = option_parser.instance_variable_get(:@options)
expect(options.header_file).to eq "./parse.h"
end
end

context "outfile option is not passed" do
it "@header_file is set based on outfile default value" do
option_parser = Lrama::OptionParser.new
Expand Down

0 comments on commit 8f92936

Please sign in to comment.