From 01ad79370f248e84d5943f6a9918abe839943fe6 Mon Sep 17 00:00:00 2001 From: aamine Date: Fri, 23 Feb 2007 09:13:49 +0000 Subject: * test/ruby/test_optimization.rb: new test (merges test_opts.rb). * yarvtest/test_opts.rb: removed. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@11831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- yarvtest/test_opts.rb | 118 -------------------------------------------------- 1 file changed, 118 deletions(-) delete mode 100644 yarvtest/test_opts.rb (limited to 'yarvtest') diff --git a/yarvtest/test_opts.rb b/yarvtest/test_opts.rb deleted file mode 100644 index 7448e294e..000000000 --- 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 - - -- cgit