Newer
Older
require "../../spec_helper"
describe "Code gen: var" do
it "codegens var" do
run("a = 1; 1.5; a").to_i.should eq(1)
end
Ary Borenszweig
committed
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
it "codegens ivar assignment when not-nil type filter applies" do
run("
class Foo
def foo
if @a
x = @a
end
@a = 2
end
end
foo = Foo.new
foo.foo
").to_i.should eq(2)
end
it "codegens bug with instance vars and ssa" do
run("
class Foo
def initialize
@angle = 0
end
def foo
if 1 == 2
@angle += 1
else
@angle -= 1
end
end
end
f = Foo.new
f.foo
").to_i.should eq(-1)
end
it "codegens bug with var, while, if, break and ssa" do
run("
a = 1
a = 2
while 1 == 1
if 1 == 2
a = 3
else
break
end
end
a
").to_i.should eq(2)
end