diff options
author | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-23 09:13:49 +0000 |
---|---|---|
committer | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-23 09:13:49 +0000 |
commit | bcd3345136047deb36943468bc4382074b96405f (patch) | |
tree | c9d79f39602fc1c9f80eb662557cd47ae8517645 /yarvtest | |
parent | f52fd2165bae52154e2069dd35811441c6eaecac (diff) | |
download | ruby-bcd3345136047deb36943468bc4382074b96405f.tar.gz |
* test/ruby/test_optimization.rb: new test (merges test_opts.rb).
* yarvtest/test_opts.rb: removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'yarvtest')
-rw-r--r-- | yarvtest/test_opts.rb | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/yarvtest/test_opts.rb b/yarvtest/test_opts.rb deleted file mode 100644 index 7448e294e5..0000000000 --- a/yarvtest/test_opts.rb +++ /dev/null @@ -1,118 +0,0 @@ -require 'yarvtest/yarvtest' - -class TestOpt < YarvTestBase - def test_plus - ae %q{ - a, b = 1, 2 - a+b - } - ae %q{ - class Fixnum - def +(*o) - o - end - def -(*o) - o - end - end - [10+11, 100-101] - } - ae %q{ - class Float - def +(o) - self * o - end - end - - a, b = 1, 2 - a+b - } - end - - def test_opt_methdos - klasses = [[Fixnum, 2, 3], [Float, 1.1, 2.2], - [String, "abc", "def"], [Array, [1,2,3], [4, 5]], - [Hash, {:a=>1, :b=>2}, {:x=>"foo", :y=>"bar"}]] - - bin_methods = [:+, :-, :*, :/, :%, ] - one_methods = [:length, :succ, ] - ary = [] - - bin_methods.each{|m| - klasses.each{|klass, obj, arg| - str = %{ - ary = [] - if (#{obj.inspect}).respond_to? #{m.inspect} - begin - ary << (#{obj.inspect}).#{m.to_s}(#{arg.inspect}) - rescue Exception => e - ary << :error - end - end - - class #{klass} - def #{m}(o) - [#{m.inspect}, :bin, #{klass}].inspect - end - end - ary << (#{obj.inspect}).#{m.to_s}(#{arg.inspect}) - ary - } - ae str - } - } - one_methods.each{|m| - klasses.each{|klass, obj| - str = %{ - ary = [] - if (#{obj.inspect}).respond_to? #{m.inspect} - ary << (#{obj.inspect}).#{m.to_s}() - end - - class #{klass} - def #{m}() - [#{m.inspect}, self, #{klass}].inspect - end - end - ary << (#{obj.inspect}).#{m.to_s}() - ary - } - ae str - } - } - end - - def test_opt_plus - ae %q{ - temp = 2**30 - 5 - (1..5).map do - temp += 1 - [temp, temp.class] - end - } - ae %q{ - temp = -(2**30 - 5) - (1..10).map do - temp += 1 - [temp, temp.class] - end - } - end - - def test_eq - ae %q{ - class Foo - def ==(other) - true - end - end - foo = Foo.new - [1.0 == foo, - 1 == foo, - "abc" == foo, - ] - } - end -end - - |