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:
parent
476a3f4be7
commit
b69951cf55
1 changed files with 37 additions and 0 deletions
|
@ -578,3 +578,40 @@ assert_equal '42', %q{
|
||||||
run
|
run
|
||||||
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]
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue