Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable specs for StaticArray#sort_by on broken targets #11359

Merged
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
48 changes: 28 additions & 20 deletions spec/std/static_array_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -263,29 +263,37 @@ describe "StaticArray" do
end
end

describe "{{ sort }}_by" do
it "sorts by" do
a = StaticArray["foo", "a", "hello"]
b = a.{{ sort }}_by(&.size)
b.should eq(StaticArray["a", "foo", "hello"])
a.should_not eq(b)
end
end

describe "{{ sort }}_by!" do
it "sorts by!" do
a = StaticArray["foo", "a", "hello"]
a.{{ sort }}_by!(&.size)
a.should eq(StaticArray["a", "foo", "hello"])
# StaticArray#sort_by and #sort_by! don't compile on aarch64-darwin and
# aarch64-linux-musl due to a codegen error caused by LLVM < 13.0.0.
# See https://github.com/crystal-lang/crystal/issues/11358 for details.
{% unless compare_versions(Crystal::LLVM_VERSION, "13.0.0") < 0 && flag?(:aarch64) && (flag?(:musl) || flag?(:darwin)) %}
describe "{{ sort }}_by" do
it "sorts by" do
a = StaticArray["foo", "a", "hello"]
b = a.{{ sort }}_by(&.size)
b.should eq(StaticArray["a", "foo", "hello"])
a.should_not eq(b)
end
end

it "calls given block exactly once for each element" do
calls = Hash(String, Int32).new(0)
a = StaticArray["foo", "a", "hello"]
a.{{ sort }}_by! { |e| calls[e] += 1; e.size }
calls.should eq({"foo" => 1, "a" => 1, "hello" => 1})
describe "{{ sort }}_by!" do
it "sorts by!" do
a = StaticArray["foo", "a", "hello"]
a.{{ sort }}_by!(&.size)
a.should eq(StaticArray["a", "foo", "hello"])
end

it "calls given block exactly once for each element" do
calls = Hash(String, Int32).new(0)
a = StaticArray["foo", "a", "hello"]
a.{{ sort }}_by! { |e| calls[e] += 1; e.size }
calls.should eq({"foo" => 1, "a" => 1, "hello" => 1})
end
end
end
{% else %}
pending "{{ sort }}_by"
pending "{{ sort }}_by!"
{% end %}
{% end %}

it_iterates "#each", [1, 2, 3], StaticArray[1, 2, 3].each
Expand Down