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

Drop deprecated definitions #10386

Merged
merged 14 commits into from
Mar 9, 2021
Merged
8 changes: 4 additions & 4 deletions spec/compiler/codegen/macro_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ describe "Code gen: macro" do
)).to_string.should eq("Green")
end

it "says that enum has Flags attribute" do
it "says that enum has Flags annotation" do
run(%(
@[Flags]
enum Color
Expand All @@ -779,19 +779,19 @@ describe "Code gen: macro" do
Blue
end

{{Color.has_attribute?("Flags")}}
{{Color.annotation(Flags) ? true : false}}
)).to_b.should be_true
end

it "says that enum doesn't have Flags attribute" do
it "says that enum doesn't have Flags annotation" do
run(%(
enum Color
Red
Green
Blue
end

{{Color.has_attribute?("Flags")}}
{{Color.annotation(Flags) ? true : false}}
)).to_b.should be_false
end

Expand Down
2 changes: 1 addition & 1 deletion spec/compiler/crystal/tools/doc/doc_renderer_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private def it_renders(context, input, output, file = __FILE__, line = __LINE__)
generator.type(program)
end
Doc::Markdown.parse input, Doc::Markdown::DocRenderer.new(c, io)
end.should eq(output), file, line
end.should eq(output), file: file, line: line
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/std/compress/zlib/stress_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Compress::Zlib
describe Zlib do
it "write read should be inverse with random string" do
expected = String.build do |io|
1_000_000.times { rand(2000).to_i.to_s(32, io) }
1_000_000.times { rand(2000).to_i.to_s(io, 32) }
end

io = IO::Memory.new
Expand Down
6 changes: 3 additions & 3 deletions spec/std/http/client/client_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,11 @@ module HTTP
client = TestClient.new "www.example.com"
request = HTTP::Request.new("GET", "/")
client.set_defaults(request)
request.host.should eq "www.example.com"
request.hostname.should eq "www.example.com"

request = HTTP::Request.new("GET", "/", HTTP::Headers{"Host" => "other.example.com"})
client.set_defaults(request)
request.host.should eq "other.example.com"
request.hostname.should eq "other.example.com"
end
end

Expand All @@ -288,7 +288,7 @@ module HTTP

io_request.rewind
request = HTTP::Request.from_io(io_request).as(HTTP::Request)
request.host.should eq("")
request.hostname.should eq("")
end

it "can specify host and port when initialized with IO" do
Expand Down
4 changes: 2 additions & 2 deletions spec/std/http/request_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@ module HTTP
request.query_params.to_s.should eq(new_query)
end

it "gets request host from the headers" do
it "gets request hostname from the headers" do
request = Request.from_io(IO::Memory.new("GET / HTTP/1.1\r\nHost: host.example.org:3000\r\nReferer:\r\n\r\n")).as(Request)
request.host.should eq("host.example.org")
request.hostname.should eq("host.example.org")
end

it "#hostname" do
Expand Down
16 changes: 0 additions & 16 deletions spec/std/http/server/handlers/log_handler_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,6 @@ describe HTTP::LogHandler do
logs.check(:info, %r(^- - GET / HTTP/1.1 - 200 \(\d+(\.\d+)?[mµn]s\)$))
end

it "logs to io" do
request = HTTP::Request.new("GET", "/")
response = HTTP::Server::Response.new(IO::Memory.new)
context = HTTP::Server::Context.new(request, response)

backend = Log::MemoryBackend.new
io = IO::Memory.new
handler = HTTP::LogHandler.new(io)
handler.next = ->(ctx : HTTP::Server::Context) {}
handler.call(context)

retry do
io.to_s.should match(%r(- - GET / HTTP/1.1 - 200 \(\d+(\.\d+)?[mµn]s\)$))
end
end

it "log failed request" do
io = IO::Memory.new
request = HTTP::Request.new("GET", "/")
Expand Down
3 changes: 0 additions & 3 deletions spec/std/int_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ end

private def to_s_with_io(num, base, upcase = false)
String.build { |io| num.to_s(io, base, upcase: upcase) }
# Test deprecated overload:
String.build { |io| num.to_s(base, io, upcase) }
end

describe "Int" do
Expand Down Expand Up @@ -176,7 +174,6 @@ describe "Int" do
it { 1234.to_s(36).should eq("ya") }
it { -1234.to_s(36).should eq("-ya") }
it { 1234.to_s(16, upcase: true).should eq("4D2") }
it { 1234.to_s(16, true).should eq("4D2") } # Deprecated test
it { -1234.to_s(16, upcase: true).should eq("-4D2") }
it { 1234.to_s(36, upcase: true).should eq("YA") }
it { -1234.to_s(36, upcase: true).should eq("-YA") }
Expand Down
56 changes: 0 additions & 56 deletions spec/std/set_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -340,20 +340,6 @@ describe "Set" do
iter.next.should be_a(Iterator::Stop)
end

it "check subset" do
set = Set{1, 2, 3}
empty_set = Set(Int32).new

