mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
711b5f35ac
commit
a5f05e7ee9
17 changed files with 95 additions and 86 deletions
|
@ -1,3 +1,8 @@
|
|||
Sun Apr 11 09:31:39 2010 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||
|
||||
* 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 <naruse@ruby-lang.org>
|
||||
|
||||
* lib/rdoc/rdoc.rb (setup_output_dir): compare by Time#to_i.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'test/unit'
|
||||
require 'yaml'
|
||||
|
||||
module YAML
|
||||
module Syck
|
||||
class TestArray < Test::Unit::TestCase
|
||||
def setup
|
||||
@list = [{ :a => 'b' }, 'foo']
|
|
@ -1,7 +1,7 @@
|
|||
require 'test/unit'
|
||||
require 'yaml'
|
||||
|
||||
module YAML
|
||||
module Syck
|
||||
###
|
||||
# Test booleans from YAML spec:
|
||||
# http://yaml.org/type/bool.html
|
|
@ -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
|
|
@ -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
|
|
@ -1,7 +1,7 @@
|
|||
require 'test/unit'
|
||||
require 'yaml'
|
||||
|
||||
module YAML
|
||||
module Syck
|
||||
class TestHash < Test::Unit::TestCase
|
||||
def setup
|
||||
@hash = { :a => 'b' }
|
|
@ -1,7 +1,7 @@
|
|||
require 'test/unit'
|
||||
require 'yaml'
|
||||
|
||||
module YAML
|
||||
module Syck
|
||||
###
|
||||
# Test null from YAML spec:
|
||||
# http://yaml.org/type/null.html
|
|
@ -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
|
|
@ -1,7 +1,7 @@
|
|||
require 'test/unit'
|
||||
require 'yaml'
|
||||
|
||||
module YAML
|
||||
module Syck
|
||||
class TestSet < Test::Unit::TestCase
|
||||
def setup
|
||||
@set = YAML::Set.new
|
|
@ -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"
|
|
@ -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')
|
|
@ -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)
|
|
@ -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')
|
|
@ -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
|
76
test/syck/test_yamlstore.rb
Normal file
76
test/syck/test_yamlstore.rb
Normal file
|
@ -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
|
|
@ -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
|
Loading…
Reference in a new issue