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

Fix positional parameter warnings in specs #12158

Merged
Show file tree
Hide file tree
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
24 changes: 12 additions & 12 deletions spec/std/indexable/mutable_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ private class SafeIndexableMutable
@values = Array.new(size) { |i| [i + offset] }
end

def unsafe_fetch(i)
raise IndexError.new unless 0 <= i < size
@values[i][0]
def unsafe_fetch(index)
raise IndexError.new unless 0 <= index < size
@values[index][0]
end

def unsafe_put(i, value : Int32)
raise IndexError.new unless 0 <= i < size
@values[i] = [value]
def unsafe_put(index, value : Int32)
raise IndexError.new unless 0 <= index < size
@values[index] = [value]
end
end

Expand All @@ -37,14 +37,14 @@ private class SafeIndexableMutableFoo
@values = Array.new(size) { [Foo.new] }
end

def unsafe_fetch(i)
raise IndexError.new unless 0 <= i < size
@values[i][0]
def unsafe_fetch(index)
raise IndexError.new unless 0 <= index < size
@values[index][0]
end

def unsafe_put(i, value : Foo)
raise IndexError.new unless 0 <= i < size
@values[i] = [value]
def unsafe_put(index, value : Foo)
raise IndexError.new unless 0 <= index < size
@values[index] = [value]
end
end

Expand Down
32 changes: 16 additions & 16 deletions spec/std/indexable_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ private class SafeIndexable
def initialize(@size : Int32, @offset = 0_i32)
end

def unsafe_fetch(i) : Int32
raise IndexError.new unless 0 <= i < size
(i + @offset).to_i
def unsafe_fetch(index) : Int32
raise IndexError.new unless 0 <= index < size
(index + @offset).to_i
end
end

Expand All @@ -22,8 +22,8 @@ private class SafeNestedIndexable
def initialize(@size : Int32, @inner_size : Int32)
end

def unsafe_fetch(i)
raise IndexError.new unless 0 <= i < size
def unsafe_fetch(index)
raise IndexError.new unless 0 <= index < size
SafeIndexable.new(@inner_size)
end
end
Expand All @@ -36,9 +36,9 @@ private class SafeStringIndexable
def initialize(@size : Int32)
end

def unsafe_fetch(i) : String
raise IndexError.new unless 0 <= i < size
i.to_s
def unsafe_fetch(index) : String
raise IndexError.new unless 0 <= index < size
index.to_s
end
end

Expand All @@ -50,9 +50,9 @@ private class SafeMixedIndexable
def initialize(@size : Int32)
end

def unsafe_fetch(i) : String | Int32
raise IndexError.new unless 0 <= i < size
i.to_s
def unsafe_fetch(index) : String | Int32
raise IndexError.new unless 0 <= index < size
index.to_s
end
end

Expand All @@ -64,12 +64,12 @@ private class SafeRecursiveIndexable
def initialize(@size : Int32)
end

def unsafe_fetch(i) : SafeRecursiveIndexable | Int32
raise IndexError.new unless 0 <= i < size
if (i % 2) == 0
SafeRecursiveIndexable.new(i)
def unsafe_fetch(index) : SafeRecursiveIndexable | Int32
raise IndexError.new unless 0 <= index < size
if (index % 2) == 0
SafeRecursiveIndexable.new(index)
else
i
index
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/std/io/memory_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe IO::Memory do
io2 = IO::Memory.new
io2.set_encoding "UTF-16LE"

io1.write_utf8 "abc😂".to_slice
io1.write_string "abc😂".to_slice
io1.to_s io2
byte_slice = io2.to_slice
utf16_slice = Slice.new(byte_slice.to_unsafe.unsafe_as(Pointer(UInt16)), byte_slice.size // sizeof(UInt16))
Expand Down
4 changes: 2 additions & 2 deletions spec/std/io/sized_spec.cr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require "spec"

private class NoPeekIO < IO
def read(bytes : Bytes)
def read(slice : Bytes)
0
end

def write(bytes : Bytes) : Nil
def write(slice : Bytes) : Nil
end

def peek
Expand Down
1 change: 1 addition & 0 deletions spec/std/json/serialization_spec.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "../spec_helper"
require "spec/helpers/iterate"
require "json"
require "big"
require "big/json"
Expand Down