diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-08 00:45:13 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-08 00:45:13 +0000 |
commit | 510f0ec86912e31babaadf1f66bf2a82351c1359 (patch) | |
tree | 14e907b72d66b685839ee2453b59fdad3967663c /test | |
parent | d8bcfd2b12cfd0919cd5c42ef546ae259c9b4160 (diff) | |
download | ruby-510f0ec86912e31babaadf1f66bf2a82351c1359.tar.gz |
parse.y: ripper generic input
* parse.y (ripper_initialize): allow generic input as source, if
it has #gets method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ripper/test_ripper.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ripper/test_ripper.rb b/test/ripper/test_ripper.rb index c2084d8b01..b99feb7f83 100644 --- a/test/ripper/test_ripper.rb +++ b/test/ripper/test_ripper.rb @@ -117,4 +117,22 @@ end assert_nothing_raised { Ripper.lex src } end + + class TestInput < self + Input = Struct.new(:lines) do + def gets + lines.shift + end + end + + def setup + @ripper = Ripper.new(Input.new(["1 + 1"])) + end + + def test_invalid_gets + ripper = assert_nothing_raised {Ripper.new(Input.new([0]))} + assert_raise(TypeError) {ripper.parse} + end + end + end if ripper_test |