summaryrefslogtreecommitdiffhomepage
path: root/test/t/codegen.rb
blob: 7177053ae6e43dd459921a5243f028f264a2fc59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
##
# 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('codegen absorbs arguments to redo and retry if they are the argument of a call') do
  assert_nothing_raised do
    a=*"1", case nil
    when 1
      redo |
      1
    end
  end

  assert_nothing_raised do
    a=*"1", case nil
    when 1
      retry |
      1
    end
  end
end