Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions spec/std/yaml/any_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,26 @@ describe YAML::Any do
YAML.parse("*foo")
end
end

it "gets yes/no unquoted booleans" do
YAML.parse("yes").as_bool.should be_true
YAML.parse("no").as_bool.should be_false
YAML.parse("'yes'").as_bool?.should be_nil
YAML.parse("'no'").as_bool?.should be_nil
YAML::Any.from_yaml("yes").as_bool.should be_true
YAML::Any.from_yaml("no").as_bool.should be_false
YAML::Any.from_yaml("'yes'").as_bool?.should be_nil
YAML::Any.from_yaml("'no'").as_bool?.should be_nil
end

it "doesn't get quoted numbers" do
YAML.parse("1").as_i64.should eq(1)
YAML.parse("'1'").as_i64?.should be_nil
YAML.parse("'1'").as_s?.should eq("1")
YAML::Any.from_yaml("1").as_i64.should eq(1)
YAML::Any.from_yaml("'1'").as_i64?.should be_nil
YAML::Any.from_yaml("'1'").as_s?.should eq("1")
end
end

describe "#size" do
Expand Down
2 changes: 1 addition & 1 deletion src/yaml/any.cr
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct YAML::Any
def self.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
case node
when YAML::Nodes::Scalar
new YAML::Schema::Core.parse_scalar(node.value)
new YAML::Schema::Core.parse_scalar(node)
when YAML::Nodes::Sequence
ary = [] of YAML::Any

Expand Down