ruby_parser-legacy 1.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ruby_parser-legacy might be problematic. Click here for more details.

@@ -0,0 +1,226 @@
1
+ # encoding: US-ASCII
2
+
3
+ require "minitest/autorun"
4
+ require "ruby_parser/legacy/ruby_parser_extras"
5
+ require "ruby_parser/legacy/ruby_parser"
6
+
7
+ class RubyParser::Legacy::TestStackState < Minitest::Test
8
+ attr_reader :s
9
+
10
+ def setup
11
+ @s = RubyParser::Legacy::RubyParserStuff::StackState.new :test
12
+ end
13
+
14
+ def assert_encoding str, default = false
15
+ orig_str = str.dup
16
+ p = RubyParser::V19.new
17
+ s = nil
18
+
19
+ out, err = capture_io do
20
+ s = p.handle_encoding str
21
+ end
22
+
23
+ assert_equal orig_str.sub(/\357\273\277/, ''), s
24
+
25
+ exp_err = ""
26
+
27
+ if defined?(Encoding) then
28
+ assert_equal "UTF-8", s.encoding.to_s, str.inspect
29
+ else
30
+ exp_err = "Skipping magic encoding comment\n" unless default
31
+ end
32
+
33
+ assert_equal "", out, str.inspect
34
+ assert_equal exp_err, err, str.inspect # HACK
35
+ end
36
+
37
+ def test_handle_encoding_bom
38
+ # bom support, default to utf-8
39
+ assert_encoding "\xEF\xBB\xBF# blah"
40
+ # we force_encode to US-ASCII, then encode to UTF-8 so our lexer will work
41
+ assert_encoding "\xEF\xBB\xBF# encoding: US-ASCII"
42
+ end
43
+
44
+ def test_handle_encoding_default
45
+ assert_encoding "blah", :default
46
+ end
47
+
48
+ def test_handle_encoding_emacs
49
+ # Q: how many different ways can we screw these up? A: ALL OF THEM
50
+
51
+ assert_encoding "# - encoding: utf-8 -"
52
+ assert_encoding "# - encoding:utf-8"
53
+ assert_encoding "# -* coding: UTF-8 -*-"
54
+ assert_encoding "# -*- coding: UTF-8 -*-"
55
+ assert_encoding "# -*- coding: utf-8 -*"
56
+ assert_encoding "# -*- coding: utf-8 -*-"
57
+ assert_encoding "# -*- coding: utf-8; mode: ruby -*-"
58
+ assert_encoding "# -*- coding: utf-8; mode: ruby; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2"
59
+ assert_encoding "# -*- coding:utf-8; mode:ruby; -*-"
60
+ assert_encoding "# -*- encoding: UTF-8 -*-"
61
+ assert_encoding "# -*- encoding: utf-8 -*"
62
+ assert_encoding "# -*- encoding: utf-8 -*-"
63
+ assert_encoding "# -*- mode:ruby; coding:utf-8 -*-"
64
+ assert_encoding "# -*- ruby encoding: utf-8 -*-"
65
+ assert_encoding "# -- encoding: utf-8 --"
66
+ assert_encoding "# ~*~ encoding: utf-8 ~*~"
67
+ assert_encoding "#-*- coding: utf-8 -*-"
68
+ assert_encoding "#-*- coding:utf-8"
69
+ assert_encoding "#-- -*- mode: ruby; encoding: utf-8 -*-\n"
70
+ end
71
+
72
+ def test_handle_encoding_wtf
73
+ assert_encoding "# coding : utf-8"
74
+ assert_encoding "# Ruby 1.9: encoding: utf-8"
75
+ assert_encoding "# Encoding: UTF-8 <-- required, please leave this in."
76
+ assert_encoding "# Encoding: UTF-8"
77
+ assert_encoding "# coding: utf-8"
78
+ assert_encoding "# coding:utf-8"
79
+ assert_encoding "# coding=utf-8"
80
+ assert_encoding "# encoding: ASCII"
81
+ assert_encoding "# encoding: ASCII-8BIT"
82
+ assert_encoding "# encoding: ISO-8859-1"
83
+ assert_encoding "# encoding: UTF-8"
84
+ assert_encoding "# encoding: ascii-8bit"
85
+ assert_encoding "# encoding: cp1252"
86
+ assert_encoding "# encoding: euc-jp -*-"
87
+ assert_encoding "# encoding: utf-8 # -*- ruby -*-"
88
+ assert_encoding "# encoding: utf-8 require 'github_api/utils/url'"
89
+ assert_encoding "# encoding: utf-8!"
90
+ assert_encoding "# encoding: utf-8"
91
+ assert_encoding "#<Encoding:UTF-8>"
92
+ assert_encoding "#Encoding: UTF-8"
93
+ assert_encoding "#coding:utf-8"
94
+ assert_encoding "#encoding: UTF-8!"
95
+ assert_encoding "#encoding: UTF-8"
96
+ assert_encoding "#encoding: cp1252"
97
+ assert_encoding "#encoding: sjis"
98
+ assert_encoding "#encoding: utf-8"
99
+ end
100
+
101
+ def test_handle_encoding_normal
102
+ assert_encoding "# encoding: UTF-8"
103
+ assert_encoding "# encoding: UTF-8\r\n" # UGH I hate windoze
104
+ assert_encoding "# coding: UTF-8"
105
+ assert_encoding "# encoding = UTF-8"
106
+ assert_encoding "# coding = UTF-8"
107
+ end
108
+
109
+ def test_handle_encoding_vim
110
+ assert_encoding "# vim: set fileencoding=utf-8 filetype=ruby ts=2 : "
111
+ assert_encoding "# vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si"
112
+ assert_encoding "# vim: fileencoding=UTF-8 nobomb sw=2 ts=2 et"
113
+ assert_encoding "# vim: filetype=ruby, fileencoding=UTF-8, tabsize=2, shiftwidth=2"
114
+ assert_encoding "# vim: set fileencoding=utf-8"
115
+ assert_encoding "# vim:encoding=UTF-8:"
116
+ assert_encoding "# vim:fileencoding=UTF-8:"
117
+ assert_encoding "# vim:set fileencoding=utf-8 filetype=ruby"
118
+ assert_encoding "# vim:set fileencoding=utf-8:"
119
+ end
120
+
121
+ def test_stack_state
122
+ s.push true
123
+ s.push false
124
+ s.lexpop
125
+ assert_equal [false, true], s.stack
126
+ end
127
+
128
+ def test_is_in_state
129
+ assert_equal false, s.is_in_state
130
+ s.push false
131
+ assert_equal false, s.is_in_state
132
+ s.push true
133
+ assert_equal true, s.is_in_state
134
+ s.push false
135
+ assert_equal false, s.is_in_state
136
+ end
137
+
138
+ def test_lexpop
139
+ assert_equal [false], s.stack
140
+ s.push true
141
+ s.push false
142
+ assert_equal [false, true, false], s.stack
143
+ s.lexpop
144
+ assert_equal [false, true], s.stack
145
+ end
146
+
147
+ def test_pop
148
+ assert_equal [false], s.stack
149
+ s.push true
150
+ assert_equal [false, true], s.stack
151
+ assert_equal true, s.pop
152
+ assert_equal [false], s.stack
153
+ end
154
+
155
+ def test_push
156
+ assert_equal [false], s.stack
157
+ s.push true
158
+ s.push false
159
+ assert_equal [false, true, false], s.stack
160
+ end
161
+ end
162
+
163
+ class TestEnvironment < Minitest::Test
164
+ def deny t
165
+ assert ! t
166
+ end
167
+
168
+ def setup
169
+ @env = RubyParser::Legacy::RubyParserStuff::Environment.new
170
+ @env[:blah] = 42
171
+ assert_equal 42, @env[:blah]
172
+ end
173
+
174
+ def test_var_scope_dynamic
175
+ @env.extend :dynamic
176
+ assert_equal 42, @env[:blah]
177
+ @env.unextend
178
+ assert_equal 42, @env[:blah]
179
+ end
180
+
181
+ def test_var_scope_static
182
+ @env.extend
183
+ assert_nil @env[:blah]
184
+ @env.unextend
185
+ assert_equal 42, @env[:blah]
186
+ end
187
+
188
+ def test_all_dynamic
189
+ expected = { :blah => 42 }
190
+
191
+ @env.extend :dynamic
192
+ assert_equal expected, @env.all
193
+ @env.unextend
194
+ assert_equal expected, @env.all
195
+ end
196
+
197
+ def test_all_static
198
+ @env.extend
199
+ expected = { }
200
+ assert_equal expected, @env.all
201
+
202
+ @env.unextend
203
+ expected = { :blah => 42 }
204
+ assert_equal expected, @env.all
205
+ end
206
+
207
+ def test_all_static_deeper
208
+ expected0 = { :blah => 42 }
209
+ expected1 = { :blah => 42, :blah2 => 24 }
210
+ expected2 = { :blah => 27 }
211
+
212
+ @env.extend :dynamic
213
+ @env[:blah2] = 24
214
+ assert_equal expected1, @env.all
215
+
216
+ @env.extend
217
+ @env[:blah] = 27
218
+ assert_equal expected2, @env.all
219
+
220
+ @env.unextend
221
+ assert_equal expected1, @env.all
222
+
223
+ @env.unextend
224
+ assert_equal expected0, @env.all
225
+ end
226
+ end
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_parser-legacy
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Davis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDPjCCAiagAwIBAg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dR1JR
29
+ Em82dBUFsipwMLCYj39kcyHWAxyl6Ae1Cn9r/ItVBCxoeFdrHjfavnrIEoXUt4bU
30
+ UfBugfLD19bu3nvL+zTAGx/U
31
+ -----END CERTIFICATE-----
32
+ date: 2019-03-15 00:00:00.000000000 Z
33
+ dependencies:
34
+ - !ruby/object:Gem::Dependency
35
+ name: ruby_parser
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.13'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.13'
48
+ - !ruby/object:Gem::Dependency
49
+ name: minitest
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.11'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.11'
62
+ - !ruby/object:Gem::Dependency
63
+ name: oedipus_lex
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.5'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.5'
76
+ - !ruby/object:Gem::Dependency
77
+ name: rdoc
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '4.0'
83
+ - - "<"
84
+ - !ruby/object:Gem::Version
85
+ version: '7'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '4.0'
93
+ - - "<"
94
+ - !ruby/object:Gem::Version
95
+ version: '7'
96
+ - !ruby/object:Gem::Dependency
97
+ name: racc
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 1.4.6
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 1.4.6
110
+ - !ruby/object:Gem::Dependency
111
+ name: hoe
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '3.17'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '3.17'
124
+ description: |-
125
+ ruby_parser-legacy includes the ruby 1.8 and 1.9 parsers from
126
+ ruby_parser (now removed) and plugs them into the existing system.
127
+ email:
128
+ - ryand-ruby@zenspider.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files:
132
+ - History.rdoc
133
+ - Manifest.txt
134
+ - README.rdoc
135
+ files:
136
+ - ".autotest"
137
+ - History.rdoc
138
+ - Manifest.txt
139
+ - README.rdoc
140
+ - Rakefile
141
+ - lib/ruby_parser/legacy.rb
142
+ - lib/ruby_parser/legacy/ruby18_parser.rb
143
+ - lib/ruby_parser/legacy/ruby18_parser.y
144
+ - lib/ruby_parser/legacy/ruby19_parser.rb
145
+ - lib/ruby_parser/legacy/ruby19_parser.y
146
+ - lib/ruby_parser/legacy/ruby_lexer.rb
147
+ - lib/ruby_parser/legacy/ruby_lexer.rex
148
+ - lib/ruby_parser/legacy/ruby_lexer.rex.rb
149
+ - lib/ruby_parser/legacy/ruby_parser.rb
150
+ - lib/ruby_parser/legacy/ruby_parser_extras.rb
151
+ - test/ruby_parser/test_legacy.rb
152
+ - test/ruby_parser/test_ruby_lexer.rb
153
+ - test/ruby_parser/test_ruby_parser.rb
154
+ - test/ruby_parser/test_ruby_parser_extras.rb
155
+ homepage: https://github.com/zenspider/ruby_parser-legacy
156
+ licenses:
157
+ - MIT
158
+ metadata: {}
159
+ post_install_message:
160
+ rdoc_options:
161
+ - "--main"
162
+ - README.rdoc
163
+ require_paths:
164
+ - lib
165
+ required_ruby_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ requirements: []
176
+ rubygems_version: 3.0.2
177
+ signing_key:
178
+ specification_version: 4
179
+ summary: ruby_parser-legacy includes the ruby 1.8 and 1.9 parsers from ruby_parser
180
+ (now removed) and plugs them into the existing system.
181
+ test_files: []
Binary file