Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

150 lines (133 sloc) 1.994 kb
assert '42', "FOO=42; p FOO"
assert '42', "FOO=42; p Object::FOO"
assert '42', "class X; FOO=42; end; p X::FOO"
assert '42', "class X; end; X::FOO=42; p X::FOO"
assert ':ok', %q{
class X; FOO=123; end
begin
p FOO
rescue NameError
p :ok
end
}
assert '42', "class X; FOO=42; def foo; FOO; end; end; p X.new.foo"
assert '42', %q{
FOO=123
class X; FOO=42; end
class Y < X; def foo; FOO; end; end
p Y.new.foo
}
assert '42', "FOO=42; 1.times { p FOO }"
assert '42', %q{
module X
FOO=42
1.times { p FOO }
end
}
assert '42', %q{
class X
FOO = 42
class Y; def foo; FOO; end; end
end
p X::Y.new.foo
}
assert '42', %q{
class X; FOO = 42; end
class Y < X; def foo; FOO; end; end
p Y.new.foo
}
assert '42', %q{
class X; FOO = 123; end
class Z
FOO = 42
class Y < X; def foo; FOO; end; end
end
p Z::Y.new.foo
}
assert '42', %q{
class A
module B
def foo
42
end
end
module C
extend B
end
end
p A::C.foo
}
assert 'true', 'p ::String == String'
assert '42', %q{
o = Object.new
class << o
module Foo
Bar = 42
end
class Baz; include Foo; end
class Baz;
def self.bar; Bar; end
end
def baz; Baz; end
end
p o.baz.bar
}
assert '42', %q{
module M
FOO = 42
class X
class << self; p FOO; end
end
end
}
assert '1', "class Float; class X; p ROUNDS; end; end"
assert '42', %{
class A
B = 42
end
A.class_eval {
def bar
p B
end
}
A.new.bar
}
assert ':ok', %{
module M
FOO=42
end
class M::Foo
begin
p FOO
rescue NameError
p :ok
end
end
}
assert '42', %{
class Foo
FOO=42
def hey
Object.new.instance_eval { p FOO }
end
end
Foo.new.hey
}
assert '42', %{
module Foo; end
module Foo::Bar
FOO=42
class X
p FOO
end
end
}
assert '42', %{
module M
FOO=42
class C; end
class C::C2
p FOO
end
end
}
Jump to Line
Something went wrong with that request. Please try again.