sexp_processor 4.6.1 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.txt +7 -0
- data/lib/pt_testcase.rb +2 -2
- data/lib/sexp.rb +6 -2
- data/lib/sexp_processor.rb +1 -1
- data/test/test_sexp.rb +23 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8c330cf1162f2b13522bf591471d69bd2daac84
|
4
|
+
data.tar.gz: 9f7001a49fb152b343544319f3de1c36f94a6b08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 918c51196a0a5d9757b20215de228e73bb25e6df71e42aa8fa2bfcf4c3a058937ffd0bdd49e9fc9f6bbfba4d175aa935d946d8a911d91cbc6ed0a886922513ac
|
7
|
+
data.tar.gz: b111b71bb1145d390125f6fa287a8b837916d92974a5665fcdda44b8427554306ceed81baa8625f292cae300267c4697f0aefdf20ec32450d5fb52fd06c95af2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/lib/pt_testcase.rb
CHANGED
@@ -76,7 +76,7 @@ class ParseTreeTestCase < Minitest::Test
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def self.add_19tests name, hash
|
79
|
-
add_tests "#{name}
|
79
|
+
add_tests "#{name}__19_20_21_22_23", hash # HACK?
|
80
80
|
end
|
81
81
|
|
82
82
|
def self.add_19edgecases ruby, sexp, cases
|
@@ -101,7 +101,7 @@ class ParseTreeTestCase < Minitest::Test
|
|
101
101
|
testcases[verbose][klass] = testcases[nonverbose][klass]
|
102
102
|
end
|
103
103
|
|
104
|
-
VER_RE = "(1[89]|2[
|
104
|
+
VER_RE = "(1[89]|2[0123])"
|
105
105
|
|
106
106
|
def self.generate_test klass, node, data, input_name, output_name
|
107
107
|
klass.send :define_method, "test_#{node}" do
|
data/lib/sexp.rb
CHANGED
@@ -85,9 +85,10 @@ class Sexp < Array # ZenTest FULL
|
|
85
85
|
|
86
86
|
##
|
87
87
|
# Recursively enumerates the sexp yielding to +block+ for every element.
|
88
|
-
# TODO: test
|
89
88
|
|
90
89
|
def deep_each(&block)
|
90
|
+
return enum_for(:deep_each) unless block_given?
|
91
|
+
|
91
92
|
self.each_sexp do |sexp|
|
92
93
|
block[sexp]
|
93
94
|
sexp.deep_each(&block)
|
@@ -98,6 +99,8 @@ class Sexp < Array # ZenTest FULL
|
|
98
99
|
# Enumeratates the sexp yielding to +b+ when the node_type == +t+.
|
99
100
|
|
100
101
|
def each_of_type(t, &b)
|
102
|
+
return enum_for(:each_of_type) unless block_given?
|
103
|
+
|
101
104
|
each do | elem |
|
102
105
|
if Sexp === elem then
|
103
106
|
elem.each_of_type(t, &b)
|
@@ -108,9 +111,10 @@ class Sexp < Array # ZenTest FULL
|
|
108
111
|
|
109
112
|
##
|
110
113
|
# Recursively enumerates all sub-sexps skipping non-Sexp elements.
|
111
|
-
# TODO: test
|
112
114
|
|
113
115
|
def each_sexp
|
116
|
+
return enum_for(:each_sexp) unless block_given?
|
117
|
+
|
114
118
|
self.each do |sexp|
|
115
119
|
next unless Sexp === sexp
|
116
120
|
|
data/lib/sexp_processor.rb
CHANGED
data/test/test_sexp.rb
CHANGED
@@ -49,6 +49,7 @@ class TestSexp < SexpTestCase # ZenTest FULL
|
|
49
49
|
@processor = SexpProcessor.new
|
50
50
|
@sexp = @sexp_class.new(1, 2, 3)
|
51
51
|
@basic_sexp = s(:lasgn, :var, s(:lit, 42))
|
52
|
+
@complex_sexp = s(:block, s(:lasgn, :foo, s(:str, "foo")), s(:if, s(:and, s(:true), s(:lit, 1)), s(:if, s(:lvar, :foo), s(:str, "bar"), nil), s(:true)))
|
52
53
|
@re = s(:lit, 42)
|
53
54
|
@bad1 = s(:lit, 24)
|
54
55
|
@bad1 = s(:blah, 42)
|
@@ -310,6 +311,28 @@ class TestSexp < SexpTestCase # ZenTest FULL
|
|
310
311
|
def test_to_s
|
311
312
|
test_inspect
|
312
313
|
end
|
314
|
+
|
315
|
+
def test_each_sexp
|
316
|
+
result = []
|
317
|
+
@basic_sexp.each_sexp { |_, val| result << val }
|
318
|
+
assert_equal [42], result
|
319
|
+
end
|
320
|
+
|
321
|
+
def test_each_sexp_without_block
|
322
|
+
assert_kind_of Enumerator, @basic_sexp.each_sexp
|
323
|
+
assert_equal [42], @basic_sexp.each_sexp.map { |_, n| n }
|
324
|
+
end
|
325
|
+
|
326
|
+
def test_deep_each
|
327
|
+
result = []
|
328
|
+
@complex_sexp.deep_each { |s| result << s if s.first == :if }
|
329
|
+
assert_equal [:if, :if], result.map { |k, _| k }
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_deep_each_without_block
|
333
|
+
assert_kind_of Enumerator, @complex_sexp.deep_each
|
334
|
+
assert_equal [:if, :if], @complex_sexp.deep_each.select { |s, _| s == :if }.map { |k, _| k }
|
335
|
+
end
|
313
336
|
end
|
314
337
|
|
315
338
|
class TestSexpAny < SexpTestCase
|
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.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
qx3h45R1CAsObX0SQDIT+rRbQrtKz1GHIZTOFYvEJjUY1XmRTZupD3CJ8Q7sDqSy
|
30
30
|
NLq5jm1fq6Y9Uolu3RJbmycf
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2016-
|
32
|
+
date: 2016-02-19 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: minitest
|
metadata.gz.sig
CHANGED
Binary file
|