From b02b4bb04831671c77dbd55eaf7e77e1629c03b5 Mon Sep 17 00:00:00 2001 From: why Date: Sun, 16 May 2004 16:09:41 +0000 Subject: * lib/yaml.rb: removed fallback to pure Ruby parser. * lib/yaml/baseemitter.rb (indent_text): was forcing a mod value of zero at times, which kept some blocks from getting indentation. * lib/yaml/baseemitter.rb (node_text): rewriting folded scalars. * ext/syck/syck.h: reports style of scalars now, be they plain, block single-, or double-quoted. * ext/syck/syck.c: ditto. * ext/syck/gram.c: ditto. * ext/syck/node.c: ditto. * ext/syck/token.c: ditto. * ext/syck/rubyext.c (yaml_org_handler): symbols loaded only if scalar style is plain. * ext/syck/rubyext.c (yaml_org_handler): some empty strings were loaded as symbols. * test/yaml/test_yaml.rb (test_perl_regexp): updated test to match new regexp serialization. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/yaml/test_yaml.rb | 93 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 83 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/yaml/test_yaml.rb b/test/yaml/test_yaml.rb index 6ddde2065c..05332a6e40 100644 --- a/test/yaml/test_yaml.rb +++ b/test/yaml/test_yaml.rb @@ -33,6 +33,10 @@ class YAML_Unit_Tests < Test::Unit::TestCase assert_equal( obj, YAML::parse( yaml ).transform ) end + def assert_cycle( obj ) + assert_equal( obj, YAML::load( obj.to_yaml ) ) + end + def assert_path_segments( path, segments ) YAML::YPath.each_path( path ) { |choice| assert_equal( choice.segments, segments.shift ) @@ -71,10 +75,14 @@ EOY def test_basic_strings # Common string types + assert_cycle("x") + assert_cycle(":x") + assert_cycle(":") assert_parse_only( { 1 => 'simple string', 2 => 42, 3 => '1 Single Quoted String', 4 => 'YAML\'s Double "Quoted" String', 5 => "A block\n with several\n lines.\n", - 6 => "A \"chomped\" block", 7 => "A folded\n string\n" }, < "A \"chomped\" block", 7 => "A folded\n string\n", 8 => ": started string" }, + < - Mark McGwire's + Mark McGwire\'s year was crippled by a knee injury. EOY @@ -442,22 +451,28 @@ octal: 014 hexadecimal: 0xC EOY ) + assert_parse_only( + { 'canonical' => 685230, 'decimal' => 685230, 'octal' => 02472256, 'hexadecimal' => 0x0A74AE, 'sexagesimal' => 685230 }, < 1230.15, 'exponential' => 1230.15, 'fixed' => 1230.15, - 'negative infinity' => -1.0/0.0 }, < -1.0/0.0 }, < /a.b/, 'complex' => /\A"((?:[^"]|\")+)"/, + { 'simple' => /a.b/, 'complex' => %r'\A"((?:[^"]|\")+)"', 'case-insensitive' => /George McFly/i }, <