sexp_processor 4.15.2 → 4.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +27 -0
- data/lib/pt_testcase.rb +14 -5
- data/lib/sexp.rb +19 -9
- data/lib/sexp_processor.rb +1 -1
- data/lib/strict_sexp.rb +25 -3
- data/test/test_sexp.rb +18 -0
- data.tar.gz.sig +0 -0
- metadata +13 -13
- metadata.gz.sig +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a80a0eb7b290d18550bcf6a37b99973960072d2f77725d73d7803bf396af750
|
4
|
+
data.tar.gz: 4f10222a8cd7932a9409c48726ea540f65c357a31f1afb8886324b5c4f6900da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cfc5c7d3b11934b973f570b17fc7c19ae9da846fe2781c805746a74d8a63f894863d6175aa50c8607ecab45ba672fc7274612a70b17f766d83ef67171f45f87
|
7
|
+
data.tar.gz: c777e8572636582150b6409d5b5072236ebc9babd8720b06f8bfe24918d1fc694041f97e916d95b6f4959f48fe47473bad2c7f0caf70697f1d5f0dcd52b45a57
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
=== 4.16.1 / 2022-04-09
|
2
|
+
|
3
|
+
* 1 minor enhancement:
|
4
|
+
|
5
|
+
* Reworked ParseTreeTestCase's notion of versions to make it easier to extend.
|
6
|
+
|
7
|
+
=== 4.16.0 / 2021-10-27
|
8
|
+
|
9
|
+
* 4 minor enhancements:
|
10
|
+
|
11
|
+
* Added Sexp#value (pushed up from ruby_parser).
|
12
|
+
* Aliased Sexp#concat to #_concat and use that so it can be overridden.
|
13
|
+
* Cache the #hash result.
|
14
|
+
* StrictSexp mode (4) now covers concat.
|
15
|
+
|
16
|
+
* 3 bug fixes:
|
17
|
+
|
18
|
+
* Fix some doco on each_sexp to clarify that it is not recursive.
|
19
|
+
* Fixed a bug calling enum_for when using each_of_type w/ no block.
|
20
|
+
* Minor fixes to pt_testcase.rb for custom timeouts and better error handling.
|
21
|
+
|
22
|
+
=== 4.15.3 / 2021-05-15
|
23
|
+
|
24
|
+
* 1 minor enhancement:
|
25
|
+
|
26
|
+
* Added 3.0 to pt_testcase.rb
|
27
|
+
|
1
28
|
=== 4.15.2 / 2021-01-10
|
2
29
|
|
3
30
|
* 1 bug fix:
|
data/lib/pt_testcase.rb
CHANGED
@@ -34,6 +34,12 @@ class Examples
|
|
34
34
|
end
|
35
35
|
|
36
36
|
class ParseTreeTestCase < Minitest::Test
|
37
|
+
all_versions = %w[18 19 20 21 22 23 24 25 26 27 30 31]
|
38
|
+
most_versions = all_versions.drop(1)
|
39
|
+
|
40
|
+
TEST_SUFFIX = "_#{most_versions.join "_"}"
|
41
|
+
VER_RE = /(#{Regexp.union(*all_versions)})/
|
42
|
+
|
37
43
|
attr_accessor :processor # to be defined by subclass
|
38
44
|
|
39
45
|
def setup
|
@@ -77,7 +83,7 @@ class ParseTreeTestCase < Minitest::Test
|
|
77
83
|
end
|
78
84
|
|
79
85
|
def self.add_19tests name, hash
|
80
|
-
add_tests "#{name}
|
86
|
+
add_tests "#{name}_#{TEST_SUFFIX}", hash # HACK?
|
81
87
|
end
|
82
88
|
|
83
89
|
def self.add_19edgecases ruby, sexp, cases
|
@@ -102,8 +108,6 @@ class ParseTreeTestCase < Minitest::Test
|
|
102
108
|
testcases[verbose][klass] = testcases[nonverbose][klass]
|
103
109
|
end
|
104
110
|
|
105
|
-
VER_RE = "(1[89]|2[01234567])"
|
106
|
-
|
107
111
|
def self.generate_test klass, node, data, input_name, output_name
|
108
112
|
klass.send :define_method, "test_#{node}" do
|
109
113
|
flunk "Processor is nil" if processor.nil?
|
@@ -150,7 +154,8 @@ class ParseTreeTestCase < Minitest::Test
|
|
150
154
|
|
151
155
|
before_process_hook klass, node, data, input_name, output_name
|
152
156
|
refute_nil data[input_name], "testcase does not exist?"
|
153
|
-
|
157
|
+
timeout = (ENV["RP_TIMEOUT"] || 10).to_i
|
158
|
+
@result = processor.process input, "(string)", timeout
|
154
159
|
assert_equal(expected, @result,
|
155
160
|
"failed on input: #{data[input_name].inspect}")
|
156
161
|
after_process_hook klass, node, data, input_name, output_name
|
@@ -158,7 +163,11 @@ class ParseTreeTestCase < Minitest::Test
|
|
158
163
|
extra_input.each do |extra|
|
159
164
|
processor.process(extra)
|
160
165
|
end
|
161
|
-
extra = processor.extra_methods
|
166
|
+
extra = if processor.respond_to?(:extra_methods) then
|
167
|
+
processor.extra_methods
|
168
|
+
else
|
169
|
+
[]
|
170
|
+
end
|
162
171
|
assert_equal extra_expected, extra
|
163
172
|
end
|
164
173
|
end
|
data/lib/sexp.rb
CHANGED
@@ -31,13 +31,15 @@ class Sexp < Array # ZenTest FULL
|
|
31
31
|
super(args)
|
32
32
|
end
|
33
33
|
|
34
|
+
alias _concat concat
|
35
|
+
|
34
36
|
##
|
35
37
|
# Creates a new Sexp from Array +a+.
|
36
38
|
|
37
39
|
def self.from_array a
|
38
40
|
ary = Array === a ? a : [a]
|
39
41
|
|
40
|
-
self.new.
|
42
|
+
self.new._concat(ary.map { |x|
|
41
43
|
case x
|
42
44
|
when Sexp
|
43
45
|
x
|
@@ -54,7 +56,7 @@ class Sexp < Array # ZenTest FULL
|
|
54
56
|
# same +file+, +line+, and +comment+ as self.
|
55
57
|
|
56
58
|
def new(*body)
|
57
|
-
r = self.class.new.
|
59
|
+
r = self.class.new._concat(body) # ensures a sexp from map
|
58
60
|
r.file = self.file if self.file
|
59
61
|
r.line = self.line if self.line
|
60
62
|
r.comments = self.comments if self.comments
|
@@ -62,7 +64,7 @@ class Sexp < Array # ZenTest FULL
|
|
62
64
|
end
|
63
65
|
|
64
66
|
def map &blk # :nodoc:
|
65
|
-
self.new.
|
67
|
+
self.new._concat(super(&blk)) # ensures a sexp from map
|
66
68
|
end
|
67
69
|
|
68
70
|
def == obj # :nodoc:
|
@@ -74,7 +76,7 @@ class Sexp < Array # ZenTest FULL
|
|
74
76
|
end
|
75
77
|
|
76
78
|
def hash
|
77
|
-
[self.class, *self].hash
|
79
|
+
@hash ||= [self.class, *self].hash
|
78
80
|
end
|
79
81
|
|
80
82
|
##
|
@@ -93,7 +95,7 @@ class Sexp < Array # ZenTest FULL
|
|
93
95
|
end
|
94
96
|
|
95
97
|
##
|
96
|
-
# Recursively enumerates the sexp yielding to +block+ for every
|
98
|
+
# Recursively enumerates the sexp yielding to +block+ for every sub-Sexp.
|
97
99
|
#
|
98
100
|
# Returning :skip will stop traversing that subtree:
|
99
101
|
#
|
@@ -122,7 +124,7 @@ class Sexp < Array # ZenTest FULL
|
|
122
124
|
# Enumeratates the sexp yielding to +b+ when the node_type == +t+.
|
123
125
|
|
124
126
|
def each_of_type t, &b
|
125
|
-
return enum_for(:each_of_type) unless block_given?
|
127
|
+
return enum_for(:each_of_type, t) unless block_given?
|
126
128
|
|
127
129
|
each_sexp do | sexp |
|
128
130
|
sexp.each_of_type(t, &b)
|
@@ -131,7 +133,7 @@ class Sexp < Array # ZenTest FULL
|
|
131
133
|
end
|
132
134
|
|
133
135
|
##
|
134
|
-
#
|
136
|
+
# Enumerates all sub-sexps skipping non-Sexp elements.
|
135
137
|
|
136
138
|
def each_sexp
|
137
139
|
return enum_for(:each_sexp) unless block_given?
|
@@ -289,11 +291,11 @@ class Sexp < Array # ZenTest FULL
|
|
289
291
|
# the values without the node type.
|
290
292
|
|
291
293
|
def sexp_body from = 1
|
292
|
-
self.new.
|
294
|
+
self.new._concat(self[from..-1] || [])
|
293
295
|
end
|
294
296
|
|
295
297
|
##
|
296
|
-
#
|
298
|
+
# Sets the Sexp body to new content.
|
297
299
|
|
298
300
|
def sexp_body= v
|
299
301
|
self[1..-1] = v
|
@@ -362,6 +364,14 @@ class Sexp < Array # ZenTest FULL
|
|
362
364
|
end
|
363
365
|
|
364
366
|
alias to_s inspect # :nodoc:
|
367
|
+
|
368
|
+
##
|
369
|
+
# Return the value (last item) of a single element sexp (eg `s(:lit, 42)`).
|
370
|
+
|
371
|
+
def value
|
372
|
+
raise "multi item sexp" if size > 2
|
373
|
+
last
|
374
|
+
end
|
365
375
|
end
|
366
376
|
|
367
377
|
##
|
data/lib/sexp_processor.rb
CHANGED
data/lib/strict_sexp.rb
CHANGED
@@ -36,6 +36,7 @@
|
|
36
36
|
# 4 = sexp << => no
|
37
37
|
|
38
38
|
class Sexp
|
39
|
+
# alias :_concat :concat in sexp.rb so we have access to the original
|
39
40
|
alias :safe_idx :[]
|
40
41
|
alias :safe_asgn :[]=
|
41
42
|
alias :sexp_type= :sexp_type=
|
@@ -43,9 +44,10 @@ class Sexp
|
|
43
44
|
alias :shift :shift
|
44
45
|
|
45
46
|
def self.nuke_method name, level
|
47
|
+
return unless __strict >= level
|
46
48
|
define_method name do |*args|
|
47
49
|
raise "no mutation allowed on sexps: %s.%s %s" % [self, name, args]
|
48
|
-
end
|
50
|
+
end
|
49
51
|
end
|
50
52
|
|
51
53
|
def self.__strict
|
@@ -87,7 +89,7 @@ class Sexp
|
|
87
89
|
|
88
90
|
nuke_method :collect!, 4
|
89
91
|
nuke_method :compact!, 4
|
90
|
-
|
92
|
+
nuke_method :concat, 4 # HACK: using self.class.new.concat(...) for speed
|
91
93
|
nuke_method :flatten!, 4
|
92
94
|
nuke_method :map!, 4
|
93
95
|
nuke_method :pop, 4
|
@@ -111,7 +113,7 @@ class Sexp
|
|
111
113
|
end
|
112
114
|
|
113
115
|
def sexp_body from = 1
|
114
|
-
self.new.
|
116
|
+
self.new._concat(safe_idx(from..-1) || [])
|
115
117
|
end
|
116
118
|
|
117
119
|
def sexp_type= v
|
@@ -123,4 +125,24 @@ class Sexp
|
|
123
125
|
end
|
124
126
|
end unless Sexp.new.respond_to? :safe_asgn if ENV["STRICT_SEXP"]
|
125
127
|
|
128
|
+
if ENV["SP_DEBUG"] && !ENV["STRICT_SEXP"] then
|
129
|
+
class Sexp
|
130
|
+
mutators = %i[
|
131
|
+
[]= clear collect! compact! concat delete delete_at
|
132
|
+
delete_if drop drop_while fill flatten! replace insert
|
133
|
+
keep_if map! pop push reject! reverse! rotate! select!
|
134
|
+
shift shuffle! slice! sort! sort_by! transpose uniq!
|
135
|
+
unshift
|
136
|
+
]
|
137
|
+
|
138
|
+
mutators.each do |method|
|
139
|
+
define_method method do |*|
|
140
|
+
warn "Sexp modified by %p at %s" % [__method__, caller.first] if
|
141
|
+
$VERBOSE or (defined?(@hash) and @hash)
|
142
|
+
super
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
126
148
|
# :startdoc:
|
data/test/test_sexp.rb
CHANGED
@@ -193,6 +193,12 @@ class TestSexp < SexpTestCase # ZenTest FULL
|
|
193
193
|
assert_equal(3, count, "must find 3 a's in #{@sexp.inspect}")
|
194
194
|
end
|
195
195
|
|
196
|
+
def test_each_of_type_no_block
|
197
|
+
@sexp = s(:a, s(:b), s(:c), :d)
|
198
|
+
|
199
|
+
assert_equal [s(:b)], @sexp.each_of_type(:b).to_a
|
200
|
+
end
|
201
|
+
|
196
202
|
def test_equals2_array
|
197
203
|
refute_equal @sexp, [1, 2, 3] # Sexp == Array
|
198
204
|
assert_raises Minitest::Assertion do # Array == Sexp.
|
@@ -654,6 +660,18 @@ class TestSexp < SexpTestCase # ZenTest FULL
|
|
654
660
|
assert_equal DEEP_EXP, act.map { |k, _| k }
|
655
661
|
end
|
656
662
|
|
663
|
+
def test_deep_each_sexp_recursive
|
664
|
+
sexp = s(:array, s(:lit, 1), nil, 42, s(:array, s(:lit, 2)))
|
665
|
+
|
666
|
+
result = []
|
667
|
+
sexp.deep_each { |x| result << x.last if x.sexp_type == :lit }
|
668
|
+
assert_equal [1, 2], result
|
669
|
+
|
670
|
+
result = []
|
671
|
+
sexp.each_of_type(:lit) { |x| result << x.last }
|
672
|
+
assert_equal [1, 2], result
|
673
|
+
end
|
674
|
+
|
657
675
|
def test_deep_each_skip
|
658
676
|
exp = DEEP_EXP.first(3) + DEEP_EXP.last(4)
|
659
677
|
act = []
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sexp_processor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -10,9 +10,9 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDPjCCAiagAwIBAgIBBjANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
|
14
14
|
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
15
|
-
|
15
|
+
GRYDY29tMB4XDTIxMTIyMzIzMTkwNFoXDTIyMTIyMzIzMTkwNFowRTETMBEGA1UE
|
16
16
|
AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
|
17
17
|
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
|
18
18
|
b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
|
@@ -22,14 +22,14 @@ cert_chain:
|
|
22
22
|
qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
|
23
23
|
gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
24
24
|
HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
AQCKB5jfsuSnKb+t/Wrh3UpdkmX7TrEsjVmERC0pPqzQ5GQJgmEXDD7oMgaKXaAq
|
26
|
+
x2m+KSZDrqk7c8uho5OX6YMqg4KdxehfSLqqTZGoeV78qwf/jpPQZKTf+W9gUSJh
|
27
|
+
zsWpo4K50MP+QtdSbKXZwjAafpQ8hK0MnnZ/aeCsW9ov5vdXpYbf3dpg6ADXRGE7
|
28
|
+
lQY2y1tJ5/chqu6h7dQmnm2ABUqx9O+JcN9hbCYoA5i/EeubUEtFIh2w3SpO6YfB
|
29
|
+
JFmxn4h9YO/pVdB962BdBNNDia0kgIjI3ENnkLq0dKpYU3+F3KhEuTksLO0L6X/V
|
30
|
+
YsuyUzsMz6GQA4khyaMgKNSD
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
32
|
+
date: 2022-04-09 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rdoc
|
@@ -57,14 +57,14 @@ dependencies:
|
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '3.
|
60
|
+
version: '3.23'
|
61
61
|
type: :development
|
62
62
|
prerelease: false
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '3.
|
67
|
+
version: '3.23'
|
68
68
|
description: |-
|
69
69
|
sexp_processor branches from ParseTree bringing all the generic sexp
|
70
70
|
processing tools with it. Sexp, SexpProcessor, Environment, etc... all
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
|
-
rubygems_version: 3.
|
121
|
+
rubygems_version: 3.3.3
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: sexp_processor branches from ParseTree bringing all the generic sexp processing
|
metadata.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
���uY�NO�P~P�V�d_�5�$�l�3��7'����<�җd���P�h��#38
|
1
|
+
�*�fZ���P`:�����yp&8цlče��))��8B��B݄@�K�2½�/��w��W����;�7=����s�2���6��c���U��u���z��DiJ��u8�{�3$-[�$��\y��2���=�Ð�S�eЌ�9vF%:�-!�B��ė��|��}gF�f\e�ϭoS�>Rξ�ur�68��=�
|
2
|
+
��u����"��.6/��`�̮�P��/�|�&�pS"�l���-�UN$C���y6
|