Skip to content

Commit

Permalink
Support YAML deserialization of 128-bit integers (#13834)
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil authored Sep 26, 2023
1 parent a5e9ac8 commit dcc5158
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion spec/std/yaml/serialization_spec.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "../spec_helper"
require "../../support/number"
require "yaml"
require "big"
require "big/yaml"
Expand Down Expand Up @@ -53,7 +54,7 @@ describe "YAML serialization" do
end
end

{% for int in [Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64] %}
{% for int in BUILTIN_INTEGER_TYPES %}
it "does {{ int }}.from_yaml" do
{{ int }}.from_yaml("0").should(be_a({{ int }})).should eq(0)
{{ int }}.from_yaml("123").should(be_a({{ int }})).should eq(123)
Expand Down
2 changes: 1 addition & 1 deletion src/yaml/from_yaml.cr
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def Bool.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
parse_scalar(ctx, node, self)
end

{% for type in %w(Int8 Int16 Int32 Int64 UInt8 UInt16 UInt32 UInt64) %}
{% for type in %w(Int8 Int16 Int32 Int64 Int128 UInt8 UInt16 UInt32 UInt64 UInt128) %}
def {{type.id}}.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
ctx.read_alias(node, {{type.id}}) do |obj|
return obj
Expand Down

0 comments on commit dcc5158

Please sign in to comment.