From a5f05e7ee9823fb04dea5219cafce5c5d879e305 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Sun, 11 Apr 2010 00:37:42 +0000 Subject: [PATCH] * test/syck/*: Moved test/yaml to test/syck since it's actually testing the syck YAML engine. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 ++ test/{yaml => syck}/test_array.rb | 2 +- test/{yaml => syck}/test_boolean.rb | 2 +- test/{yaml => syck}/test_class.rb | 2 +- test/{yaml => syck}/test_engine_manager.rb | 0 test/{yaml => syck}/test_exception.rb | 2 +- test/{yaml => syck}/test_hash.rb | 2 +- test/{yaml => syck}/test_null.rb | 2 +- test/{yaml => syck}/test_omap.rb | 2 +- test/{yaml => syck}/test_set.rb | 2 +- test/{yaml => syck}/test_string.rb | 2 +- test/{yaml => syck}/test_struct.rb | 2 +- test/{yaml => syck}/test_symbol.rb | 2 +- test/{yaml => syck}/test_yaml.rb | 2 + test/{yaml => syck}/test_yaml_properties.rb | 2 +- test/syck/test_yamlstore.rb | 76 +++++++++++++++++++++ test/yaml/test_yamlstore.rb | 74 -------------------- 17 files changed, 95 insertions(+), 86 deletions(-) rename test/{yaml => syck}/test_array.rb (96%) rename test/{yaml => syck}/test_boolean.rb (98%) rename test/{yaml => syck}/test_class.rb (96%) rename test/{yaml => syck}/test_engine_manager.rb (100%) rename test/{yaml => syck}/test_exception.rb (98%) rename test/{yaml => syck}/test_hash.rb (97%) rename test/{yaml => syck}/test_null.rb (95%) rename test/{yaml => syck}/test_omap.rb (99%) rename test/{yaml => syck}/test_set.rb (97%) rename test/{yaml => syck}/test_string.rb (98%) rename test/{yaml => syck}/test_struct.rb (98%) rename test/{yaml => syck}/test_symbol.rb (97%) rename test/{yaml => syck}/test_yaml.rb (99%) rename test/{yaml => syck}/test_yaml_properties.rb (99%) create mode 100644 test/syck/test_yamlstore.rb delete mode 100644 test/yaml/test_yamlstore.rb diff --git a/ChangeLog b/ChangeLog index 7243c0e17e..e68a6945d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Apr 11 09:31:39 2010 Aaron Patterson + + * test/syck/*: Moved test/yaml to test/syck since it's actually + testing the syck YAML engine. + Sun Apr 11 08:56:44 2010 NARUSE, Yui * lib/rdoc/rdoc.rb (setup_output_dir): compare by Time#to_i. diff --git a/test/yaml/test_array.rb b/test/syck/test_array.rb similarity index 96% rename from test/yaml/test_array.rb rename to test/syck/test_array.rb index 95ff94b959..7ffa1b404f 100644 --- a/test/yaml/test_array.rb +++ b/test/syck/test_array.rb @@ -1,7 +1,7 @@ require 'test/unit' require 'yaml' -module YAML +module Syck class TestArray < Test::Unit::TestCase def setup @list = [{ :a => 'b' }, 'foo'] diff --git a/test/yaml/test_boolean.rb b/test/syck/test_boolean.rb similarity index 98% rename from test/yaml/test_boolean.rb rename to test/syck/test_boolean.rb index 1c75c3a390..615b0b0c8f 100644 --- a/test/yaml/test_boolean.rb +++ b/test/syck/test_boolean.rb @@ -1,7 +1,7 @@ require 'test/unit' require 'yaml' -module YAML +module Syck ### # Test booleans from YAML spec: # http://yaml.org/type/bool.html diff --git a/test/yaml/test_class.rb b/test/syck/test_class.rb similarity index 96% rename from test/yaml/test_class.rb rename to test/syck/test_class.rb index 9ea9db3096..803a1f14b4 100644 --- a/test/yaml/test_class.rb +++ b/test/syck/test_class.rb @@ -1,7 +1,7 @@ require 'test/unit' require 'yaml' -module YAML +module Syck class TestClass < Test::Unit::TestCase def test_to_yaml assert_raises(::TypeError) do diff --git a/test/yaml/test_engine_manager.rb b/test/syck/test_engine_manager.rb similarity index 100% rename from test/yaml/test_engine_manager.rb rename to test/syck/test_engine_manager.rb diff --git a/test/yaml/test_exception.rb b/test/syck/test_exception.rb similarity index 98% rename from test/yaml/test_exception.rb rename to test/syck/test_exception.rb index f9354ffe2b..b85cabcd6b 100644 --- a/test/yaml/test_exception.rb +++ b/test/syck/test_exception.rb @@ -1,7 +1,7 @@ require 'test/unit' require 'yaml' -module YAML +module Syck class TestException < Test::Unit::TestCase class Wups < Exception attr_reader :foo, :bar diff --git a/test/yaml/test_hash.rb b/test/syck/test_hash.rb similarity index 97% rename from test/yaml/test_hash.rb rename to test/syck/test_hash.rb index 18a7e2533a..0690f77ec3 100644 --- a/test/yaml/test_hash.rb +++ b/test/syck/test_hash.rb @@ -1,7 +1,7 @@ require 'test/unit' require 'yaml' -module YAML +module Syck class TestHash < Test::Unit::TestCase def setup @hash = { :a => 'b' } diff --git a/test/yaml/test_null.rb b/test/syck/test_null.rb similarity index 95% rename from test/yaml/test_null.rb rename to test/syck/test_null.rb index e6b29550e4..b38bf50fba 100644 --- a/test/yaml/test_null.rb +++ b/test/syck/test_null.rb @@ -1,7 +1,7 @@ require 'test/unit' require 'yaml' -module YAML +module Syck ### # Test null from YAML spec: # http://yaml.org/type/null.html diff --git a/test/yaml/test_omap.rb b/test/syck/test_omap.rb similarity index 99% rename from test/yaml/test_omap.rb rename to test/syck/test_omap.rb index d1d30e9e93..8a2d7075b6 100644 --- a/test/yaml/test_omap.rb +++ b/test/syck/test_omap.rb @@ -1,7 +1,7 @@ require 'test/unit' require 'yaml' -module YAML +module Syck class TestOmap < Test::Unit::TestCase def test_keys map = YAML::Omap.new diff --git a/test/yaml/test_set.rb b/test/syck/test_set.rb similarity index 97% rename from test/yaml/test_set.rb rename to test/syck/test_set.rb index a3368769d1..d58f92e53f 100644 --- a/test/yaml/test_set.rb +++ b/test/syck/test_set.rb @@ -1,7 +1,7 @@ require 'test/unit' require 'yaml' -module YAML +module Syck class TestSet < Test::Unit::TestCase def setup @set = YAML::Set.new diff --git a/test/yaml/test_string.rb b/test/syck/test_string.rb similarity index 98% rename from test/yaml/test_string.rb rename to test/syck/test_string.rb index 26229a62f5..3bac75964f 100644 --- a/test/yaml/test_string.rb +++ b/test/syck/test_string.rb @@ -1,7 +1,7 @@ require 'test/unit' require 'yaml' -module YAML +module Syck class TestString < Test::Unit::TestCase def test_binary_string_null string = "\x00" diff --git a/test/yaml/test_struct.rb b/test/syck/test_struct.rb similarity index 98% rename from test/yaml/test_struct.rb rename to test/syck/test_struct.rb index b5f944c788..cdd4814fd4 100644 --- a/test/yaml/test_struct.rb +++ b/test/syck/test_struct.rb @@ -9,7 +9,7 @@ class StructWithIvar < Struct.new(:foo) end end -module YAML +module Syck class TestStruct < MiniTest::Unit::TestCase def test_roundtrip thing = StructWithIvar.new('bar') diff --git a/test/yaml/test_symbol.rb b/test/syck/test_symbol.rb similarity index 97% rename from test/yaml/test_symbol.rb rename to test/syck/test_symbol.rb index c5358aa19d..39ffa8bb03 100644 --- a/test/yaml/test_symbol.rb +++ b/test/syck/test_symbol.rb @@ -1,7 +1,7 @@ require 'test/unit' require 'yaml' -module YAML +module Syck class TestSymbol < Test::Unit::TestCase def test_to_yaml assert_equal :a, YAML.load(:a.to_yaml) diff --git a/test/yaml/test_yaml.rb b/test/syck/test_yaml.rb similarity index 99% rename from test/yaml/test_yaml.rb rename to test/syck/test_yaml.rb index 606c2676f1..ece1b768e3 100644 --- a/test/yaml/test_yaml.rb +++ b/test/syck/test_yaml.rb @@ -11,6 +11,7 @@ module YAML_Tests StructTest = Struct::new( :c ) end +module Syck class YAML_Unit_Tests < Test::Unit::TestCase # # Convert between YAML and the object to verify correct parsing and @@ -1316,6 +1317,7 @@ EOY # '[ruby-core:13735]' end end +end if $0 == __FILE__ suite = Test::Unit::TestSuite.new('YAML') diff --git a/test/yaml/test_yaml_properties.rb b/test/syck/test_yaml_properties.rb similarity index 99% rename from test/yaml/test_yaml_properties.rb rename to test/syck/test_yaml_properties.rb index 48bb878a01..2df2e1cf76 100644 --- a/test/yaml/test_yaml_properties.rb +++ b/test/syck/test_yaml_properties.rb @@ -1,7 +1,7 @@ require 'test/unit' require 'yaml' -module YAML +module Syck class TestYamlProperties < Test::Unit::TestCase class Foo attr_reader :a, :b, :c diff --git a/test/syck/test_yamlstore.rb b/test/syck/test_yamlstore.rb new file mode 100644 index 0000000000..e78a7e4ecb --- /dev/null +++ b/test/syck/test_yamlstore.rb @@ -0,0 +1,76 @@ +require 'test/unit' +require 'syck/store' + +module Syck + class YAMLStoreTest < Test::Unit::TestCase + def setup + @yamlstore_file = "yamlstore.tmp.#{Process.pid}" + @yamlstore = YAML::Store.new(@yamlstore_file) + end + + def teardown + File.unlink(@yamlstore_file) rescue nil + end + + def test_opening_new_file_in_readonly_mode_should_result_in_empty_values + @yamlstore.transaction(true) do + assert_nil @yamlstore[:foo] + assert_nil @yamlstore[:bar] + end + end + + def test_opening_new_file_in_readwrite_mode_should_result_in_empty_values + @yamlstore.transaction do + assert_nil @yamlstore[:foo] + assert_nil @yamlstore[:bar] + end + end + + def test_data_should_be_loaded_correctly_when_in_readonly_mode + @yamlstore.transaction do + @yamlstore[:foo] = "bar" + end + @yamlstore.transaction(true) do + assert_equal "bar", @yamlstore[:foo] + end + end + + def test_data_should_be_loaded_correctly_when_in_readwrite_mode + @yamlstore.transaction do + @yamlstore[:foo] = "bar" + end + @yamlstore.transaction do + assert_equal "bar", @yamlstore[:foo] + end + end + + def test_changes_after_commit_are_discarded + @yamlstore.transaction do + @yamlstore[:foo] = "bar" + @yamlstore.commit + @yamlstore[:foo] = "baz" + end + @yamlstore.transaction(true) do + assert_equal "bar", @yamlstore[:foo] + end + end + + def test_changes_are_not_written_on_abort + @yamlstore.transaction do + @yamlstore[:foo] = "bar" + @yamlstore.abort + end + @yamlstore.transaction(true) do + assert_nil @yamlstore[:foo] + end + end + + def test_writing_inside_readonly_transaction_raises_error + assert_raise(PStore::Error) do + @yamlstore.transaction(true) do + @yamlstore[:foo] = "bar" + end + end + end + end +end diff --git a/test/yaml/test_yamlstore.rb b/test/yaml/test_yamlstore.rb deleted file mode 100644 index 1374d32d24..0000000000 --- a/test/yaml/test_yamlstore.rb +++ /dev/null @@ -1,74 +0,0 @@ -require 'test/unit' -require 'syck/store' - -class YAMLStoreTest < Test::Unit::TestCase - def setup - @yamlstore_file = "yamlstore.tmp.#{Process.pid}" - @yamlstore = YAML::Store.new(@yamlstore_file) - end - - def teardown - File.unlink(@yamlstore_file) rescue nil - end - - def test_opening_new_file_in_readonly_mode_should_result_in_empty_values - @yamlstore.transaction(true) do - assert_nil @yamlstore[:foo] - assert_nil @yamlstore[:bar] - end - end - - def test_opening_new_file_in_readwrite_mode_should_result_in_empty_values - @yamlstore.transaction do - assert_nil @yamlstore[:foo] - assert_nil @yamlstore[:bar] - end - end - - def test_data_should_be_loaded_correctly_when_in_readonly_mode - @yamlstore.transaction do - @yamlstore[:foo] = "bar" - end - @yamlstore.transaction(true) do - assert_equal "bar", @yamlstore[:foo] - end - end - - def test_data_should_be_loaded_correctly_when_in_readwrite_mode - @yamlstore.transaction do - @yamlstore[:foo] = "bar" - end - @yamlstore.transaction do - assert_equal "bar", @yamlstore[:foo] - end - end - - def test_changes_after_commit_are_discarded - @yamlstore.transaction do - @yamlstore[:foo] = "bar" - @yamlstore.commit - @yamlstore[:foo] = "baz" - end - @yamlstore.transaction(true) do - assert_equal "bar", @yamlstore[:foo] - end - end - - def test_changes_are_not_written_on_abort - @yamlstore.transaction do - @yamlstore[:foo] = "bar" - @yamlstore.abort - end - @yamlstore.transaction(true) do - assert_nil @yamlstore[:foo] - end - end - - def test_writing_inside_readonly_transaction_raises_error - assert_raise(PStore::Error) do - @yamlstore.transaction(true) do - @yamlstore[:foo] = "bar" - end - end - end -end