-
Notifications
You must be signed in to change notification settings - Fork 785
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
## | ||
# Codegen tests | ||
|
||
assert('peephole optimization does not eliminate move whose result is reused') do | ||
assert_raise LocalJumpError do | ||
def method | ||
yield | ||
end | ||
method(&a &&= 0) | ||
end | ||
end | ||
|
||
assert('empty condition in ternary expression parses correctly') do | ||
assert_equal(() ? 1 : 2, 2) | ||
end | ||
|
||
assert('method call with exactly 127 arguments') do | ||
def args_to_ary(*args) | ||
args | ||
end | ||
|
||
assert_equal [0]*127, args_to_ary( | ||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ | ||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ | ||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ | ||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ | ||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ | ||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 | ||
) | ||
end | ||
|
||
assert('nested empty heredoc') do | ||
_, a = nil, <<B | ||
#{<<A} | ||
A | ||
B | ||
assert_equal "\n", a | ||
end | ||
assert('splat in case splat') do | ||
a = *case | ||
when 0 | ||
* = 1 | ||
end | ||
assert_equal [1], a | ||
end | ||
assert('undef with 127 or more arguments') do | ||
assert_raise NameError do | ||
undef | ||
a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, | ||
a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, | ||
a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, | ||
a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a | ||
end | ||
end | ||
assert('next in normal loop with 127 arguments') do | ||
assert_raise NameError do | ||
while true | ||
next A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A | ||
end | ||
end | ||
end | ||
assert('negate literal register alignment') do | ||
a = *case | ||
when 0 | ||
-0.0 | ||
2 | ||
end | ||
assert_equal [2], a | ||
end |