Skip to content

Commit

Permalink
Showing 2 changed files with 5 additions and 30 deletions.
28 changes: 4 additions & 24 deletions spec/std/proc_spec.cr
Original file line number Diff line number Diff line change
@@ -5,48 +5,28 @@ describe "Proc" do
str = MemoryIO.new
f = ->(x : Int32) { x.to_f }
f.to_s(str)
# TODO: Change to .starts_with? "0.18.1" once 0.18.1 is released
{% if Crystal::VERSION.starts_with?("0.18.0+") || Crystal::VERSION.starts_with?("0.18.1") %}
str.to_s.should eq("#<Proc(Int32, Float64):0x#{f.pointer.address.to_s(16)}>")
{% else %}
str.to_s.should eq("#<(Int32 -> Float64):0x#{f.pointer.address.to_s(16)}>")
{% end %}
str.to_s.should eq("#<Proc(Int32, Float64):0x#{f.pointer.address.to_s(16)}>")
end

it "does to_s(io) when closured" do
str = MemoryIO.new
a = 1.5
f = ->(x : Int32) { x + a }
f.to_s(str)
# TODO: Change to .starts_with? "0.18.1" once 0.18.1 is released
{% if Crystal::VERSION.starts_with?("0.18.0+") || Crystal::VERSION.starts_with?("0.18.1") %}
str.to_s.should eq("#<Proc(Int32, Float64):0x#{f.pointer.address.to_s(16)}:closure>")
{% else %}
str.to_s.should eq("#<(Int32 -> Float64):0x#{f.pointer.address.to_s(16)}:closure>")
{% end %}
str.to_s.should eq("#<Proc(Int32, Float64):0x#{f.pointer.address.to_s(16)}:closure>")
end

it "does to_s" do
str = MemoryIO.new
f = ->(x : Int32) { x.to_f }
# TODO: Change to .starts_with? "0.18.1" once 0.18.1 is released
{% if Crystal::VERSION.starts_with?("0.18.0+") || Crystal::VERSION.starts_with?("0.18.1") %}
f.to_s.should eq("#<Proc(Int32, Float64):0x#{f.pointer.address.to_s(16)}>")
{% else %}
f.to_s.should eq("#<(Int32 -> Float64):0x#{f.pointer.address.to_s(16)}>")
{% end %}
f.to_s.should eq("#<Proc(Int32, Float64):0x#{f.pointer.address.to_s(16)}>")
end

it "does to_s when closured" do
str = MemoryIO.new
a = 1.5
f = ->(x : Int32) { x + a }
# TODO: Change to .starts_with? "0.18.1" once 0.18.1 is released
{% if Crystal::VERSION.starts_with?("0.18.0+") || Crystal::VERSION.starts_with?("0.18.1") %}
f.to_s.should eq("#<Proc(Int32, Float64):0x#{f.pointer.address.to_s(16)}:closure>")
{% else %}
f.to_s.should eq("#<(Int32 -> Float64):0x#{f.pointer.address.to_s(16)}:closure>")
{% end %}
f.to_s.should eq("#<Proc(Int32, Float64):0x#{f.pointer.address.to_s(16)}:closure>")
end

it "gets pointer" do
7 changes: 1 addition & 6 deletions spec/std/tuple_spec.cr
Original file line number Diff line number Diff line change
@@ -270,12 +270,7 @@ describe "Tuple" do

it "does types" do
tuple = {1, 'a', "hello"}
# TODO: Change to .starts_with? "0.18.1" once 0.18.1 is released
{% if Crystal::VERSION.starts_with?("0.18.0+") || Crystal::VERSION.starts_with?("0.18.1") %}
tuple.types.to_s.should eq("Tuple(Int32, Char, String)")
{% else %}
tuple.types.to_s.should eq("{Int32, Char, String}")
{% end %}
tuple.types.to_s.should eq("Tuple(Int32, Char, String)")
end

it "does ===" do

0 comments on commit 861b5af

Please sign in to comment.