Skip to content

Commit

Permalink
Restore test/t/codegen.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Jun 2, 2017
1 parent 0f2f021 commit 563036e
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions test/t/codegen.rb
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

0 comments on commit 563036e

Please sign in to comment.