set.subset?(Set{1, 2, 3, 4}).should be_true
set.subset?(Set{1, 2, 3, "4"}).should be_true
set.subset?(Set{1, 2, 3}).should be_true
set.subset?(Set{1, 2}).should be_false
set.subset?(empty_set).should be_false

empty_set.subset?(Set{1}).should be_true
empty_set.subset?(empty_set).should be_true
end

it "#subset_of?" do
set = Set{1, 2, 3}
empty_set = Set(Int32).new
Expand All @@ -368,20 +354,6 @@ describe "Set" do
empty_set.subset_of?(empty_set).should be_true
end

it "check proper_subset" do
set = Set{1, 2, 3}
empty_set = Set(Int32).new

set.proper_subset?(Set{1, 2, 3, 4}).should be_true
set.proper_subset?(Set{1, 2, 3, "4"}).should be_true
set.proper_subset?(Set{1, 2, 3}).should be_false
set.proper_subset?(Set{1, 2}).should be_false
set.proper_subset?(empty_set).should be_false

empty_set.proper_subset?(Set{1}).should be_true
empty_set.proper_subset?(empty_set).should be_false
end

it "#proper_subset_of?" do
set = Set{1, 2, 3}
empty_set = Set(Int32).new
Expand All @@ -396,20 +368,6 @@ describe "Set" do
empty_set.proper_subset_of?(empty_set).should be_false
end

it "check superset" do
set = Set{1, 2, "3"}
empty_set = Set(Int32).new

set.superset?(empty_set).should be_true
set.superset?(Set{1, 2}).should be_true
set.superset?(Set{1, 2, "3"}).should be_true
set.superset?(Set{1, 2, 3}).should be_false
set.superset?(Set{1, 2, 3, 4}).should be_false
set.superset?(Set{1, 4}).should be_false

empty_set.superset?(empty_set).should be_true
end

it "#superset_of?" do
set = Set{1, 2, "3"}
empty_set = Set(Int32).new
Expand All @@ -424,20 +382,6 @@ describe "Set" do
empty_set.superset_of?(empty_set).should be_true
end

it "check proper_superset" do
set = Set{1, 2, "3"}
empty_set = Set(Int32).new

set.proper_superset?(empty_set).should be_true
set.proper_superset?(Set{1, 2}).should be_true
set.proper_superset?(Set{1, 2, "3"}).should be_false
set.proper_superset?(Set{1, 2, 3}).should be_false
set.proper_superset?(Set{1, 2, 3, 4}).should be_false
set.proper_superset?(Set{1, 4}).should be_false

empty_set.proper_superset?(empty_set).should be_false
end

it "#proper_superset_of?" do
set = Set{1, 2, "3"}
empty_set = Set(Int32).new
Expand Down
21 changes: 0 additions & 21 deletions spec/std/string_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2162,13 +2162,6 @@ describe "String" do
it { String.build { |io| "12".ljust(io, 7, '-') }.should eq("12-----") }
it { String.build { |io| "12".ljust(io, 7, 'あ') }.should eq("12あああああ") }
end

describe "to io (deprecated)" do
it { String.build { |io| "123".ljust(2, io) }.should eq("123") }
it { String.build { |io| "123".ljust(5, io) }.should eq("123 ") }
it { String.build { |io| "12".ljust(7, '-', io) }.should eq("12-----") }
it { String.build { |io| "12".ljust(7, 'あ', io) }.should eq("12あああああ") }
end
end

describe "rjust" do
Expand All @@ -2183,13 +2176,6 @@ describe "String" do
it { String.build { |io| "12".rjust(io, 7, '-') }.should eq("-----12") }
it { String.build { |io| "12".rjust(io, 7, 'あ') }.should eq("あああああ12") }
end

describe "to io (deprecated)" do
it { String.build { |io| "123".rjust(2, io) }.should eq("123") }
it { String.build { |io| "123".rjust(5, io) }.should eq(" 123") }
it { String.build { |io| "12".rjust(7, '-', io) }.should eq("-----12") }
it { String.build { |io| "12".rjust(7, 'あ', io) }.should eq("あああああ12") }
end
end

describe "center" do
Expand All @@ -2204,13 +2190,6 @@ describe "String" do
it { String.build { |io| "12".center(io, 7, '-') }.should eq("--12---") }
it { String.build { |io| "12".center(io, 7, 'あ') }.should eq("ああ12あああ") }
end

describe "to io (deprecated)" do
it { String.build { |io| "123".center(2, io) }.should eq("123") }
it { String.build { |io| "123".center(5, io) }.should eq(" 123 ") }
it { String.build { |io| "12".center(7, '-', io) }.should eq("--12---") }
it { String.build { |io| "12".center(7, 'あ', io) }.should eq("ああ12あああ") }
end
end

describe "succ" do
Expand Down
3 changes: 1 addition & 2 deletions spec/std/time/span_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,8 @@ describe Time::Span do
1_000_000.5.days.to_s.should eq("1000000.12:00:00")
end

