mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
get rid of ambiguous parentheses warnings
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
db31f2fafb
commit
716610ae56
12 changed files with 33 additions and 33 deletions
|
@ -3,7 +3,7 @@
|
||||||
# Contributed by Sokolov Yura
|
# Contributed by Sokolov Yura
|
||||||
|
|
||||||
$last = 42.0
|
$last = 42.0
|
||||||
def gen_random (max,im=139968,ia=3877,ic=29573)
|
def gen_random(max, im=139968, ia=3877, ic=29573)
|
||||||
(max * ($last = ($last * ia + ic) % im)) / im
|
(max * ($last = ($last * ia + ic) % im)) / im
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
2
benchmark/bm_so_meteor_contest.rb
Normal file → Executable file
2
benchmark/bm_so_meteor_contest.rb
Normal file → Executable file
|
@ -155,7 +155,7 @@ class Rotation
|
||||||
|
|
||||||
# given a set of directions places the piece (as defined by a set of directions) on the board at
|
# given a set of directions places the piece (as defined by a set of directions) on the board at
|
||||||
# a location that will not take it off the edge
|
# a location that will not take it off the edge
|
||||||
def get_values ( directions )
|
def get_values( directions )
|
||||||
start = start_adjust(directions)
|
start = start_adjust(directions)
|
||||||
values = [ start ]
|
values = [ start ]
|
||||||
directions.each do | direction |
|
directions.each do | direction |
|
||||||
|
|
|
@ -38,7 +38,7 @@ end
|
||||||
|
|
||||||
class Transformation
|
class Transformation
|
||||||
attr_reader :q, :r, :s, :t
|
attr_reader :q, :r, :s, :t
|
||||||
def initialize (q, r, s, t)
|
def initialize(q, r, s, t)
|
||||||
@q,@r,@s,@t,@k = q,r,s,t,0
|
@q,@r,@s,@t,@k = q,r,s,t,0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ class Matrix
|
||||||
|
|
||||||
# Returns +true+ if +U+, and hence +A+, is singular.
|
# Returns +true+ if +U+, and hence +A+, is singular.
|
||||||
|
|
||||||
def singular? ()
|
def singular?
|
||||||
@column_count.times do |j|
|
@column_count.times do |j|
|
||||||
if (@lu[j][j] == 0)
|
if (@lu[j][j] == 0)
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -47,7 +47,7 @@ class Shell #:nodoc:
|
||||||
#
|
#
|
||||||
# Inputs from +source+, which is either a string of a file name or an IO
|
# Inputs from +source+, which is either a string of a file name or an IO
|
||||||
# object.
|
# object.
|
||||||
def < (src)
|
def <(src)
|
||||||
case src
|
case src
|
||||||
when String
|
when String
|
||||||
cat = Cat.new(@shell, src)
|
cat = Cat.new(@shell, src)
|
||||||
|
@ -65,7 +65,7 @@ class Shell #:nodoc:
|
||||||
#
|
#
|
||||||
# Outputs from +source+, which is either a string of a file name or an IO
|
# Outputs from +source+, which is either a string of a file name or an IO
|
||||||
# object.
|
# object.
|
||||||
def > (to)
|
def >(to)
|
||||||
case to
|
case to
|
||||||
when String
|
when String
|
||||||
dst = @shell.open(to, "w")
|
dst = @shell.open(to, "w")
|
||||||
|
@ -87,7 +87,7 @@ class Shell #:nodoc:
|
||||||
#
|
#
|
||||||
# Appends the output to +source+, which is either a string of a file name
|
# Appends the output to +source+, which is either a string of a file name
|
||||||
# or an IO object.
|
# or an IO object.
|
||||||
def >> (to)
|
def >>(to)
|
||||||
begin
|
begin
|
||||||
Shell.cd(@shell.pwd).append(to, self)
|
Shell.cd(@shell.pwd).append(to, self)
|
||||||
rescue CantApplyMethod
|
rescue CantApplyMethod
|
||||||
|
@ -99,7 +99,7 @@ class Shell #:nodoc:
|
||||||
# | filter
|
# | filter
|
||||||
#
|
#
|
||||||
# Processes a pipeline.
|
# Processes a pipeline.
|
||||||
def | (filter)
|
def |(filter)
|
||||||
filter.input = self
|
filter.input = self
|
||||||
if active?
|
if active?
|
||||||
@shell.process_controller.start_job filter
|
@shell.process_controller.start_job filter
|
||||||
|
@ -111,7 +111,7 @@ class Shell #:nodoc:
|
||||||
# filter1 + filter2
|
# filter1 + filter2
|
||||||
#
|
#
|
||||||
# Outputs +filter1+, and then +filter2+ using Join.new
|
# Outputs +filter1+, and then +filter2+ using Join.new
|
||||||
def + (filter)
|
def +(filter)
|
||||||
Join.new(@shell, self, filter)
|
Join.new(@shell, self, filter)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,15 +5,15 @@ ECHO = 0x00000008
|
||||||
TIOCGETP = 0x40067408
|
TIOCGETP = 0x40067408
|
||||||
TIOCSETP = 0x80067409
|
TIOCSETP = 0x80067409
|
||||||
|
|
||||||
def cbreak ()
|
def cbreak
|
||||||
set_cbreak(true)
|
set_cbreak(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def cooked ()
|
def cooked
|
||||||
set_cbreak(false)
|
set_cbreak(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_cbreak (on)
|
def set_cbreak(on)
|
||||||
tty = "\0" * 256
|
tty = "\0" * 256
|
||||||
STDIN.ioctl(TIOCGETP, tty)
|
STDIN.ioctl(TIOCGETP, tty)
|
||||||
ttys = tty.unpack("C4 S")
|
ttys = tty.unpack("C4 S")
|
||||||
|
|
|
@ -35,7 +35,7 @@ TestComprehensiveCaseFold.data_files_available? and class TestComprehensiveCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.read_data_file (filename)
|
def self.read_data_file(filename)
|
||||||
IO.foreach(expand_filename(filename), encoding: Encoding::ASCII_8BIT) do |line|
|
IO.foreach(expand_filename(filename), encoding: Encoding::ASCII_8BIT) do |line|
|
||||||
if $. == 1
|
if $. == 1
|
||||||
if filename == 'UnicodeData'
|
if filename == 'UnicodeData'
|
||||||
|
@ -140,7 +140,7 @@ TestComprehensiveCaseFold.data_files_available? and class TestComprehensiveCase
|
||||||
@@tests ||= []
|
@@tests ||= []
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.generate_unicode_case_mapping_tests (encoding)
|
def self.generate_unicode_case_mapping_tests(encoding)
|
||||||
all_tests.each do |test|
|
all_tests.each do |test|
|
||||||
attributes = test.attributes.map(&:to_s).join '-'
|
attributes = test.attributes.map(&:to_s).join '-'
|
||||||
attributes.prepend '_' unless attributes.empty?
|
attributes.prepend '_' unless attributes.empty?
|
||||||
|
@ -158,7 +158,7 @@ TestComprehensiveCaseFold.data_files_available? and class TestComprehensiveCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.generate_case_mapping_tests (encoding)
|
def self.generate_case_mapping_tests(encoding)
|
||||||
all_tests
|
all_tests
|
||||||
# preselect codepoints to speed up testing for small encodings
|
# preselect codepoints to speed up testing for small encodings
|
||||||
codepoints = @@codepoints.select do |code|
|
codepoints = @@codepoints.select do |code|
|
||||||
|
@ -200,7 +200,7 @@ TestComprehensiveCaseFold.data_files_available? and class TestComprehensiveCase
|
||||||
end
|
end
|
||||||
|
|
||||||
# test for encodings that don't yet (or will never) deal with non-ASCII characters
|
# test for encodings that don't yet (or will never) deal with non-ASCII characters
|
||||||
def self.generate_ascii_only_case_mapping_tests (encoding)
|
def self.generate_ascii_only_case_mapping_tests(encoding)
|
||||||
all_tests
|
all_tests
|
||||||
# preselect codepoints to speed up testing for small encodings
|
# preselect codepoints to speed up testing for small encodings
|
||||||
codepoints = @@codepoints.select do |code|
|
codepoints = @@codepoints.select do |code|
|
||||||
|
|
|
@ -3,21 +3,21 @@
|
||||||
require "test/unit"
|
require "test/unit"
|
||||||
|
|
||||||
class TestCaseOptions < Test::Unit::TestCase
|
class TestCaseOptions < Test::Unit::TestCase
|
||||||
def assert_raise_functional_operations (arg, *options)
|
def assert_raise_functional_operations(arg, *options)
|
||||||
assert_raise(ArgumentError) { arg.upcase(*options) }
|
assert_raise(ArgumentError) { arg.upcase(*options) }
|
||||||
assert_raise(ArgumentError) { arg.downcase(*options) }
|
assert_raise(ArgumentError) { arg.downcase(*options) }
|
||||||
assert_raise(ArgumentError) { arg.capitalize(*options) }
|
assert_raise(ArgumentError) { arg.capitalize(*options) }
|
||||||
assert_raise(ArgumentError) { arg.swapcase(*options) }
|
assert_raise(ArgumentError) { arg.swapcase(*options) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_raise_bang_operations (arg, *options)
|
def assert_raise_bang_operations(arg, *options)
|
||||||
assert_raise(ArgumentError) { arg.upcase!(*options) }
|
assert_raise(ArgumentError) { arg.upcase!(*options) }
|
||||||
assert_raise(ArgumentError) { arg.downcase!(*options) }
|
assert_raise(ArgumentError) { arg.downcase!(*options) }
|
||||||
assert_raise(ArgumentError) { arg.capitalize!(*options) }
|
assert_raise(ArgumentError) { arg.capitalize!(*options) }
|
||||||
assert_raise(ArgumentError) { arg.swapcase!(*options) }
|
assert_raise(ArgumentError) { arg.swapcase!(*options) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_raise_both_types (*options)
|
def assert_raise_both_types(*options)
|
||||||
assert_raise_functional_operations 'a', *options
|
assert_raise_functional_operations 'a', *options
|
||||||
assert_raise_bang_operations 'a', *options
|
assert_raise_bang_operations 'a', *options
|
||||||
assert_raise_functional_operations :a, *options
|
assert_raise_functional_operations :a, *options
|
||||||
|
@ -35,21 +35,21 @@ class TestCaseOptions < Test::Unit::TestCase
|
||||||
assert_raise_both_types :lithuanian, :ascii
|
assert_raise_both_types :lithuanian, :ascii
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_okay_functional_operations (arg, *options)
|
def assert_okay_functional_operations(arg, *options)
|
||||||
assert_nothing_raised { arg.upcase(*options) }
|
assert_nothing_raised { arg.upcase(*options) }
|
||||||
assert_nothing_raised { arg.downcase(*options) }
|
assert_nothing_raised { arg.downcase(*options) }
|
||||||
assert_nothing_raised { arg.capitalize(*options) }
|
assert_nothing_raised { arg.capitalize(*options) }
|
||||||
assert_nothing_raised { arg.swapcase(*options) }
|
assert_nothing_raised { arg.swapcase(*options) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_okay_bang_operations (arg, *options)
|
def assert_okay_bang_operations(arg, *options)
|
||||||
assert_nothing_raised { arg.upcase!(*options) }
|
assert_nothing_raised { arg.upcase!(*options) }
|
||||||
assert_nothing_raised { arg.downcase!(*options) }
|
assert_nothing_raised { arg.downcase!(*options) }
|
||||||
assert_nothing_raised { arg.capitalize!(*options) }
|
assert_nothing_raised { arg.capitalize!(*options) }
|
||||||
assert_nothing_raised { arg.swapcase!(*options) }
|
assert_nothing_raised { arg.swapcase!(*options) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_okay_both_types (*options)
|
def assert_okay_both_types(*options)
|
||||||
assert_okay_functional_operations 'a', *options
|
assert_okay_functional_operations 'a', *options
|
||||||
assert_okay_bang_operations 'a', *options
|
assert_okay_bang_operations 'a', *options
|
||||||
assert_okay_functional_operations :a, *options
|
assert_okay_functional_operations :a, *options
|
||||||
|
|
|
@ -434,7 +434,7 @@ class Complex_Test < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
class ObjectX
|
class ObjectX
|
||||||
def + (x) Rational(1) end
|
def +(x) Rational(1) end
|
||||||
alias - +
|
alias - +
|
||||||
alias * +
|
alias * +
|
||||||
alias / +
|
alias / +
|
||||||
|
|
|
@ -214,10 +214,10 @@ class SimpleRat < Numeric
|
||||||
def numerator() @num end
|
def numerator() @num end
|
||||||
def denominator() @den end
|
def denominator() @den end
|
||||||
|
|
||||||
def +@ () self end
|
def +@() self end
|
||||||
def -@ () self.class.new(-@num, @den) end
|
def -@() self.class.new(-@num, @den) end
|
||||||
|
|
||||||
def + (o)
|
def +(o)
|
||||||
case o
|
case o
|
||||||
when SimpleRat, Rational
|
when SimpleRat, Rational
|
||||||
a = @num * o.denominator
|
a = @num * o.denominator
|
||||||
|
@ -233,7 +233,7 @@ class SimpleRat < Numeric
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def - (o)
|
def -(o)
|
||||||
case o
|
case o
|
||||||
when SimpleRat, Rational
|
when SimpleRat, Rational
|
||||||
a = @num * o.denominator
|
a = @num * o.denominator
|
||||||
|
@ -249,7 +249,7 @@ class SimpleRat < Numeric
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def * (o)
|
def *(o)
|
||||||
case o
|
case o
|
||||||
when SimpleRat, Rational
|
when SimpleRat, Rational
|
||||||
a = @num * o.numerator
|
a = @num * o.numerator
|
||||||
|
@ -334,7 +334,7 @@ class SimpleRat < Numeric
|
||||||
def divmod(o) [div(o), modulo(o)] end
|
def divmod(o) [div(o), modulo(o)] end
|
||||||
def quotrem(o) [quot(o), remainder(o)] end
|
def quotrem(o) [quot(o), remainder(o)] end
|
||||||
|
|
||||||
def ** (o)
|
def **(o)
|
||||||
case o
|
case o
|
||||||
when SimpleRat, Rational
|
when SimpleRat, Rational
|
||||||
Float(self) ** o
|
Float(self) ** o
|
||||||
|
@ -357,7 +357,7 @@ class SimpleRat < Numeric
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def <=> (o)
|
def <=>(o)
|
||||||
case o
|
case o
|
||||||
when SimpleRat, Rational
|
when SimpleRat, Rational
|
||||||
a = @num * o.denominator
|
a = @num * o.denominator
|
||||||
|
@ -373,7 +373,7 @@ class SimpleRat < Numeric
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def == (o)
|
def ==(o)
|
||||||
begin
|
begin
|
||||||
(self <=> o) == 0
|
(self <=> o) == 0
|
||||||
rescue
|
rescue
|
||||||
|
|
|
@ -567,7 +567,7 @@ class Rational_Test < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
class ObjectX
|
class ObjectX
|
||||||
def + (x) Rational(1) end
|
def +(x) Rational(1) end
|
||||||
alias - +
|
alias - +
|
||||||
alias * +
|
alias * +
|
||||||
alias / +
|
alias / +
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
require "optparse"
|
require "optparse"
|
||||||
|
|
||||||
def set_argument (argname, nth)
|
def set_argument(argname, nth)
|
||||||
# remove C style type info
|
# remove C style type info
|
||||||
argname.gsub!(/.+ (.+)/, '\1') # e.g. char *hoge -> *hoge
|
argname.gsub!(/.+ (.+)/, '\1') # e.g. char *hoge -> *hoge
|
||||||
argname.gsub!(/^\*/, '') # e.g. *filename -> filename
|
argname.gsub!(/^\*/, '') # e.g. *filename -> filename
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue