Skip to content

Commit 534d41a

Browse files
Drop to_a in expectations with Slice (#15735)
1 parent f6be44b commit 534d41a

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

spec/std/io/memory_spec.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,14 @@ describe IO::Memory do
348348
io = IO::Memory.new
349349
io.pos = 1000
350350
io.print 'a'
351-
io.to_slice.to_a.should eq([0] * 1000 + [97])
351+
io.to_slice.should eq(Bytes.new(1001).tap { |bytes| bytes[-1] = 97 })
352352
end
353353

354354
it "writes past end with write_byte" do
355355
io = IO::Memory.new
356356
io.pos = 1000
357357
io.write_byte 'a'.ord.to_u8
358-
io.to_slice.to_a.should eq([0] * 1000 + [97])
358+
io.to_slice.should eq(Bytes.new(1001).tap { |bytes| bytes[-1] = 97 })
359359
end
360360

361361
it "reads at offset" do

spec/std/slice_spec.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ describe "Slice" do
529529
it "does macro [] with numbers (#3055)" do
530530
slice = Bytes[1, 2, 3]
531531
slice.should be_a(Bytes)
532-
slice.to_a.should eq([1, 2, 3])
532+
slice.should eq(Bytes[1, 2, 3])
533533
end
534534

535535
it "does Bytes[]" do
@@ -547,7 +547,7 @@ describe "Slice" do
547547
it "reverses" do
548548
slice = Bytes[1, 2, 3]
549549
slice.reverse!
550-
slice.to_a.should eq([3, 2, 1])
550+
slice.should eq(Bytes[3, 2, 1])
551551
end
552552

553553
it "shuffles" do

spec/std/string_spec.cr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2870,7 +2870,7 @@ describe "String" do
28702870
describe "encode" do
28712871
it "encodes" do
28722872
bytes = "Hello".encode("UCS-2LE")
2873-
bytes.to_a.should eq([72, 0, 101, 0, 108, 0, 108, 0, 111, 0])
2873+
bytes.should eq Bytes[72, 0, 101, 0, 108, 0, 108, 0, 111, 0]
28742874
end
28752875

28762876
{% unless flag?(:musl) || flag?(:solaris) || flag?(:freebsd) || flag?(:dragonfly) || flag?(:netbsd) %}
@@ -2908,7 +2908,7 @@ describe "String" do
29082908
end
29092909

29102910
it "doesn't raise on invalid byte sequence" do
2911-
"\xff".encode("EUC-JP", invalid: :skip).to_a.should eq([185, 165, 192, 167])
2911+
"\xff".encode("EUC-JP", invalid: :skip).should eq(Bytes[185, 165, 192, 167])
29122912
end
29132913

29142914
it "raises if incomplete byte sequence" do
@@ -2918,7 +2918,7 @@ describe "String" do
29182918
end
29192919

29202920
it "doesn't raise if incomplete byte sequence" do
2921-
("".byte_slice(0, 1) + "").encode("EUC-JP", invalid: :skip).to_a.should eq([192, 167])
2921+
("".byte_slice(0, 1) + "").encode("EUC-JP", invalid: :skip).should eq(Bytes[192, 167])
29222922
end
29232923

29242924
it "decodes" do

0 commit comments

Comments
 (0)