Skip to content
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
7 changes: 7 additions & 0 deletions spec/compiler/codegen/c_enum_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,22 @@ describe "Code gen: c enum" do
end

[
{"+1", 1},
{"-1", -1},
{"~1", -2},
{"1 + 2", 3},
{"3 - 2", 1},
{"3 * 2", 6},
{"1 &+ 2", 3},
{"3 &- 2", 1},
{"3 &* 2", 6},
# {"10 / 2", 5}, # MathInterpreter only works with Integer and 10 / 2 : Float
{"10 // 2", 5},
{"1 << 3", 8},
{"100 >> 3", 12},
{"10 & 3", 2},
{"10 | 3", 11},
{"10 ^ 3", 9},
{"(1 + 2) * 3", 9},
{"10 % 3", 1},
].each do |(code, expected)|
Expand Down
1 change: 1 addition & 0 deletions src/compiler/crystal/semantic/math_interpreter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ struct Crystal::MathInterpreter
when "//" then left // right
when "&" then left & right
when "|" then left | right
when "^" then left ^ right
when "<<" then left << right
when ">>" then left >> right
when "%" then left % right
Expand Down