it "test negate and duration" do
it "test negate and abs" do
(-Time::Span.new(nanoseconds: 1234500)).to_s.should eq("-00:00:00.001234500")
Time::Span.new(nanoseconds: -1234500).duration.to_s.should eq("00:00:00.001234500")
Time::Span.new(nanoseconds: -1234500).abs.to_s.should eq("00:00:00.001234500")
(-Time::Span.new(nanoseconds: 7700)).to_s.should eq("-00:00:00.000007700")
(+Time::Span.new(nanoseconds: 7700)).to_s.should eq("00:00:00.000007700")
Expand Down
15 changes: 0 additions & 15 deletions spec/std/uri_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,6 @@ describe "URI" do
it { URI.new(scheme: "scheme", path: "/path").authority.should be_nil }
end

describe "#full_path" do
it { URI.new(path: "/foo").full_path.should eq("/foo") }
it { URI.new.full_path.should eq("/") }
it { URI.new(path: "/foo", query: "q=1").full_path.should eq("/foo?q=1") }
it { URI.new(path: "/", query: "q=1").full_path.should eq("/?q=1") }
it { URI.new(query: "q=1").full_path.should eq("/?q=1") }
it { URI.new(path: "/a%3Ab").full_path.should eq("/a%3Ab") }

it "does not add '?' to the end if the query params are empty" do
uri = URI.parse("http://www.example.com/foo")
uri.query = ""
uri.full_path.should eq("/foo")
end
end

describe "#request_target" do
it { URI.new(path: "/foo").request_target.should eq("/foo") }
it { URI.new.request_target.should eq("/") }
Expand Down
12 changes: 0 additions & 12 deletions spec/std/yaml/builder_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,4 @@ describe YAML::Builder do
end
end.should eq 1.to_yaml
end

it ".new (with block)" do
String.build do |io|
YAML::Builder.new(io) do |builder|
builder.stream do
builder.document do
builder.scalar(1)
end
end
end
end.should eq 1.to_yaml
end
end
7 changes: 0 additions & 7 deletions src/compiler/crystal/macros.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1919,13 +1919,6 @@ module Crystal::Macros
def has_method?(name : StringLiteral | SymbolLiteral) : BoolLiteral
end

# Returns `true` if this type has an attribute. For example `@[Flags]`
# or `@[Packed]` (the name you pass to this method is `"Flags"` or `"Packed"`
# in these cases).
@[Deprecated("Use #annotation instead")]
def has_attribute?(name : StringLiteral | SymbolLiteral) : BoolLiteral
end

# Returns the last `Annotation` with the given `type`
# attached to this variable or `NilLiteral` if there are none.
def annotation(type : TypeNode) : Annotation | NilLiteral
Expand Down
13 changes: 0 additions & 13 deletions src/compiler/crystal/macros/methods.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1624,19 +1624,6 @@ module Crystal
value = arg.to_string("argument to 'TypeNode#has_method?'")
TypeNode.has_method?(type, value)
end
when "has_attribute?"
interpreter.report_warning_at(name_loc, "Deprecated TypeNode#has_attribute?. Use #annotation instead")
interpret_one_arg_method(method, args) do |arg|
value = arg.to_string("argument to 'TypeNode#has_attribute?'")
case value
when "Flags"
BoolLiteral.new(!!type.as?(EnumType).try &.flags?)
when "Packed"
BoolLiteral.new(!!type.as?(ClassType).try &.packed?)
else
BoolLiteral.new(false)
end
end
when "annotation"
fetch_annotation(self, method, args) do |type|
self.type.annotation(type)
Expand Down
6 changes: 0 additions & 6 deletions src/dir.cr
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,6 @@ class Dir
mkdir(path, mode) unless Dir.exists?(path)
end

# Removes the directory at the given path.
@[Deprecated("Use `Dir.delete` instead")]
def self.rmdir(path : Path | String)
delete(path)
end

# Removes the directory at the given path.
def self.delete(path : Path | String)
Crystal::System::Dir.delete(path.to_s)
Expand Down
12 changes: 0 additions & 12 deletions src/file/info.cr
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,9 @@ class File
# The user ID that the file belongs to.
abstract def owner_id : String

# :ditto:
@[Deprecated("Use File#owner_id instead")]
def owner : UInt32
owner_id.to_u32
end

# The group ID that the file belongs to.
abstract def group_id : String

# :ditto:
@[Deprecated("Use File#group_id instead")]
def group : UInt32
group_id.to_u32
end

# Returns true if this `Info` and *other* are of the same file.
#
# On unix, this compares device and inode fields, and will compare equal for
Expand Down
19 changes: 0 additions & 19 deletions src/hash.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1208,25 +1208,6 @@ class Hash(K, V)
entry ? entry.value : yield key
end

# Deletes each key-value pair for which the given block returns `true`.
#
# ```
# h = {"foo" => "bar", "fob" => "baz", "bar" => "qux"}
# h.delete_if { |key, value| key.starts_with?("fo") }
# h # => { "bar" => "qux" }
# ```
@[Deprecated("Use `#reject!` instead")]
def delete_if
keys_to_delete = [] of K
each do |key, value|
keys_to_delete << key if yield(key, value)
end
keys_to_delete.each do |key|
delete(key)
end
self
end

# Returns `true` when hash contains no key-value pairs.
#
# ```
Expand Down
Loading