diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2009-09-30 16:07:42 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2009-09-30 16:07:42 -0700 |
commit | aeda4bb2ae215a67f862edb36f52f50358258278 (patch) | |
tree | 04c13400b240d636213ee4d49ef25538f3d3536a /test | |
parent | 9306ea64be1a720a3f237e885137e1689ef054d0 (diff) | |
download | psych-aeda4bb2ae215a67f862edb36f52f50358258278.zip |
moving boolean classes
Diffstat (limited to 'test')
-rw-r--r-- | test/test_scalar_scanner.rb | 7 | ||||
-rw-r--r-- | test/visitors/test_to_ruby.rb | 18 | ||||
-rw-r--r-- | test/visitors/test_yast_builder.rb | 13 |
3 files changed, 38 insertions, 0 deletions
diff --git a/test/test_scalar_scanner.rb b/test/test_scalar_scanner.rb index 5311249..af4adc5 100644 --- a/test/test_scalar_scanner.rb +++ b/test/test_scalar_scanner.rb @@ -48,4 +48,11 @@ class TestScalarScanner < MiniTest::Unit::TestCase ss = Psych::ScalarScanner.new('1.2') assert_equal [:FLOAT, 1.2], ss.tokenize end + + def test_scan_true + ss = Psych::ScalarScanner.new('true') + assert_equal [:BOOLEAN, true], ss.tokenize + ss = Psych::ScalarScanner.new('y') + assert_equal [:BOOLEAN, true], ss.tokenize + end end diff --git a/test/visitors/test_to_ruby.rb b/test/visitors/test_to_ruby.rb index 0dafbd8..c252573 100644 --- a/test/visitors/test_to_ruby.rb +++ b/test/visitors/test_to_ruby.rb @@ -39,6 +39,24 @@ module Psych end end + # http://yaml.org/type/bool.html + def test_boolean_true + %w{ y Y yes Yes YES true True TRUE on On ON }.each do |t| + i = Nodes::Scalar.new(t, nil, 'tag:yaml.org,2002:bool') + assert_equal true, i.to_ruby + assert_equal true, Nodes::Scalar.new(t).to_ruby + end + end + + # http://yaml.org/type/bool.html + def test_boolean_false + %w{ n N no No NO false False FALSE off Off OFF }.each do |t| + i = Nodes::Scalar.new(t, nil, 'tag:yaml.org,2002:bool') + assert_equal false, i.to_ruby + assert_equal false, Nodes::Scalar.new(t).to_ruby + end + end + def test_float i = Nodes::Scalar.new('1.2', nil, 'tag:yaml.org,2002:float') assert_equal 1.2, i.to_ruby diff --git a/test/visitors/test_yast_builder.rb b/test/visitors/test_yast_builder.rb index 9a074e1..9d2945b 100644 --- a/test/visitors/test_yast_builder.rb +++ b/test/visitors/test_yast_builder.rb @@ -14,12 +14,25 @@ module Psych assert_equal a.inspect, Psych.load(a.to_yaml).inspect end + def test_circular_map + a = {} + a[a] = a + assert_equal a.inspect, Psych.load(a.to_yaml).inspect + end + def test_scalar assert_round_trip 'foo' assert_round_trip ':foo' assert_round_trip '' end + def test_boolean + assert_round_trip true + assert_round_trip 'true' + assert_round_trip false + assert_round_trip 'false' + end + def test_binary string = [0, 123,22, 44, 9, 32, 34, 39].pack('C*') assert_equal string, Psych.load(string.to_yaml) |