require_relative '../spec_helper' describe "The -n command line option" do before :each do @names = fixture __FILE__, "names.txt" end it "runs the code in loop conditional on Kernel.gets()" do ruby_exe("puts $_", options: "-n", escape: true, args: " < #{@names}").should == "alice\nbob\njames\n" end it "only evaluates BEGIN blocks once" do ruby_exe("BEGIN { puts \"hi\" }; puts $_", options: "-n", escape: true, args: " < #{@names}").should == "hi\nalice\nbob\njames\n" end it "only evaluates END blocks once" do ruby_exe("puts $_; END {puts \"bye\"}", options: "-n", escape: true, args: " < #{@names}").should == "alice\nbob\njames\nbye\n" end it "allows summing over a whole file" do script = <<-script BEGIN { $total = 0 } $total += 1 END { puts $total } script ruby_exe(script, options: "-n", escape: true, args: " < #{@names}").should == "3\n" end end ion value='ruby_1_9_2'>ruby_1_9_2 The Ruby Programming Language
summaryrefslogtreecommitdiff
path: root/test/json
AgeCommit message (Expand)Author
2020-03-24test/json/test_helper.rb: Do not add a relative path to $LOAD_PATHYusuke Endoh
2019-12-12Import json-2.3.0 from flori/jsonHiroshi SHIBATA
2019-11-29Skip useless testNobuyoshi Nakada
2019-10-17Look up constant instead of caching in a globalAaron Patterson
2019-10-14[flori/json] fix test as reported in #343Florian Frank
2019-10-14[flori/json] Fixed unexpected illegal/malformed utf-8 errorNobuyoshi Nakada
2019-06-01Ignore warnings about ambiguous first argument with the negative integer.Hiroshi SHIBATA
2019-06-01Ignore warnings about ambiguous first argument of regexp with assert match.Hiroshi SHIBATA
2019-02-23Merge json-2.2.0 from flori/json.hsbt
2018-12-02Fix JSON::Parser against bigdecimal updatesmrkn