From 01386f93ee3536a6cfca3ab9e48d09f3af08038f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Muska=C5=82a?= Date: Fri, 7 Jul 2023 10:19:13 +0100 Subject: [PATCH] Fix tests on OTP 26 --- test/encode_test.exs | 4 ++-- test/helpers_test.exs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/encode_test.exs b/test/encode_test.exs index 7da4da9..a4f3b0d 100644 --- a/test/encode_test.exs +++ b/test/encode_test.exs @@ -117,7 +117,7 @@ defmodule Jason.EncoderTest do test "Fragment" do pre_encoded_json = Jason.encode!(%{hello: "world", test: 123}) - assert to_json(%{foo: Jason.Fragment.new(pre_encoded_json)}) == ~s({"foo":{"hello":"world","test":123}}) + assert to_json(%{foo: Jason.Fragment.new(pre_encoded_json)}) == ~s({"foo":#{pre_encoded_json}}) end defmodule Derived do @@ -190,7 +190,7 @@ defmodule Jason.EncoderTest do def encode(struct, opts) do struct |> Map.from_struct - |> Enum.map(&(&1)) + |> Enum.sort_by(&elem(&1, 0)) |> Jason.Encode.keyword(opts) end end diff --git a/test/helpers_test.exs b/test/helpers_test.exs index 80eb6f7..55bb782 100644 --- a/test/helpers_test.exs +++ b/test/helpers_test.exs @@ -1,7 +1,7 @@ defmodule Jason.HelpersTest do use ExUnit.Case, async: true - alias Jason.{Helpers, Fragment, EncodeError} + alias Jason.{OrderedObject, Helpers, Fragment, EncodeError} import Helpers doctest Helpers @@ -17,7 +17,7 @@ defmodule Jason.HelpersTest do test "produces same output as regular encoding" do assert %Fragment{} = helper = json_map(bar: 2, baz: 3, foo: 1) - assert Jason.encode!(helper) == Jason.encode!(%{bar: 2, baz: 3, foo: 1}) + assert Jason.encode!(helper) == Jason.encode!(OrderedObject.new(bar: 2, baz: 3, foo: 1)) end test "rejects keys with invalid characters" do