add a couple of getivar tests for symbols

This commit is contained in:
Alan Wu 2021-04-09 19:08:23 -04:00
Родитель 476a3f4be7
Коммит b69951cf55
1 изменённых файлов: 37 добавлений и 0 удалений

Просмотреть файл

@ -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]
}