Struct#new behavior differs from MRI
------------------------------------

                 Key: JRUBY-1597
                 URL: http://jira.codehaus.org/browse/JRUBY-1597
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.x
         Environment: Ubuntu Linux 7.10,
ruby 1.8.5 (2007-11-21 rev 4842) [i386-jruby1.1b1]

            Reporter: Vladimir Sizikov
            Priority: Minor


Rubinius spec tests have one particular test case that verifies that 
Struct.new(), invoked with Object as a first parameter, uses Object.to_str to 
convert the object to the name. That's how MRI (and Rubinius) operate, but I 
wasn't able to find any supporting wording in the official docs.

Code:
obj = Object.new
def obj.to_str() "Foo" end
struct = Struct.new(obj)

MRI: ===>  Struct::Foo

JRuby: ===> #<Class:01x12943ac>  (anonymous struct with no name)

This leads to Rubinius spec test failure:
#> bin/mspec -t jruby spec/core/struct

Struct.new calls to_str on its first argument (constant name) FAILED
uninitialized constant Struct::Foo:
/opt/work/rubinius/./spec/core/struct/new_spec.rb:26:in `const_missing'
/opt/work/rubinius/./spec/core/struct/new_spec.rb:22:in `it'
/opt/work/rubinius/spec/mini_rspec.rb:403:in `it'
/opt/work/rubinius/./spec/core/struct/new_spec.rb:22:in `it'
/opt/work/rubinius/./spec/core/struct/new_spec.rb:22:in `describe'
/opt/work/rubinius/spec/mini_rspec.rb:399:in `describe'
/opt/work/rubinius/./spec/core/struct/new_spec.rb:4:in `describe'
/opt/work/rubinius/./spec/core/struct/new_spec.rb:4:in `load'
last_mspec.rb:11:in `load'
last_mspec.rb:1:in `each'
last_mspec.rb:6:in `each'



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to