From 8b12317f5862f5cd0817c1b681859c9e87f9f61b Mon Sep 17 00:00:00 2001 From: Kip Cole Date: Tue, 7 Jun 2022 16:57:44 +0800 Subject: [PATCH] Fix math bugs; respect :usage param to localize --- CHANGELOG.md | 10 +++++++ lib/cldr/unit.ex | 6 ++++- lib/cldr/unit/math.ex | 56 ++++++++++++++++++++-------------------- mix.exs | 2 +- mix.lock | 18 +++++++------ test/cldr_units_test.exs | 10 +++---- 6 files changed, 59 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20f7ee9..f2d5019 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## Cldr_Units v3.13.1 + +This is the changelog for Cldr_units v3.13.1 released on June 7th, 2022. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_units/tags) + +### Bug Fixes + +* Fix `Cldr.Unit.Math.*` to respect unit `:usage` of the input parameters + +* Fix `Cldr.Math.localize/2` to respect unit `:usage` of the options parameter if provided + ## Cldr_Units v3.13.0 This is the changelog for Cldr_units v3.13.0 released on April 6th, 2022. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_units/tags) diff --git a/lib/cldr/unit.ex b/lib/cldr/unit.ex index c23c374..11dc35a 100644 --- a/lib/cldr/unit.ex +++ b/lib/cldr/unit.ex @@ -1337,7 +1337,10 @@ defmodule Cldr.Unit do iex> unit = Cldr.Unit.new!(1.83, :meter) iex> Cldr.Unit.localize(unit, usage: :person_height, territory: :US) - [Cldr.Unit.new!(:foot, 6), Cldr.Unit.new!(:inch, Ratio.new(6485183463413016, 137269716642252725))] + [ + Cldr.Unit.new!(:foot, 6, usage: :person_height), + Cldr.Unit.new!(:inch, Ratio.new(6485183463413016, 137269716642252725), usage: :person_height) + ] """ @@ -1351,6 +1354,7 @@ defmodule Cldr.Unit do def localize(%Unit{} = unit, backend, options) when is_atom(backend) do with {:ok, unit_list, format_options} <- Preference.preferred_units(unit, backend, options) do + unit = %{unit | usage: (options[:usage] || unit.usage)} decompose(unit, unit_list, format_options) end end diff --git a/lib/cldr/unit/math.ex b/lib/cldr/unit/math.ex index 99d8cd7..8774a96 100644 --- a/lib/cldr/unit/math.ex +++ b/lib/cldr/unit/math.ex @@ -45,27 +45,27 @@ defmodule Cldr.Unit.Math do end def add(%Unit{unit: unit, value: %Decimal{}} = u1, %Unit{unit: unit, value: %Decimal{}} = u2) do - %{u1 | value: Decimal.add(u1.value, u2.value)} + %{u1 | value: Decimal.add(u1.value, u2.value)} end - def add(%Unit{unit: unit, value: %Decimal{}} = unit_1, %Unit{unit: unit, value: value_2}) + def add(%Unit{unit: unit, value: %Decimal{}} = unit_1, %Unit{unit: unit, value: value_2} = unit_2) when is_number(value_2) do - add(unit_1, Unit.new!(unit, Decimal.new(value_2))) + add(unit_1, %{unit_2 | value: Decimal.new(value_2)}) end - def add(%Unit{unit: unit, value: value_2}, %Unit{unit: unit, value: %Decimal{}} = unit_1) - when is_number(value_2) do - add(unit_1, Unit.new!(unit, Decimal.new(value_2))) + def add(%Unit{unit: unit, value: value_1} = unit_1, %Unit{unit: unit, value: %Decimal{}} = unit_2) + when is_number(value_1) do + add(%{unit_1 | value: Decimal.new(value_1)}, unit_2) end - def add(%Unit{unit: unit, value: %Ratio{} = value_1}, %Unit{unit: unit, value: value_2}) + def add(%Unit{unit: unit, value: %Ratio{} = value_1} = unit_1, %Unit{unit: unit, value: value_2}) when is_number(value_2) do - Unit.new!(unit, Ratio.add(value_1, value_2)) + %{unit_1 | value: Ratio.add(value_1, value_2)} end - def add(%Unit{unit: unit, value: value_2}, %Unit{unit: unit, value: %Ratio{} = value_1}) + def add(%Unit{unit: unit, value: value_2} = unit_1, %Unit{unit: unit, value: %Ratio{} = value_1}) when is_number(value_2) do - Unit.new!(unit, Ratio.add(value_1, value_2)) + %{unit_1 | value: Ratio.add(value_1, value_2)} end def add(%Unit{unit: unit_category_1} = unit_1, %Unit{unit: unit_category_2} = unit_2) do @@ -122,10 +122,10 @@ defmodule Cldr.Unit.Math do ## Examples iex> Cldr.Unit.sub Cldr.Unit.new!(:kilogram, 5), Cldr.Unit.new!(:pound, 1) - #Cldr.Unit<:kilogram, -81900798833369519 <|> 18014398509481984> + #Cldr.Unit<:kilogram, 81900798833369519 <|> 18014398509481984> iex> Cldr.Unit.sub Cldr.Unit.new!(:pint, 5), Cldr.Unit.new!(:liter, 1) - #Cldr.Unit<:pint, -36794683014431043834033898368027039378825884348261 <|> 12746616238742849396626455585282990375683527307233> + #Cldr.Unit<:pint, 36794683014431043834033898368027039378825884348261 <|> 12746616238742849396626455585282990375683527307233> iex> Cldr.Unit.sub Cldr.Unit.new!(:pint, 5), Cldr.Unit.new!(:pint, 1) #Cldr.Unit<:pint, 4> @@ -138,11 +138,11 @@ defmodule Cldr.Unit.Math do Unit.new!(unit, value_1 - value_2) end - def sub(%Unit{unit: unit, value: %Decimal{} = value_1}, %Unit{ + def sub(%Unit{unit: unit, value: %Decimal{} = value_1} = unit_1, %Unit{ unit: unit, value: %Decimal{} = value_2 }) do - Unit.new!(unit, Decimal.sub(value_1, value_2)) + %{unit_1 | value: Decimal.sub(value_1, value_2)} end def sub(%Unit{unit: unit, value: %Decimal{}} = unit_1, %Unit{unit: unit, value: value_2}) @@ -155,14 +155,14 @@ defmodule Cldr.Unit.Math do sub(unit_1, Unit.new!(unit, Decimal.new(value_2))) end - def sub(%Unit{unit: unit, value: %Ratio{} = value_1}, %Unit{unit: unit, value: value_2}) + def sub(%Unit{unit: unit, value: %Ratio{} = value_1} = unit_1, %Unit{unit: unit, value: value_2}) when is_number(value_2) do - Unit.new!(unit, Ratio.sub(value_1, value_2)) + %{unit_1 | value: Ratio.sub(value_1, value_2)} end - def sub(%Unit{unit: unit, value: value_2}, %Unit{unit: unit, value: %Ratio{} = value_1}) - when is_number(value_2) do - Unit.new!(unit, Ratio.sub(value_1, value_2)) + def sub(%Unit{unit: unit, value: value_1} = unit_1, %Unit{unit: unit, value: %Ratio{} = value_2}) + when is_number(value_1) do + %{unit_1 | value: Ratio.sub(value_1, value_2)} end def sub(%Unit{unit: unit_category_1} = unit_1, %Unit{unit: unit_category_2} = unit_2) do @@ -235,11 +235,11 @@ defmodule Cldr.Unit.Math do Unit.new!(unit, value_1 * value_2) end - def mult(%Unit{unit: unit, value: %Decimal{} = value_1}, %Unit{ + def mult(%Unit{unit: unit, value: %Decimal{} = value_1} = unit_1, %Unit{ unit: unit, value: %Decimal{} = value_2 }) do - Unit.new!(unit, Decimal.mult(value_1, value_2)) + %{unit_1 | value: Decimal.mult(value_1, value_2)} end def mult(%Unit{unit: unit, value: %Decimal{}} = unit_1, %Unit{unit: unit, value: value_2}) @@ -252,14 +252,14 @@ defmodule Cldr.Unit.Math do mult(unit_1, Unit.new!(unit, Decimal.new(value_2))) end - def mult(%Unit{unit: unit, value: %Ratio{} = value_1}, %Unit{unit: unit, value: value_2}) + def mult(%Unit{unit: unit, value: %Ratio{} = value_1} = unit_1, %Unit{unit: unit, value: value_2}) when is_number(value_2) do - Unit.new!(unit, Ratio.mult(value_1, value_2)) + %{unit_1 | value: Ratio.mult(value_1, value_2)} end - def mult(%Unit{unit: unit, value: value_2}, %Unit{unit: unit, value: %Ratio{} = value_1}) - when is_number(value_2) do - Unit.new!(unit, Ratio.mult(value_1, value_2)) + def mult(%Unit{unit: unit, value: value_1} = unit_1, %Unit{unit: unit, value: %Ratio{} = value_2}) + when is_number(value_1) do + %{unit_1 | value: Ratio.mult(value_1, value_2)} end def mult(%Unit{unit: unit_category_1} = unit_1, %Unit{unit: unit_category_2} = unit_2) do @@ -461,9 +461,9 @@ defmodule Cldr.Unit.Math do round(%{unit | value: value}, places, mode) end - def round(%Unit{unit: unit, value: value}, places, mode) do + def round(%Unit{value: value} = unit_1, places, mode) do rounded_value = Cldr.Math.round(value, places, mode) - Unit.new!(unit, rounded_value) + %{unit_1 | value: rounded_value} end @doc """ diff --git a/mix.exs b/mix.exs index 9f619ca..8e0ee79 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Cldr.Units.Mixfile do use Mix.Project - @version "3.13.0" + @version "3.13.1" def project do [ diff --git a/mix.lock b/mix.lock index 6c33bb2..af5d14b 100644 --- a/mix.lock +++ b/mix.lock @@ -1,24 +1,26 @@ %{ - "benchee": {:hex, :benchee, "1.0.1", "66b211f9bfd84bd97e6d1beaddf8fc2312aaabe192f776e8931cb0c16f53a521", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm", "3ad58ae787e9c7c94dd7ceda3b587ec2c64604563e049b2a0e8baafae832addb"}, - "cldr_utils": {:hex, :cldr_utils, "2.17.1", "d5532ccfbe4b39cb652ba4566571324278344a6a2fb4500dac213ce8e123732f", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "052e0c2cf5ee801018580d69939b25528730d73ea05a05cb2c0e0a8204856d76"}, + "benchee": {:hex, :benchee, "1.1.0", "f3a43817209a92a1fade36ef36b86e1052627fd8934a8b937ac9ab3a76c43062", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}, {:statistex, "~> 1.0", [hex: :statistex, repo: "hexpm", optional: false]}], "hexpm", "7da57d545003165a012b587077f6ba90b89210fd88074ce3c60ce239eb5e6d93"}, + "cldr_utils": {:hex, :cldr_utils, "2.17.2", "4dcb582caa2108d4461a86fb761b9b072ab84a6b191173dae6bff1c67d10115e", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "9c5667e647c2ec20f9beba530f7e72557a0dc29f92947738a8ced2d0cdf04c1c"}, "coerce": {:hex, :coerce, "1.0.1", "211c27386315dc2894ac11bc1f413a0e38505d808153367bd5c6e75a4003d096", [:mix], [], "hexpm", "b44a691700f7a1a15b4b7e2ff1fa30bebd669929ac8aa43cffe9e2f8bf051cf1"}, "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"}, "deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"}, "dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"}, + "digital_token": {:hex, :digital_token, "0.4.0", "2ad6894d4a40be8b2890aad286ecd5745fa473fa5699d80361a8c94428edcd1f", [:mix], [{:cldr_utils, "~> 2.17", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "a178edf61d1fee5bb3c34e14b0f4ee21809ee87cade8738f87337e59e5e66e26"}, "earmark": {:hex, :earmark, "1.4.6", "f14260802d8998f30e1654189a0d1699c4aa7d099eb4dad904eb5f41283a70b2", [:mix], [], "hexpm", "c1653a90f63400d029b783a098f4d70a40418ddff14da4cc156a0fee9e72e8d6"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.20", "89970db71b11b6b89759ce16807e857df154f8df3e807b2920a8c39834a9e5cf", [:mix], [], "hexpm", "1eb0d2dabeeeff200e0d17dc3048a6045aab271f73ebb82e416464832eb57bdd"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.25", "2024618731c55ebfcc5439d756852ec4e85978a39d0d58593763924d9a15916f", [:mix], [], "hexpm", "56749c5e1c59447f7b7a23ddb235e4b3defe276afc220a6227237f3efe83f51e"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, - "ex_cldr": {:hex, :ex_cldr, "2.28.0", "8f7a8c70a49dc31f656eb02d4c6280550ab52abd340406e8341dd4ba2390798d", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:cldr_utils, "~> 2.17", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:gettext, "~> 0.19", [hex: :gettext, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "564608c4a344c9cca54874e95fb77cd7149f593ccf522db5cbe8943c0b183630"}, - "ex_cldr_currencies": {:hex, :ex_cldr_currencies, "2.13.0", "13188b99e527d724ed3dc2af37e54f0dac42dec42b620a34c4ed4d4902fad6dd", [:mix], [{:ex_cldr, "~> 2.24", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "64731e49ac3530aa88872b52c319eb5231bfb1a3ebb0956044c34abc0ed4f520"}, + "ex_cldr": {:hex, :ex_cldr, "2.29.0", "1c3c90cc7888afcd5e957d38af7bcfc2a0bd62bbc6885e141aef6f790cdacf6a", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:cldr_utils, "~> 2.17", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:gettext, "~> 0.19", [hex: :gettext, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: true]}], "hexpm", "9cbfcb2445e3c6b5652d0d1c435cee4ae585b9ecf533180b442adb6bf375cf74"}, + "ex_cldr_currencies": {:hex, :ex_cldr_currencies, "2.14.0", "6fbd5f48d522d6a52803ec91c91bda491698dca010bc86185b6920caa8bdfa19", [:mix], [{:ex_cldr, "~> 2.27", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "83fb1b396b8eac8161cf1187f96f8bb226760f486e98a21965c757ff98d8de9f"}, "ex_cldr_lists": {:hex, :ex_cldr_lists, "2.10.0", "4d4c9877da2d0417fd832907d69974e8328969f75fafc79b05ccf85f549f6281", [:mix], [{:ex_cldr_numbers, "~> 2.25", [hex: :ex_cldr_numbers, repo: "hexpm", optional: false]}, {:ex_doc, "~> 0.18", [hex: :ex_doc, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "adc040cde7b97f7fd7c0b35dd69ddb6fcf607303ae6355bb1851deae1f8b0652"}, - "ex_cldr_numbers": {:hex, :ex_cldr_numbers, "2.26.0", "f1104498a96666fc0b0c0995f17266c8700593e984418aa05e7b731bfd8c5670", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ex_cldr, "~> 2.28", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:ex_cldr_currencies, "~> 2.13", [hex: :ex_cldr_currencies, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "35b1c7bd6c87149e7f31ef24705d254419b35f9f26fe439af88d02950710e11b"}, - "ex_doc": {:hex, :ex_doc, "0.28.2", "e031c7d1a9fc40959da7bf89e2dc269ddc5de631f9bd0e326cbddf7d8085a9da", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "51ee866993ffbd0e41c084a7677c570d0fc50cb85c6b5e76f8d936d9587fa719"}, + "ex_cldr_numbers": {:hex, :ex_cldr_numbers, "2.27.0", "a29e49e1e0f990c8fec0307640a6e980074598dd8d4b9af7f85905e82f30c6b2", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:digital_token, "~> 0.3 or ~> 1.0", [hex: :digital_token, repo: "hexpm", optional: false]}, {:ex_cldr, "~> 2.28", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:ex_cldr_currencies, "~> 2.13", [hex: :ex_cldr_currencies, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "1ecb5810d4e3db138e05a18e401626a14cfdd889ad98b49b96bb280c76529ba0"}, + "ex_doc": {:hex, :ex_doc, "0.28.4", "001a0ea6beac2f810f1abc3dbf4b123e9593eaa5f00dd13ded024eae7c523298", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "bf85d003dd34911d89c8ddb8bda1a958af3471a274a4c2150a9c01c78ac3f8ed"}, "jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"}, "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"}, "numbers": {:hex, :numbers, "5.2.4", "f123d5bb7f6acc366f8f445e10a32bd403c8469bdbce8ce049e1f0972b607080", [:mix], [{:coerce, "~> 1.0", [hex: :coerce, repo: "hexpm", optional: false]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "eeccf5c61d5f4922198395bf87a465b6f980b8b862dd22d28198c5e6fab38582"}, "ratio": {:hex, :ratio, "2.4.2", "c8518f3536d49b1b00d88dd20d49f8b11abb7819638093314a6348139f14f9f9", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:numbers, "~> 5.2.0", [hex: :numbers, repo: "hexpm", optional: false]}], "hexpm", "441ef6f73172a3503de65ccf1769030997b0d533b1039422f1e5e0e0b4cbf89e"}, + "statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"}, "sweet_xml": {:hex, :sweet_xml, "0.6.6", "fc3e91ec5dd7c787b6195757fbcf0abc670cee1e4172687b45183032221b66b8", [:mix], [], "hexpm", "2e1ec458f892ffa81f9f8386e3f35a1af6db7a7a37748a64478f13163a1f3573"}, } diff --git a/test/cldr_units_test.exs b/test/cldr_units_test.exs index 03ebccb..6ab3813 100644 --- a/test/cldr_units_test.exs +++ b/test/cldr_units_test.exs @@ -83,13 +83,13 @@ defmodule Cldr.UnitsTest do unit = Cldr.Unit.new!(100, :meter) assert Cldr.Unit.localize(unit, usage: :person, territory: :US) == - [Cldr.Unit.new!(:inch, Ratio.new(21_617_278_211_378_380_800, 5_490_788_665_690_109))] + [Cldr.Unit.new!(:inch, Ratio.new(21_617_278_211_378_380_800, 5_490_788_665_690_109), usage: :person)] assert Cldr.Unit.localize(unit, usage: :person_height, territory: :US) == - [ - Cldr.Unit.new!(:foot, 328), - Cldr.Unit.new!(:inch, Ratio.new(5_534_023_222_111_776, 5_490_788_665_690_109)) - ] + [ + Cldr.Unit.new!(:foot, 328, usage: :person_height), + Cldr.Unit.new!(:inch, Ratio.new(5_534_023_222_111_776, 5_490_788_665_690_109), usage: :person_height) + ] assert Cldr.Unit.localize(unit, usage: :unknown, territory: :US) == {:error,