diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-10-03 15:59:45 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-10-03 15:59:45 +0000 |
commit | ceadcc44141f598532bff6c6f6c5cf90135b1f87 (patch) | |
tree | bf8c46bbd1d9a0f993b6a4f0ec9a64a95597b459 /sample | |
parent | 46469c300eb012eb0c30520f81cd0458f4f44aeb (diff) | |
download | ruby-ceadcc44141f598532bff6c6f6c5cf90135b1f87.tar.gz ruby-ceadcc44141f598532bff6c6f6c5cf90135b1f87.tar.xz ruby-ceadcc44141f598532bff6c6f6c5cf90135b1f87.zip |
* parse.y (block_param): restrict block parameters to be local
variables only.
* test/ruby/test_iterator.rb (TestIterator::test_nested_iterator):
update test suite to conform the last change.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@11075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample')
-rw-r--r-- | sample/optparse/opttest.rb | 26 | ||||
-rw-r--r-- | sample/test.rb | 3 |
2 files changed, 15 insertions, 14 deletions
diff --git a/sample/optparse/opttest.rb b/sample/optparse/opttest.rb index 683c450d5..e2c6d1e04 100644 --- a/sample/optparse/opttest.rb +++ b/sample/optparse/opttest.rb @@ -23,49 +23,49 @@ ARGV.options do # mandatory argument opts.on("-r", "--require=LIBRARY", String, "require the LIBRARY, before", - "executing your script") {|@library|} + "executing your script") {|lib|@library=lib} # optional argument opts.on("-i", "--inplace=[EXTENSION]", "edit ARGV files in place", # multiline description - "(make backup if EXTENSION supplied)") {|@inplace| @inplace ||= ''} + "(make backup if EXTENSION supplied)") {|inplace| @inplace = inplace || ''} - opts.on("-N=[NUM]", Integer) {|@number|} + opts.on("-N=[NUM]", Integer) {|num|@number=num} # additional class - opts.on("-t", "--[no-]time[=TIME]", Time, "it's the time") {|@time|} + opts.on("-t", "--[no-]time[=TIME]", Time, "it's the time") {|time|@time=time} # limit argument syntax opts.on("-[0-7]", "-F", "--irs=[OCTAL]", OptionParser::OctalInteger, - "specify record separator", "(\\0, if no argument)") {|@irs|} + "specify record separator", "(\\0, if no argument)") {|irs|@irs=irs} # boolean switch(default true) @exec = true - opts.on("-n", "--no-exec[=FLAG]", TrueClass, "not really execute") {|@exec|} + opts.on("-n", "--no-exec[=FLAG]", TrueClass, "not really execute") {|exec|@exec=exec} # array - opts.on("-a", "--list[=LIST,LIST]", Array, "list") {|@list|} + opts.on("-a", "--list[=LIST,LIST]", Array, "list") {|list|@list=list} # fixed size array - opts.on("--pair[=car,cdr]", Array, "pair") {|@x, @y|} + opts.on("--pair[=car,cdr]", Array, "pair") {|x,y|@x=x; @y=y} # keyword completion opts.on("--code=CODE", CODES, CODE_ALIASES, "select coding system", - "("+CODES.join(",")+",", " "+CODE_ALIASES.keys.join(",")+")") {|@code|} + "("+CODES.join(",")+",", " "+CODE_ALIASES.keys.join(",")+")") {|c|@code=c} # optional argument with keyword completion - opts.on("--type[=TYPE]", [:text, :binary], "select type(text, binary)") {|@type|} + opts.on("--type[=TYPE]", [:text, :binary], "select type(text, binary)") {|t|@type=t} # boolean switch with optional argument(default false) - opts.on("-v", "--[no-]verbose=[FLAG]", "run verbosely") {|@verbose|} + opts.on("-v", "--[no-]verbose=[FLAG]", "run verbosely") {|v|@verbose=v} # easy way, set local variable - opts.on("-q", "--quit", "quit when ARGV is empty") {|@quit|} + opts.on("-q", "--quit", "quit when ARGV is empty") {|q|@quit=q} # adding on the fly opts.on("--add=SWITCH=[ARG]", "add option on the fly", /\A(\w+)(?:=.+)?\Z/) do |opt, var| - opts.on("--#{opt}", "added in runtime", &eval("proc {|@#{var}|}")) + opts.on("--#{opt}", "added in runtime", &eval("proc {|x|@#{var}=x}")) end opts.on_head("specific options:") diff --git a/sample/test.rb b/sample/test.rb index a5026d49c..a32dbcbec 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -846,8 +846,9 @@ def tt } end +i=0 tt{|i| break if i == 5} -test_ok(i == 5) +test_ok(i == 0) def tt2(dummy) yield 1 |