mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* parse.y (rb_enc_symname_type): :$a!, @a! and so on are not
valid symbols, so they should be inspected with quotes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2bcd502a71
commit
65658ea0d4
3 changed files with 20 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Sat Jul 23 15:37:04 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* parse.y (rb_enc_symname_type): :$a!, @a! and so on are not
|
||||
valid symbols, so they should be inspected with quotes.
|
||||
|
||||
Sat Jul 23 17:06:25 2011 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* io.c (rb_update_max_fd): validate fd.
|
||||
|
|
2
parse.y
2
parse.y
|
@ -9758,10 +9758,12 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc)
|
|||
while (m < e && is_identchar(m, e, enc)) m += rb_enc_mbclen(m, e, enc);
|
||||
switch (*m) {
|
||||
case '!': case '?':
|
||||
if (type == ID_GLOBAL || type == ID_CLASS || type == ID_INSTANCE) return -1;
|
||||
type = ID_JUNK;
|
||||
++m;
|
||||
break;
|
||||
case '=':
|
||||
if (type != ID_CONST && type != ID_LOCAL) return -1;
|
||||
type = ID_ATTRSET;
|
||||
++m;
|
||||
break;
|
||||
|
|
|
@ -75,6 +75,19 @@ class TestSymbol < Test::Unit::TestCase
|
|||
assert_inspect_evaled(':$1')
|
||||
end
|
||||
|
||||
def test_inspect
|
||||
valid = %w{$a @a @@a < << <= <=> > >> >= =~ == === * ** + +@ - -@
|
||||
| ^ & / % ~ ` [] []= ! != !~ a a? a! a= A A? A! A=}
|
||||
valid.each do |sym|
|
||||
assert_equal(':' + sym, sym.intern.inspect)
|
||||
end
|
||||
|
||||
invalid = %w{$a? $a! $a= @a? @a! @a= @@a? @@a! @@a= =}
|
||||
invalid.each do |sym|
|
||||
assert_equal(':"' + sym + '"', sym.intern.inspect)
|
||||
end
|
||||
end
|
||||
|
||||
def test_to_proc
|
||||
assert_equal %w(1 2 3), (1..3).map(&:to_s)
|
||||
[
|
||||
|
|
Loading…
Reference in a new issue