sexp_processor 4.9.0 → 4.10.0b1
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.tar.gz.sig +0 -0
- data/History.txt +45 -0
- data/Manifest.txt +1 -0
- data/README.txt +36 -7
- data/Rakefile +4 -0
- data/lib/composite_sexp_processor.rb +4 -4
- data/lib/pt_testcase.rb +21 -25
- data/lib/sexp.rb +1150 -107
- data/lib/sexp_processor.rb +127 -65
- data/lib/strict_sexp.rb +126 -0
- data/lib/unique.rb +7 -1
- data/test/test_composite_sexp_processor.rb +9 -12
- data/test/test_environment.rb +2 -2
- data/test/test_sexp.rb +1311 -113
- data/test/test_sexp_processor.rb +65 -52
- metadata +5 -4
- metadata.gz.sig +0 -0
data/test/test_sexp_processor.rb
CHANGED
@@ -1,78 +1,86 @@
|
|
1
1
|
$TESTING = true
|
2
2
|
|
3
|
-
|
4
|
-
require
|
5
|
-
|
6
|
-
|
3
|
+
if ENV["COV"]
|
4
|
+
require "simplecov"
|
5
|
+
SimpleCov.start do
|
6
|
+
add_filter "lib/sexp.rb"
|
7
|
+
add_filter "test"
|
8
|
+
end
|
9
|
+
warn "Running simplecov"
|
10
|
+
end
|
11
|
+
|
12
|
+
require "sexp_processor"
|
13
|
+
require "stringio"
|
14
|
+
require "minitest/autorun"
|
15
|
+
require "pp"
|
7
16
|
|
8
17
|
# Fake test classes:
|
9
18
|
|
10
19
|
class TestProcessor < SexpProcessor # ZenTest SKIP
|
11
20
|
attr_accessor :auto_shift_type
|
12
21
|
|
13
|
-
def
|
22
|
+
def initialize
|
23
|
+
super
|
24
|
+
self.require_empty = false
|
25
|
+
self.auto_shift_type = false
|
26
|
+
end
|
27
|
+
|
28
|
+
def process_acc1 exp
|
14
29
|
out = self.expected.new(:acc2, exp.thing_three, exp.thing_two, exp.thing_one)
|
15
30
|
exp.clear
|
16
|
-
|
31
|
+
out
|
17
32
|
end
|
18
33
|
|
19
|
-
def process_acc2
|
20
|
-
out =
|
34
|
+
def process_acc2 exp
|
35
|
+
out = s()
|
21
36
|
out << exp.thing_one
|
22
37
|
end
|
23
38
|
|
24
|
-
def process_specific
|
25
|
-
_ = exp
|
26
|
-
|
27
|
-
until exp.empty?
|
28
|
-
result.push process(exp.shift)
|
29
|
-
end
|
30
|
-
result
|
39
|
+
def process_specific exp
|
40
|
+
_, *data = exp
|
41
|
+
s(:blah, *data.map { |x| process x })
|
31
42
|
end
|
32
43
|
|
33
|
-
def process_strip
|
34
|
-
|
35
|
-
exp.clear
|
36
|
-
result
|
44
|
+
def process_strip exp
|
45
|
+
exp.deep_clone
|
37
46
|
end
|
38
47
|
|
39
|
-
def process_nonempty
|
48
|
+
def process_nonempty exp
|
40
49
|
s(*exp)
|
41
50
|
end
|
42
51
|
|
43
|
-
def process_broken
|
52
|
+
def process_broken exp
|
44
53
|
result = [*exp]
|
45
54
|
exp.clear
|
46
55
|
result
|
47
56
|
end
|
48
57
|
|
49
|
-
def process_expected
|
58
|
+
def process_expected exp
|
50
59
|
exp.clear
|
51
|
-
|
60
|
+
{}
|
52
61
|
end
|
53
62
|
|
54
|
-
def process_string
|
55
|
-
|
63
|
+
def process_string exp
|
64
|
+
exp.sexp_type
|
56
65
|
end
|
57
66
|
|
58
|
-
def rewrite_rewritable
|
59
|
-
|
67
|
+
def rewrite_rewritable exp # (a b c) => (a c b)
|
68
|
+
a, b, c = exp
|
69
|
+
s(a, c, b)
|
60
70
|
end
|
61
71
|
|
62
|
-
def process_rewritable
|
72
|
+
def process_rewritable exp
|
73
|
+
_, *data = exp
|
74
|
+
|
63
75
|
@n ||= 0
|
64
|
-
|
65
|
-
result = s(:rewritten)
|
66
|
-
until exp.empty?
|
67
|
-
result.push process(exp.shift)
|
68
|
-
end
|
69
|
-
result.push @n
|
76
|
+
result = s(:rewritten, *data.map { |x| process x }, @n)
|
70
77
|
@n += 1
|
78
|
+
|
71
79
|
result
|
72
80
|
end
|
73
81
|
|
74
|
-
def rewrite_major_rewrite
|
75
|
-
exp
|
82
|
+
def rewrite_major_rewrite exp
|
83
|
+
exp.sexp_type = :rewritable
|
76
84
|
exp
|
77
85
|
end
|
78
86
|
end
|
@@ -83,7 +91,7 @@ class TestProcessorDefault < SexpProcessor # ZenTest SKIP
|
|
83
91
|
self.default_method = :def_method
|
84
92
|
end
|
85
93
|
|
86
|
-
def def_method
|
94
|
+
def def_method exp
|
87
95
|
exp.clear
|
88
96
|
self.expected.new(42)
|
89
97
|
end
|
@@ -98,13 +106,13 @@ class TestSexpProcessor < Minitest::Test
|
|
98
106
|
end
|
99
107
|
|
100
108
|
def test_process_specific
|
101
|
-
a =
|
102
|
-
expected =
|
109
|
+
a = s(:specific, s(:x, 1), s(:y, 2), s(:z, 3))
|
110
|
+
expected = s(:blah, s(:x, 1), s(:y, 2), s(:z, 3))
|
103
111
|
assert_equal(expected, @processor.process(a))
|
104
112
|
end
|
105
113
|
|
106
114
|
def test_process_generic
|
107
|
-
a =
|
115
|
+
a = s(:blah, 1, 2, 3)
|
108
116
|
expected = a.deep_clone
|
109
117
|
assert_equal(expected, @processor.process(a))
|
110
118
|
end
|
@@ -122,7 +130,7 @@ class TestSexpProcessor < Minitest::Test
|
|
122
130
|
@processor.warn_on_default = false
|
123
131
|
|
124
132
|
assert_raises SexpTypeError do
|
125
|
-
@processor.process(
|
133
|
+
@processor.process(s(:broken, 1, 2, 3))
|
126
134
|
end
|
127
135
|
end
|
128
136
|
|
@@ -131,7 +139,7 @@ class TestSexpProcessor < Minitest::Test
|
|
131
139
|
@processor.unsupported << :strip
|
132
140
|
|
133
141
|
assert_raises UnsupportedNodeError do
|
134
|
-
@processor.process(
|
142
|
+
@processor.process(s(:whatever))
|
135
143
|
end
|
136
144
|
end
|
137
145
|
|
@@ -139,29 +147,32 @@ class TestSexpProcessor < Minitest::Test
|
|
139
147
|
@processor.strict = true
|
140
148
|
@processor.unsupported = [ :unsupported ]
|
141
149
|
assert_raises UnsupportedNodeError do
|
142
|
-
@processor.process(
|
150
|
+
@processor.process(s(:unsupported, 42))
|
143
151
|
end
|
144
152
|
end
|
145
153
|
|
146
154
|
def test_strict
|
147
155
|
@processor.strict = true
|
148
156
|
assert_raises UnknownNodeError do
|
149
|
-
@processor.process(
|
157
|
+
@processor.process(s(:blah, 1, 2, 3))
|
150
158
|
end
|
151
159
|
end
|
152
|
-
|
160
|
+
|
161
|
+
def test_strict=; skip; end # handled
|
153
162
|
|
154
163
|
def test_require_empty_false
|
155
164
|
@processor.require_empty = false
|
156
165
|
|
157
|
-
assert_equal s(:nonempty, 1, 2, 3), @processor.process(
|
166
|
+
assert_equal s(:nonempty, 1, 2, 3), @processor.process(s(:nonempty, 1, 2, 3))
|
158
167
|
end
|
159
168
|
|
160
169
|
def test_require_empty_true
|
161
170
|
assert_raises NotEmptyError do
|
162
|
-
@processor.
|
171
|
+
@processor.require_empty = true
|
172
|
+
@processor.process(s(:nonempty, 1, 2, 3))
|
163
173
|
end
|
164
174
|
end
|
175
|
+
|
165
176
|
def test_require_empty=; skip; end # handled
|
166
177
|
|
167
178
|
def test_process_strip
|
@@ -189,7 +200,6 @@ class TestSexpProcessor < Minitest::Test
|
|
189
200
|
expect = s(:rewritable, 2, 1)
|
190
201
|
result = @processor.rewrite(insert)
|
191
202
|
assert_equal(expect, result)
|
192
|
-
assert_equal(s(2), insert) # post-processing
|
193
203
|
end
|
194
204
|
|
195
205
|
def test_process_rewrite
|
@@ -256,6 +266,7 @@ class TestSexpProcessor < Minitest::Test
|
|
256
266
|
@processor.auto_shift_type = true
|
257
267
|
assert_equal(true, @processor.auto_shift_type)
|
258
268
|
end
|
269
|
+
|
259
270
|
def test_auto_shift_type_equal; skip; end # handled
|
260
271
|
|
261
272
|
def test_default_method
|
@@ -264,12 +275,13 @@ class TestSexpProcessor < Minitest::Test
|
|
264
275
|
@processor.default_method = :something
|
265
276
|
assert_equal :something, @processor.default_method
|
266
277
|
end
|
278
|
+
|
267
279
|
def test_default_method=; skip; end # handled
|
268
280
|
|
269
281
|
def test_expected
|
270
282
|
assert_equal Sexp, @processor.expected
|
271
283
|
assert_raises SexpTypeError do
|
272
|
-
@processor.process(
|
284
|
+
@processor.process(s(:expected)) # should raise
|
273
285
|
end
|
274
286
|
|
275
287
|
@processor.process(s(:str, "string")) # shouldn't raise
|
@@ -282,8 +294,9 @@ class TestSexpProcessor < Minitest::Test
|
|
282
294
|
@processor.process(s(:string, "string")) # should raise
|
283
295
|
end
|
284
296
|
|
285
|
-
@processor.process(
|
297
|
+
@processor.process(s(:expected)) # shouldn't raise
|
286
298
|
end
|
299
|
+
|
287
300
|
def test_expected=; skip; end # handled
|
288
301
|
|
289
302
|
# Not Testing:
|
@@ -323,7 +336,7 @@ class TestMethodBasedSexpProcessor < Minitest::Test
|
|
323
336
|
|
324
337
|
assert_empty processor.method_stack
|
325
338
|
|
326
|
-
expected = {"main#xxx" => "file.rb:42"}
|
339
|
+
expected = { "main#xxx" => "file.rb:42" }
|
327
340
|
assert_equal expected, processor.method_locations
|
328
341
|
end
|
329
342
|
|
@@ -336,7 +349,7 @@ class TestMethodBasedSexpProcessor < Minitest::Test
|
|
336
349
|
|
337
350
|
assert_empty processor.method_stack
|
338
351
|
|
339
|
-
expected = {"main#xxx" => "file.rb:42-44"}
|
352
|
+
expected = { "main#xxx" => "file.rb:42-44" }
|
340
353
|
assert_equal expected, processor.method_locations
|
341
354
|
end
|
342
355
|
|
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.10.0b1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
E4oJcnPkJAr0rw504JGtlZtONZQblwmRJOIdXzolaE3NRGUzGVOUSptZppAKiavY
|
31
31
|
fO6tdKQc/5RfA8oQEkg8hrxA5PQSz4TOFJGLpFvIapEk6tMruQ0bHgkhr9auXg==
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2017-
|
33
|
+
date: 2017-06-13 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rdoc
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- lib/pt_testcase.rb
|
82
82
|
- lib/sexp.rb
|
83
83
|
- lib/sexp_processor.rb
|
84
|
+
- lib/strict_sexp.rb
|
84
85
|
- lib/unique.rb
|
85
86
|
- test/test_composite_sexp_processor.rb
|
86
87
|
- test/test_environment.rb
|
@@ -103,9 +104,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
104
|
version: '0'
|
104
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
106
|
requirements:
|
106
|
-
- - "
|
107
|
+
- - ">"
|
107
108
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
109
|
+
version: 1.3.1
|
109
110
|
requirements: []
|
110
111
|
rubyforge_project:
|
111
112
|
rubygems_version: 2.6.8
|
metadata.gz.sig
CHANGED
Binary file
|