diff options
Diffstat (limited to 'test/ruby/test_basicinstructions.rb')
| -rw-r--r-- | test/ruby/test_basicinstructions.rb | 52 |
1 files changed, 6 insertions, 46 deletions
diff --git a/test/ruby/test_basicinstructions.rb b/test/ruby/test_basicinstructions.rb index f6b69cc1e5..7e57530d72 100644 --- a/test/ruby/test_basicinstructions.rb +++ b/test/ruby/test_basicinstructions.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: false require 'test/unit' ConstTest = 3 @@ -86,9 +85,7 @@ class TestBasicInstructions < Test::Unit::TestCase s = "OK" prev = nil 3.times do - re = /#{s}/o - assert_same prev, re if prev - prev = re + assert_equal prev.object_id, (prev ||= /#{s}/o).object_id if prev end end @@ -117,6 +114,7 @@ class TestBasicInstructions < Test::Unit::TestCase assert_equal({1=>2}, {1=>2}) assert_equal({1=>2, 3=>4}, {1=>2, 3=>4}) assert_equal({1=>2, 3=>4}, {3=>4, 1=>2}) + # assert_equal({1=>2, 3=>4}, {1,2, 3,4}) # 1.9 doesn't support assert_equal({"key"=>"val"}, {"key"=>"val"}) end @@ -210,9 +208,9 @@ class TestBasicInstructions < Test::Unit::TestCase assert_raise(NameError) { a } assert_raise(NameError) { b } assert_raise(NameError) { c } - a = a = "NOT OK" - b = b = "NOT OK" - c = c = "NOT OK" + a = "NOT OK" + b = "NOT OK" + c = "NOT OK" end class Const @@ -428,9 +426,7 @@ class TestBasicInstructions < Test::Unit::TestCase end class CVarA - def self.setup - @@cv = 'CVarA@@cv' - end + @@cv = 'CVarA@@cv' def self.cv() @@cv end def self.cv=(v) @@cv = v end class << self @@ -451,7 +447,6 @@ class TestBasicInstructions < Test::Unit::TestCase end def test_class_variable - CVarA.setup assert_equal 'CVarA@@cv', CVarA.cv assert_equal 'CVarA@@cv', CVarA.cv2 assert_equal 'CVarA@@cv', CVarA.new.cv @@ -505,7 +500,6 @@ class TestBasicInstructions < Test::Unit::TestCase class OP attr_reader :x - attr_accessor :foo def x=(x) @x = x :Bug1996 @@ -606,19 +600,6 @@ class TestBasicInstructions < Test::Unit::TestCase assert_equal 4, x[0] end - def test_send_opassign - return if defined?(RUBY_ENGINE) and RUBY_ENGINE != "ruby" - - bug7773 = '[ruby-core:51821]' - x = OP.new - assert_equal 42, x.foo = 42, bug7773 - assert_equal 42, x.foo, bug7773 - assert_equal (-6), x.send(:foo=, -6), bug7773 - assert_equal (-6), x.foo, bug7773 - assert_equal :Bug1996, x.send(:x=, :case_when_setter_returns_other_value), bug7773 - assert_equal :case_when_setter_returns_other_value, x.x, bug7773 - end - def test_backref /re/ =~ 'not match' assert_nil $~ @@ -701,25 +682,4 @@ class TestBasicInstructions < Test::Unit::TestCase assert_equal [1], [1, *a] end - def test_special_const_instance_variables - assert_separately(%w(-W0), <<-INPUT, timeout: 60) - module M - def get - # we can not set instance variables on special const objects. - # However, we can access instance variables with default value (nil). - @ivar - end - end - class Integer; include M; end - class Float; include M; end - class Symbol; include M; end - class FalseClass; include M; end - class TrueClass; include M; end - class NilClass; include M; end - - [123, 1.2, :sym, false, true, nil].each{|obj| - assert_equal(nil, obj.get) - } - INPUT - end end |
