Skip to content

Commit

Permalink
Remove overflowing Float#to_u! interpreter primitive specs (#13737)
Browse files Browse the repository at this point in the history
Co-authored-by: Beta Ziliani <beta@manas.tech>
  • Loading branch information
HertzDevil and beta-ziliani authored Sep 22, 2023
1 parent 1b93257 commit feb17ec
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions spec/compiler/interpreter/primitives_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,22 @@ describe Crystal::Repl::Interpreter do
interpret("23.8_f32.to_{{target_type}}!").should eq(f.to_{{target_type}}!)
end

it "interprets Float32#to_{{target_type}}! (negative)" do
f = -23.8_f32
interpret("-23.8_f32.to_{{target_type}}!").should eq(f.to_{{target_type}}!)
end

it "interprets Float64#to_{{target_type}}! (positive)" do
f = 23.8_f64
interpret("23.8_f64.to_{{target_type}}!").should eq(f.to_{{target_type}}!)
end

it "interprets Float64#to_{{target_type}}! (negative)" do
f = -23.8_f64
interpret("-23.8_f64.to_{{target_type}}!").should eq(f.to_{{target_type}}!)
end
{% unless target_type.starts_with?("u") %} # Do not test undefined behavior that might differ (#13736)
it "interprets Float32#to_{{target_type}}! (negative)" do
f = -23.8_f32
interpret("-23.8_f32.to_{{target_type}}!").should eq(f.to_{{target_type}}!)
end

it "interprets Float64#to_{{target_type}}! (negative)" do
f = -23.8_f64
interpret("-23.8_f64.to_{{target_type}}!").should eq(f.to_{{target_type}}!)
end
{% end %}
{% end %}

it "interprets Char#ord" do
Expand Down

0 comments on commit feb17ec

Please sign in to comment.