Daniele Alessandri
2009-Aug-18 14:04 UTC
[Ironruby-core] A couple of doubts (related to Time)
Hi, I encountered a few bugs in IronRuby while running the specs for rufus-scheduler (http://github.com/jmettraux/rufus-scheduler/). I''m fixing some of them right now, but in the meanwhile I bumped into a couple of issues running the rubyspecs for the Time class: * Time.at creates a dup time object with the value given by time See http://gist.github.com/169660 . The implementation of DateTime.Create(object, DateTime) returns a new DateTime created from self, but the two instances on the "ruby side" have the same object_id. I investigated a little bit more and noticed that there is only one DateTime element in the associated _valueTypeInstanceData of the current RubyContext. Well, no wonder: DateTime is a ValueType, the two values shares the same hashcode and _valueTypeInstanceData is a Dictionary<object, RubyInstanceData>. Honestly I don''t think this poses any real problems, but still it is a different behaviour from the MRI. Thoughts? * Time.at converts to time object There was a bug in Time#at which got already fixed on my local repository, even so this spec is still failing. This time the problem is related to the rubyspecs: if you take a look at the the localtime method in rubyspec\core\time\fixtures\methods.rb (it returns the current local time from the OS), you can note that it works only for POSIX-systems. I can''t think of a good and clean way to get this fixed, hope to hear Jim''s thoughts about this one. Thanks, Daniele -- Daniele Alessandri http://www.clorophilla.net/blog/ http://twitter.com/JoL1hAHN
jirapong.nanta at gmail.com
2009-Aug-19 06:02 UTC
[Ironruby-core] A couple of doubts (related to Time)
Hello Daniele, About the DateTime in ironruby, you might encountered same problem with me. The implementation in IronRuby use .NET DateTime struct which unable to maintain reference id. I was introduce RubyDateTime class to solve this problem, but unfortunately i didn''t have time to finish it yet. My todo list: RubyDateTime.cs - Replace DateTime in the codebase - Converter.IsIntegral might need to be - override Equals, HashCode, and ToString (remember this is immutable DateTime) - Constructor as a DateTime - Make it Serializable - see msdn.com any other interfaces/attributes to propagate to - define implicit operator converting from and to DateTime so that Ruby code can pass a Ruby Time object to a CLR method that expects DateTime. - change comment "?Encapsulates DateTime and supports mutating of instances (whereas DateTime is immutable)? - Time#utc spec should be "modifies the receiver" - fix for rfc2822 spec You can find more info at - http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=1021 Bests, -Jirapong On Aug 18, 2009, at 9:04 PM, Daniele Alessandri wrote:> Hi, > I encountered a few bugs in IronRuby while running the specs for > rufus-scheduler (http://github.com/jmettraux/rufus-scheduler/). I''m > fixing some of them right now, but in the meanwhile I bumped into a > couple of issues running the rubyspecs for the Time class: > > * Time.at creates a dup time object with the value given by time > See http://gist.github.com/169660 . The implementation of > DateTime.Create(object, DateTime) returns a new DateTime created from > self, but the two instances on the "ruby side" have the same > object_id. I investigated a little bit more and noticed that there is > only one DateTime element in the associated _valueTypeInstanceData of > the current RubyContext. Well, no wonder: DateTime is a ValueType, the > two values shares the same hashcode and _valueTypeInstanceData is a > Dictionary<object, RubyInstanceData>. Honestly I don''t think this > poses any real problems, but still it is a different behaviour from > the MRI. Thoughts? > > * Time.at converts to time object > There was a bug in Time#at which got already fixed on my local > repository, even so this spec is still failing. This time the problem > is related to the rubyspecs: if you take a look at the the localtime > method in rubyspec\core\time\fixtures\methods.rb (it returns the > current local time from the OS), you can note that it works only for > POSIX-systems. I can''t think of a good and clean way to get this > fixed, hope to hear Jim''s thoughts about this one. > > Thanks, > Daniele > > -- > Daniele Alessandri > http://www.clorophilla.net/blog/ > http://twitter.com/JoL1hAHN > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core