summaryrefslogtreecommitdiff
path: root/test/psych/test_set.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-03-26 17:32:15 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-03-26 17:32:15 -0700
commit2195fb15a7b6c4f3ea17885b184f386e6cc82787 (patch)
treecd5a0b31eed6fb79d367b43bdb7aeb8382911a0c /test/psych/test_set.rb
parent50dd7278528e4323c6fdfc2e0587616eb6a815b5 (diff)
downloadpsych-2195fb15a7b6c4f3ea17885b184f386e6cc82787.zip
moving tests under the psych directory
Diffstat (limited to 'test/psych/test_set.rb')
-rw-r--r--test/psych/test_set.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/psych/test_set.rb b/test/psych/test_set.rb
new file mode 100644
index 0000000..071eedc
--- /dev/null
+++ b/test/psych/test_set.rb
@@ -0,0 +1,49 @@
+require 'minitest/autorun'
+require 'psych'
+
+module Psych
+ class TestSet < MiniTest::Unit::TestCase
+ def setup
+ @set = Psych::Set.new
+ @set['foo'] = 'bar'
+ @set['bar'] = 'baz'
+ end
+
+ def test_to_yaml
+ assert_match(/!set/, @set.to_yaml)
+ end
+
+ def test_roundtrip
+ assert_equal(@set, Psych.load(Psych.dump(@set)))
+ end
+
+ ###
+ # FIXME: Syck should also support !!set as shorthand
+ def test_load_from_yaml
+ loaded = Psych.load(<<-eoyml)
+--- !set
+foo: bar
+bar: baz
+ eoyml
+ assert_equal(@set, loaded)
+ end
+
+ def test_loaded_class
+ assert_instance_of(Psych::Set, Psych.load(Psych.dump(@set)))
+ end
+
+ def test_set_shorthand
+ loaded = Psych.load(<<-eoyml)
+--- !!set
+foo: bar
+bar: baz
+ eoyml
+ assert_instance_of(Psych::Set, loaded)
+ end
+
+ def test_set_self_reference
+ @set['self'] = @set
+ assert_equal(@set, Psych.load(Psych.dump(@set)))
+ end
+ end
+end