Skip to content

Commit

Permalink
Compile overflow specs with compiler_rt stub
Browse files Browse the repository at this point in the history
  • Loading branch information
bcardiff committed Dec 27, 2018
1 parent 0cee1aa commit a658b3f
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions spec/compiler/codegen/arithmetics_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ SupportedIntsConversions = {
to_i8: Int8, to_i16: Int16, to_i32: Int32, to_i64: Int64, to_i128: Int128,
to_u8: UInt8, to_u16: UInt16, to_u32: UInt32, to_u64: UInt64, to_u128: UInt128,
}

PreviewOverflowFlags = ["preview_overflow"]
{% else %}
# skip Int128 and UInt128 on 32 bits platforms
SupportedInts = [UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64]
SupportedIntsConversions = {
to_i8: Int8, to_i16: Int16, to_i32: Int32, to_i64: Int64,
to_u8: UInt8, to_u16: UInt16, to_u32: UInt32, to_u64: UInt64,
}

PreviewOverflowFlags = ["preview_overflow", "compiler_rt"]
{% end %}

describe "Code gen: arithmetics primitives" do
Expand Down Expand Up @@ -81,7 +85,7 @@ describe "Code gen: arithmetics primitives" do
rescue OverflowError
1
end
), flags: ["preview_overflow"]).to_i.should eq(1)
), flags: PreviewOverflowFlags).to_i.should eq(1)
end

it "raises overflow for {{type}} + Int64" do
Expand All @@ -93,7 +97,7 @@ describe "Code gen: arithmetics primitives" do
rescue OverflowError
1
end
), flags: ["preview_overflow"]).to_i.should eq(1)
), flags: PreviewOverflowFlags).to_i.should eq(1)
end
{% end %}
end
Expand All @@ -109,7 +113,7 @@ describe "Code gen: arithmetics primitives" do
rescue OverflowError
1
end
), flags: ["preview_overflow"]).to_i.should eq(1)
), flags: PreviewOverflowFlags).to_i.should eq(1)
end

it "raises overflow for {{type}} - Int64" do
Expand All @@ -121,7 +125,7 @@ describe "Code gen: arithmetics primitives" do
rescue OverflowError
1
end
), flags: ["preview_overflow"]).to_i.should eq(1)
), flags: PreviewOverflowFlags).to_i.should eq(1)
end
{% end %}
end
Expand All @@ -139,7 +143,7 @@ describe "Code gen: arithmetics primitives" do
rescue OverflowError
1
end
), flags: ["preview_overflow"]).to_i.should eq(1)
), flags: PreviewOverflowFlags).to_i.should eq(1)
end

it "raises overflow for {{type}} * Int64" do
Expand All @@ -151,7 +155,7 @@ describe "Code gen: arithmetics primitives" do
rescue OverflowError
1
end
), flags: ["preview_overflow"]).to_i.should eq(1)
), flags: PreviewOverflowFlags).to_i.should eq(1)
end
{% end %}
{% end %}
Expand All @@ -174,7 +178,7 @@ describe "Code gen: arithmetics primitives" do
rescue OverflowError
1
end
), flags: ["preview_overflow"]).to_i.should eq(1)
), flags: PreviewOverflowFlags).to_i.should eq(1)
end
{% end %}

Expand All @@ -191,7 +195,7 @@ describe "Code gen: arithmetics primitives" do
rescue OverflowError
1
end
), flags: ["preview_overflow"]).to_i.should eq(1)
), flags: PreviewOverflowFlags).to_i.should eq(1)
end
{% end %}

Expand All @@ -208,7 +212,7 @@ describe "Code gen: arithmetics primitives" do
rescue OverflowError
1
end
), flags: ["preview_overflow"]).to_i.should eq(1)
), flags: PreviewOverflowFlags).to_i.should eq(1)
end
{% end %}

Expand All @@ -225,7 +229,7 @@ describe "Code gen: arithmetics primitives" do
rescue OverflowError
1
end
), flags: ["preview_overflow"]).to_i.should eq(1)
), flags: PreviewOverflowFlags).to_i.should eq(1)
end
{% end %}

Expand All @@ -245,7 +249,7 @@ describe "Code gen: arithmetics primitives" do
rescue OverflowError
1
end
), flags: ["preview_overflow"]).to_i.should eq(1)
), flags: PreviewOverflowFlags).to_i.should eq(1)
end
{% end %}

Expand All @@ -261,7 +265,7 @@ describe "Code gen: arithmetics primitives" do
rescue OverflowError
1
end
), flags: ["preview_overflow"]).to_i.should eq(1)
), flags: PreviewOverflowFlags).to_i.should eq(1)
end
{% end %}
{% end %}
Expand All @@ -279,7 +283,7 @@ describe "Code gen: arithmetics primitives" do
rescue OverflowError
1
end
), flags: ["preview_overflow"]).to_i.should eq(1)
), flags: PreviewOverflowFlags).to_i.should eq(1)
end
{% end %}

Expand All @@ -295,7 +299,7 @@ describe "Code gen: arithmetics primitives" do
rescue OverflowError
1
end
), flags: ["preview_overflow"]).to_i.should eq(1)
), flags: PreviewOverflowFlags).to_i.should eq(1)
end

it "raises overflow if lower than Float32::MIN" do
Expand All @@ -310,7 +314,7 @@ describe "Code gen: arithmetics primitives" do
rescue OverflowError
1
end
), flags: ["preview_overflow"]).to_i.should eq(1)
), flags: PreviewOverflowFlags).to_i.should eq(1)
end
end
end

0 comments on commit a658b3f

Please sign in to comment.