Skip to content
Newer
Older
100644 144 lines (131 sloc) 2.26 KB
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
1 assert "nil", "p @foo"
2
3 assert "42", %q{
4 class Foo
5 def initialize; @x = 42; end;
6 def x; @x; end
7 end
8 p Foo.new.x
9 }
10
11 assert "42", %q{
12 class Foo
13 def initialize; @x, @y = 40, 2; end
14 end
15 class Foo
16 def z; @z ||= @x + @y; end
17 end
18 p Foo.new.z
19 }
20
21 assert "42", %q{
22 class Foo
23 def initialize; @x = 42; end
24 end
25 o = Foo.new
26 class Foo
27 def y; @y ||= @x; end
28 end
29 p o.y
30 }
31
32 assert "42", %q{
33 instance_variable_set(:@foo, 42)
34 p instance_variable_get(:@foo)
35 }
36
37 assert "42", %q{
38 class Foo
39 def initialize; @x = 42; end
40 end
41 o = Foo.new
42 p o.instance_variable_get(:@x)
43 }
44
45 assert "42\n123", %q{
46 class Foo
47 @foo = 42
48 def self.foo; @foo; end
49 def self.foo=(x); @foo=x; end
50 end
51 p Foo.foo
52 Foo.foo=123
53 p Foo.foo
54 }
55
56 assert '231', %q{
57 class Foo
58 def initialize
59 @v1 = 1; @v2 = 2; @v3 = 3
60 @v4 = 4; @v5 = 5; @v6 = 6
61 @v7 = 7; @v8 = 8; @v9 = 9
62 @v10 = 10; @v11 = 11; @v12 = 12
63 @v13 = 13; @v14 = 14; @v15 = 15
64 @v16 = 16; @v17 = 17; @v18 = 18
65 @v19 = 19; @v20 = 20; @v21 = 21
66 end
67 def foo
68 @v1 + @v2 + @v3 + @v4 + @v5 + @v6 +
69 @v7 + @v8 + @v9 + @v10 + @v11 + @v12 +
70 @v13 + @v14 + @v15 + @v16 + @v17 + @v18 +
71 @v19 + @v20 + @v21
72 end
73 end
74 p Foo.new.foo
c2c4c3a adding new failing test
Laurent Sansonetti authored
75 }
76
77 assert '42', %{
78 class Foo < File::Stat
79 def foo; @foo=42; end
80 end
81 o=Foo.new('/System')
82 o.foo
83 p o.instance_variable_get(:@foo)
84 }
e046011 added failing test (patch by Bernd Ohr)
Laurent Sansonetti authored
85
86 assert 'nil', %{
87 class Foo
88 def bar
89 @v1 = @v2 = @v3 = @v4 = @v5 = @v6 = @v7 = @v8 = @v9 = @v10 = 0
90 end
91 def foo
92 p @oops
93 end
94 end
95 Foo.new.foo
96 }
af742d5 adding 2 tests (one is failing)
Laurent Sansonetti authored
97
98 assert '42', %{
99 class Foo
100 def initialize
101 @foo=42
102 end
103 def foo
104 o = Object.new
105 self.addObserver(o, forKeyPath:'foo', options:0, context:nil)
106 p @foo
107 end
108 end
109 Foo.new.foo
110 }
111
112 assert '42', %{
113 class Foo
114 def initialize
115 @foo=42
116 end
117 def foo
118 o = Object.new
119 self.addObserver(o, forKeyPath:'foo', options:0, context:nil)
120 1.times { p @foo }
121 end
122 end
123 Foo.new.foo
124 }
2157deb added failing test (based on #499)
Laurent Sansonetti authored
125
126 assert "2\n2", %{
127 class X; end
128 class Y < X
129 def set_foo; @foo = 1; end
130 end
131 class X
132 def set_bar; @bar = 2; end
133 def bar; @bar; end
134 end
135 class Z < Y
136 def set_foo; @foo = 3; end
137 end
138 o = Z.new
139 o.set_bar
140 p o.bar
141 o.set_foo
142 p o.bar
143 }
Something went wrong with that request. Please try again.