Revision: 2912 http://trac.macosforge.org/projects/ruby/changeset/2912 Author: neeracher@apple.com Date: 2009-10-28 18:34:27 -0700 (Wed, 28 Oct 2009) Log Message: ----------- Make remaining to_yaml test cases work. Defined new failing test for Struct functionality (seems to fail in mspec only) Modified Paths: -------------- MacRuby/trunk/ext/libyaml/emitter.c MacRuby/trunk/lib/yaml/rubytypes.rb MacRuby/trunk/spec/frozen/core/struct/new_spec.rb MacRuby/trunk/spec/frozen/library/yaml/to_yaml_spec.rb MacRuby/trunk/spec/frozen/tags/macruby/core/struct/new_tags.txt Removed Paths: ------------- MacRuby/trunk/spec/frozen/tags/macruby/library/yaml/to_yaml_tags.txt Modified: MacRuby/trunk/ext/libyaml/emitter.c =================================================================== --- MacRuby/trunk/ext/libyaml/emitter.c 2009-10-29 00:38:58 UTC (rev 2911) +++ MacRuby/trunk/ext/libyaml/emitter.c 2009-10-29 01:34:27 UTC (rev 2912) @@ -556,7 +556,9 @@ yaml_tag_directive_t default_tag_directives[] = { {(yaml_char_t *)"!", (yaml_char_t *)"!"}, {(yaml_char_t *)"!!", (yaml_char_t *)"tag:yaml.org,2002:"}, - {NULL, NULL} + /* MN To match ruby specs. Not 100% sure if such an implicit directive is legal YAML. */ + {(yaml_char_t *)"!ruby/", (yaml_char_t *)"tag:ruby.yaml.org,2002:"}, + {NULL, NULL} }; yaml_tag_directive_t *tag_directive; int implicit; Modified: MacRuby/trunk/lib/yaml/rubytypes.rb =================================================================== --- MacRuby/trunk/lib/yaml/rubytypes.rb 2009-10-29 00:38:58 UTC (rev 2911) +++ MacRuby/trunk/lib/yaml/rubytypes.rb 2009-10-29 01:34:27 UTC (rev 2912) @@ -65,7 +65,7 @@ YAML::quick_emit(output) do |out| out.map(taguri, to_yaml_style) do |map| members.each do |m| - out.add(m, self[m]) + out.add(m.to_s, self[m]) end end end @@ -104,6 +104,8 @@ end end end + + def taguri; "!ruby/exception:#{self.class}"; end end class Array Modified: MacRuby/trunk/spec/frozen/core/struct/new_spec.rb =================================================================== --- MacRuby/trunk/spec/frozen/core/struct/new_spec.rb 2009-10-29 00:38:58 UTC (rev 2911) +++ MacRuby/trunk/spec/frozen/core/struct/new_spec.rb 2009-10-29 01:34:27 UTC (rev 2912) @@ -8,6 +8,12 @@ struct.name.should == "Struct::Animal" end + it "creates a constant in Struct namespace by assigning to constant" do + Animal = Struct.new(:name, :legs, :eyeballs) + Animal.should == Animal + Animal.name.should == "Animal" + end + it "overwrites previously defined constants with string as first argument" do first = Struct.new('Person', :height, :weight) first.should == Struct::Person Modified: MacRuby/trunk/spec/frozen/library/yaml/to_yaml_spec.rb =================================================================== --- MacRuby/trunk/spec/frozen/library/yaml/to_yaml_spec.rb 2009-10-29 00:38:58 UTC (rev 2911) +++ MacRuby/trunk/spec/frozen/library/yaml/to_yaml_spec.rb 2009-10-29 01:34:27 UTC (rev 2912) @@ -62,8 +62,8 @@ end it "returns the YAML representation of a Struct object" do - Person = Struct.new(:name, :gender) - Person.new("Jane", "female").to_yaml.should match_yaml("--- !ruby/struct:Person\nname: Jane\ngender: female\n") + Struct.new("Person", :name, :gender) + Struct::Person.new("Jane", "female").to_yaml.should match_yaml("--- !ruby/struct:Person\nname: Jane\ngender: female\n") end it "returns the YAML representation of a Symbol object" do Modified: MacRuby/trunk/spec/frozen/tags/macruby/core/struct/new_tags.txt =================================================================== --- MacRuby/trunk/spec/frozen/tags/macruby/core/struct/new_tags.txt 2009-10-29 00:38:58 UTC (rev 2911) +++ MacRuby/trunk/spec/frozen/tags/macruby/core/struct/new_tags.txt 2009-10-29 01:34:27 UTC (rev 2912) @@ -1,2 +1,3 @@ +fails:Struct.new creates a constant in Struct namespace by assigning to constant fails:Struct.new accepts Fixnums as Symbols unless fixnum.to_sym.nil? fails:Struct.new raises an ArgumentError if fixnum#to_sym is nil Deleted: MacRuby/trunk/spec/frozen/tags/macruby/library/yaml/to_yaml_tags.txt =================================================================== --- MacRuby/trunk/spec/frozen/tags/macruby/library/yaml/to_yaml_tags.txt 2009-10-29 00:38:58 UTC (rev 2911) +++ MacRuby/trunk/spec/frozen/tags/macruby/library/yaml/to_yaml_tags.txt 2009-10-29 01:34:27 UTC (rev 2912) @@ -1,4 +0,0 @@ -fails:Object#to_yaml returns the YAML representation of a Struct object -fails:Object#to_yaml returns the YAML represenation of a RegExp object -fails:Object#to_yaml returns the YAML representation of a Error object -fails:Object#to_yaml returns the YAML representation for Range objects
participants (1)
-
source_changes@macosforge.org