1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

add a couple of getivar tests for symbols

This commit is contained in:
Alan Wu 2021-04-09 19:08:23 -04:00
parent 476a3f4be7
commit b69951cf55

View file

@ -578,3 +578,40 @@ assert_equal '42', %q{
run
run
}
# getinstancevariable on Symbol
assert_equal '[nil, nil]', %q{
# @foo to exercise the getinstancevariable instruction
public def get_foo
@foo
end
dyn_sym = ("a" + "b").to_sym
sym = :static
# compile get_foo
dyn_sym.get_foo
dyn_sym.get_foo
[dyn_sym.get_foo, sym.get_foo]
}
# attr_reader on Symbol
assert_equal '[nil, nil]', %q{
class Symbol
attr_reader :foo
end
public def get_foo
foo
end
dyn_sym = ("a" + "b").to_sym
sym = :static
# compile get_foo
dyn_sym.get_foo
dyn_sym.get_foo
[dyn_sym.get_foo, sym.get_foo]
}