1require 'psych/helper'
2
3module Psych
4  ###
5  # Test booleans from YAML spec:
6  # http://yaml.org/type/bool.html
7  class TestBoolean < TestCase
8    %w{ yes Yes YES true True TRUE on On ON }.each do |truth|
9      define_method(:"test_#{truth}") do
10        assert_equal true, Psych.load("--- #{truth}")
11      end
12    end
13
14    %w{ no No NO false False FALSE off Off OFF }.each do |truth|
15      define_method(:"test_#{truth}") do
16        assert_equal false, Psych.load("--- #{truth}")
17      end
18    end
19
20    ###
21    # YAML spec says "y" and "Y" may be used as true, but Syck treats them
22    # as literal strings
23    def test_y
24      assert_equal "y", Psych.load("--- y")
25      assert_equal "Y", Psych.load("--- Y")
26    end
27
28    ###
29    # YAML spec says "n" and "N" may be used as false, but Syck treats them
30    # as literal strings
31    def test_n
32      assert_equal "n", Psych.load("--- n")
33      assert_equal "N", Psych.load("--- N")
34    end
35  end
36end
37