diff options
Diffstat (limited to 'test/ruby/test_literal.rb')
| -rw-r--r-- | test/ruby/test_literal.rb | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb index 8732d8f0d0..cff888d4b3 100644 --- a/test/ruby/test_literal.rb +++ b/test/ruby/test_literal.rb @@ -39,6 +39,8 @@ class TestRubyLiteral < Test::Unit::TestCase end def test_string + verbose_bak, $VERBOSE = $VERBOSE, nil # prevent syntax warnings + assert_instance_of String, ?a assert_equal "a", ?a assert_instance_of String, ?A @@ -94,6 +96,15 @@ class TestRubyLiteral < Test::Unit::TestCase assert_equal "ab", eval("?a 'b'") assert_equal "a\nb", eval("<<A 'b'\na\nA") + + assert_raise(SyntaxError) {eval('"\C-' "\u3042" '"')} + assert_raise(SyntaxError) {eval('"\C-\\' "\u3042" '"')} + assert_raise(SyntaxError) {eval('"\M-' "\u3042" '"')} + assert_raise(SyntaxError) {eval('"\M-\\' "\u3042" '"')} + + assert_equal "\x09 \xC9 \x89", eval('"\C-\111 \M-\111 \M-\C-\111"') + ensure + $VERBOSE = verbose_bak end def test_dstring @@ -241,8 +252,9 @@ class TestRubyLiteral < Test::Unit::TestCase def test_dregexp assert_instance_of Regexp, /re#{'ge'}xp/ assert_equal(/regexp/, /re#{'ge'}xp/) - bug3903 = '[ruby-core:32682]' - assert_raise(SyntaxError, bug3903) {eval('/[#{"\x80"}]/')} + + # [ruby-core:32682] + eval('/[#{"\x80"}]/') end def test_array @@ -590,6 +602,8 @@ class TestRubyLiteral < Test::Unit::TestCase end def test_integer + verbose_bak, $VERBOSE = $VERBOSE, nil # prevent syntax warnings + head = ['', '0x', '0o', '0b', '0d', '-', '+'] chars = ['0', '1', '_', '9', 'f'] head.each {|h| @@ -619,9 +633,14 @@ class TestRubyLiteral < Test::Unit::TestCase assert_syntax_error(h, /numeric literal without digits\Z/, "#{bug2407}: #{h.inspect}") end end + + ensure + $VERBOSE = verbose_bak end def test_float + verbose_bak, $VERBOSE = $VERBOSE, nil # prevent syntax warnings + head = ['', '-', '+'] chars = ['0', '1', '_', '9', 'f', '.'] head.each {|h| @@ -658,6 +677,14 @@ class TestRubyLiteral < Test::Unit::TestCase } } assert_equal(100.0, 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100e100) + + ensure + $VERBOSE = verbose_bak + end + + def test_rational_float + assert_equal(12, 0.12r * 100) + assert_equal(12, 0.1_2r * 100) end def test_symbol_list |
