skeem 0.2.21 → 0.2.22
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
- data/.rubocop.yml +33 -337
- data/CHANGELOG.md +7 -0
- data/LICENSE.txt +1 -1
- data/lib/skeem/grammar.rb +13 -13
- data/lib/skeem/interpreter.rb +1 -1
- data/lib/skeem/primitive/primitive_builder.rb +1 -1
- data/lib/skeem/primitive/primitive_procedure.rb +1 -1
- data/lib/skeem/runtime.rb +2 -0
- data/lib/skeem/s_expr_nodes.rb +5 -3
- data/lib/skeem/tokenizer.rb +15 -20
- data/lib/skeem/version.rb +1 -1
- data/lib/skeem.rb +2 -2
- data/skeem.gemspec +8 -5
- data/spec/skeem/datum_dsl_spec.rb +50 -50
- data/spec/skeem/element_visitor_spec.rb +108 -108
- data/spec/skeem/interpreter_spec.rb +171 -169
- data/spec/skeem/lambda_spec.rb +27 -27
- data/spec/skeem/parser_spec.rb +27 -25
- data/spec/skeem/primitive/primitive_builder_spec.rb +127 -131
- data/spec/skeem/primitive/primitive_procedure_spec.rb +28 -28
- data/spec/skeem/runtime_spec.rb +52 -51
- data/spec/skeem/s_expr_nodes_spec.rb +31 -31
- data/spec/skeem/skm_compound_datum_spec.rb +36 -35
- data/spec/skeem/skm_element_spec.rb +35 -34
- data/spec/skeem/skm_empty_list_spec.rb +19 -19
- data/spec/skeem/skm_frame_spec.rb +49 -46
- data/spec/skeem/skm_pair_spec.rb +93 -93
- data/spec/skeem/skm_procedure_exec_spec.rb +11 -11
- data/spec/skeem/skm_simple_datum_spec.rb +102 -95
- data/spec/skeem/skm_unary_expression_spec.rb +60 -61
- data/spec/skeem/tokenizer_spec.rb +52 -52
- data/spec/skeem_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -2
- metadata +62 -18
data/lib/skeem/tokenizer.rb
CHANGED
@@ -25,7 +25,7 @@ module Skeem
|
|
25
25
|
# @return [Integer] Offset of start of current line
|
26
26
|
attr_reader(:line_start)
|
27
27
|
|
28
|
-
|
28
|
+
Lexeme2name = {
|
29
29
|
"'" => 'APOSTROPHE',
|
30
30
|
'=>' => 'ARROW',
|
31
31
|
'`' => 'GRAVE_ACCENT',
|
@@ -40,7 +40,7 @@ module Skeem
|
|
40
40
|
}.freeze
|
41
41
|
|
42
42
|
# Here are all the implemented Scheme keywords (in uppercase)
|
43
|
-
|
43
|
+
Keywords = %w[
|
44
44
|
BEGIN
|
45
45
|
COND
|
46
46
|
DEFINE
|
@@ -66,11 +66,11 @@ module Skeem
|
|
66
66
|
# @param source [String] Skeem text to tokenize.
|
67
67
|
def initialize(source)
|
68
68
|
@scanner = StringScanner.new('')
|
69
|
-
|
69
|
+
reset(source)
|
70
70
|
end
|
71
71
|
|
72
72
|
# @param source [String] Skeem text to tokenize.
|
73
|
-
def
|
73
|
+
def reset(source)
|
74
74
|
@scanner.string = source
|
75
75
|
@lineno = 1
|
76
76
|
@line_start = 0
|
@@ -84,7 +84,7 @@ module Skeem
|
|
84
84
|
tok_sequence << token unless token.nil?
|
85
85
|
end
|
86
86
|
|
87
|
-
|
87
|
+
tok_sequence
|
88
88
|
end
|
89
89
|
|
90
90
|
private
|
@@ -100,11 +100,11 @@ module Skeem
|
|
100
100
|
|
101
101
|
if "()'`".include? curr_ch
|
102
102
|
# Delimiters, separators => single character token
|
103
|
-
token = build_token(
|
103
|
+
token = build_token(Lexeme2name[curr_ch], scanner.getch)
|
104
104
|
elsif (lexeme = scanner.scan(/(?:\.|_)(?=\s|\()/)) # Single char occurring alone
|
105
|
-
token = build_token(
|
105
|
+
token = build_token(Lexeme2name[curr_ch], scanner.getch)
|
106
106
|
elsif (lexeme = scanner.scan(/(?:,@?)|(?:=>)|(?:\.\.\.)/))
|
107
|
-
token = build_token(
|
107
|
+
token = build_token(Lexeme2name[lexeme], lexeme)
|
108
108
|
elsif (token = recognize_char_token)
|
109
109
|
# Do nothing
|
110
110
|
elsif (lexeme = scanner.scan(/[+-]?[0-9]+\/[0-9]+(?=\s|[|()";]|$)/))
|
@@ -121,7 +121,7 @@ module Skeem
|
|
121
121
|
elsif (lexeme = scanner.scan(/"(?:\\"|[^"])*"/)) # Double quotes literal?
|
122
122
|
token = build_token('STRING_LIT', lexeme)
|
123
123
|
elsif (lexeme = scanner.scan(/[a-zA-Z!$%&*\/:<=>?@^_~][a-zA-Z0-9!$%&*+-.\/:<=>?@^_~+-]*/))
|
124
|
-
keyw =
|
124
|
+
keyw = Keywords[lexeme.upcase]
|
125
125
|
tok_type = keyw || 'IDENTIFIER'
|
126
126
|
token = build_token(tok_type, lexeme)
|
127
127
|
elsif (lexeme = scanner.scan(/\|(?:[^|])*\|/)) # Vertical bar delimited
|
@@ -142,7 +142,7 @@ module Skeem
|
|
142
142
|
raise ScanError, "Unknown token #{erroneous} on line #{lineno}"
|
143
143
|
end
|
144
144
|
|
145
|
-
|
145
|
+
token
|
146
146
|
end
|
147
147
|
|
148
148
|
# rubocop: enable Lint/DuplicateBranch
|
@@ -160,15 +160,15 @@ other literal data (section 2.4).
|
|
160
160
|
when /^#true|false|t|f$/
|
161
161
|
token = build_token('BOOLEAN', aLexeme)
|
162
162
|
when '#('
|
163
|
-
token = build_token(
|
163
|
+
token = build_token(Lexeme2name[aLexeme], aLexeme)
|
164
164
|
end
|
165
165
|
|
166
|
-
|
166
|
+
token
|
167
167
|
end
|
168
168
|
|
169
169
|
def recognize_char_token
|
170
170
|
token = nil
|
171
|
-
if (lexeme = scanner.scan(
|
171
|
+
if (lexeme = scanner.scan("#\\"))
|
172
172
|
if (lexeme = scanner.scan(/(?:alarm|backspace|delete|escape|newline|null|return|space|tab)/))
|
173
173
|
token = build_token('CHAR', lexeme, :name)
|
174
174
|
elsif (lexeme = scanner.scan(/x[0-9a-fA-F]+/))
|
@@ -193,7 +193,7 @@ other literal data (section 2.4).
|
|
193
193
|
raise e
|
194
194
|
end
|
195
195
|
|
196
|
-
|
196
|
+
token
|
197
197
|
end
|
198
198
|
|
199
199
|
def convert_to(aLexeme, aSymbolName, aFormat)
|
@@ -218,7 +218,7 @@ other literal data (section 2.4).
|
|
218
218
|
value = aLexeme
|
219
219
|
end
|
220
220
|
|
221
|
-
|
221
|
+
[value, symb]
|
222
222
|
end
|
223
223
|
|
224
224
|
def to_boolean(aLexeme, _format)
|
@@ -333,8 +333,6 @@ other literal data (section 2.4).
|
|
333
333
|
end
|
334
334
|
|
335
335
|
def skip_intertoken_spaces
|
336
|
-
pre_pos = scanner.pos
|
337
|
-
|
338
336
|
loop do
|
339
337
|
ws_found = scanner.skip(/[ \t\f]+/) ? true : false
|
340
338
|
nl_found = scanner.skip(/(?:\r\n)|\r|\n/)
|
@@ -354,9 +352,6 @@ other literal data (section 2.4).
|
|
354
352
|
end
|
355
353
|
break unless ws_found || cmt_found
|
356
354
|
end
|
357
|
-
|
358
|
-
curr_pos = scanner.pos
|
359
|
-
return if curr_pos == pre_pos
|
360
355
|
end
|
361
356
|
|
362
357
|
def skip_block_comment
|
data/lib/skeem/version.rb
CHANGED
data/lib/skeem.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# This file acts as a jumping-off point for loading dependencies expected
|
5
5
|
# for a Skeem client.
|
6
6
|
|
7
|
-
require_relative '
|
8
|
-
require_relative '
|
7
|
+
require_relative 'skeem/version'
|
8
|
+
require_relative 'skeem/interpreter'
|
9
9
|
|
10
10
|
# End of file
|
data/skeem.gemspec
CHANGED
@@ -54,7 +54,8 @@ DESCR
|
|
54
54
|
SUMMARY
|
55
55
|
spec.homepage = 'https://github.com/famished-tiger/Skeem'
|
56
56
|
spec.license = 'MIT'
|
57
|
-
spec.required_ruby_version = '>=
|
57
|
+
spec.required_ruby_version = '>= 3.1.0'
|
58
|
+
spec.metadata = { 'rubygems_mfa_required' => 'true' }
|
58
59
|
|
59
60
|
spec.bindir = 'bin'
|
60
61
|
spec.executables << 'skeem'
|
@@ -62,10 +63,12 @@ SUMMARY
|
|
62
63
|
PkgExtending.pkg_files(spec)
|
63
64
|
PkgExtending.pkg_documentation(spec)
|
64
65
|
# Runtime dependencies
|
65
|
-
spec.add_dependency 'rley', '~> 0.
|
66
|
+
spec.add_dependency 'rley', '~> 0.9', '>= 0.9.02'
|
66
67
|
|
67
68
|
# Development dependencies
|
68
|
-
spec.add_development_dependency '
|
69
|
-
spec.add_development_dependency '
|
70
|
-
spec.add_development_dependency '
|
69
|
+
spec.add_development_dependency 'benchmark', '~> 0.4.0'
|
70
|
+
spec.add_development_dependency 'bundler', '~> 2.4', '>= 2.4.1'
|
71
|
+
spec.add_development_dependency 'ostruct', '~> 0.6.1'
|
72
|
+
spec.add_development_dependency 'rake', '~> 13'
|
73
|
+
spec.add_development_dependency 'rspec', '~> 3', '>= 3.10.0'
|
71
74
|
end
|
@@ -8,9 +8,9 @@ require_relative '../../lib/skeem/datum_dsl'
|
|
8
8
|
|
9
9
|
module Skeem
|
10
10
|
describe DatumDSL do
|
11
|
-
subject do
|
11
|
+
subject(:dsl) do
|
12
12
|
obj = Object.new
|
13
|
-
obj.extend(
|
13
|
+
obj.extend(described_class) # use the mixin module
|
14
14
|
obj
|
15
15
|
end
|
16
16
|
|
@@ -83,140 +83,140 @@ module Skeem
|
|
83
83
|
end
|
84
84
|
|
85
85
|
context 'Simple datums:' do
|
86
|
-
it '
|
86
|
+
it 'concerts boolean literals' do
|
87
87
|
boolean_tests.each do |(literal, predicted)|
|
88
|
-
expect(
|
88
|
+
expect(dsl.boolean(literal)).to eq(predicted)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
it '
|
92
|
+
it 'concerts integer literals' do
|
93
93
|
integer_tests.each do |(literal, predicted)|
|
94
|
-
expect(
|
94
|
+
expect(dsl.integer(literal)).to eq(predicted)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
it '
|
98
|
+
it 'concerts rational literals' do
|
99
99
|
rational_tests.each do |(literal, predicted)|
|
100
|
-
expect(
|
100
|
+
expect(dsl.rational(literal)).to eq(predicted)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
it '
|
104
|
+
it 'concerts real number literals' do
|
105
105
|
real_tests.each do |(literal, predicted)|
|
106
|
-
expect(
|
106
|
+
expect(dsl.real(literal)).to eq(predicted)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
it '
|
110
|
+
it 'concerts string literals' do
|
111
111
|
string_tests.each do |(literal, predicted)|
|
112
|
-
expect(
|
112
|
+
expect(dsl.string(literal)).to eq(predicted)
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
|
-
it '
|
116
|
+
it 'concerts identifier literals' do
|
117
117
|
identifier_tests.each do |(literal, predicted)|
|
118
|
-
expect(
|
118
|
+
expect(dsl.identifier(literal)).to eq(predicted)
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end # context
|
122
122
|
|
123
123
|
|
124
124
|
context 'Compound datums:' do
|
125
|
-
it '
|
126
|
-
result =
|
127
|
-
expect(result).to
|
125
|
+
it 'concerts empty array into one-member list' do
|
126
|
+
result = dsl.list([])
|
127
|
+
expect(result).to be_a(SkmEmptyList)
|
128
128
|
expect(result).to be_null
|
129
129
|
end
|
130
130
|
|
131
|
-
it '
|
131
|
+
it 'concerts array of simple datums into list' do
|
132
132
|
literals = simple_datum_tests.map { |(datum, _predicted)| datum }
|
133
133
|
predictions = simple_datum_tests.map { |(_datum, predicted)| predicted }
|
134
|
-
list_result =
|
135
|
-
expect(list_result).to
|
134
|
+
list_result = dsl.list(literals)
|
135
|
+
expect(list_result).to be_a(SkmPair)
|
136
136
|
list_result.to_a.each_with_index do |member, index|
|
137
137
|
expect(member).to eq(predictions[index])
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
-
it '
|
142
|
-
result =
|
143
|
-
expect(result).to
|
141
|
+
it 'concerts a single datum into one-member list' do
|
142
|
+
result = dsl.list('123')
|
143
|
+
expect(result).to be_a(SkmPair)
|
144
144
|
expect(result.car).to eq(123)
|
145
145
|
end
|
146
146
|
|
147
|
-
it '
|
148
|
-
result =
|
149
|
-
expect(result).to
|
147
|
+
it 'concerts empty array into one-member list' do
|
148
|
+
result = dsl.vector([])
|
149
|
+
expect(result).to be_a(SkmVector)
|
150
150
|
expect(result.members).to be_empty
|
151
151
|
end
|
152
152
|
|
153
153
|
|
154
|
-
it '
|
154
|
+
it 'concerts array of simple datums into vector' do
|
155
155
|
literals = simple_datum_tests.map { |(datum, _predicted)| datum }
|
156
156
|
predictions = simple_datum_tests.map { |(_datum, predicted)| predicted }
|
157
|
-
vector_result =
|
158
|
-
expect(vector_result).to
|
157
|
+
vector_result = dsl.vector(literals)
|
158
|
+
expect(vector_result).to be_a(SkmVector)
|
159
159
|
vector_result.members.each_with_index do |member, index|
|
160
160
|
expect(member).to eq(predictions[index])
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
164
|
-
it '
|
165
|
-
result =
|
166
|
-
expect(result).to
|
164
|
+
it 'concerts a single datum into one-member vector' do
|
165
|
+
result = dsl.vector('123')
|
166
|
+
expect(result).to be_a(SkmVector)
|
167
167
|
expect(result.members.first).to eq(123)
|
168
168
|
end
|
169
169
|
end # context
|
170
170
|
|
171
171
|
context 'Arbitrary datums:' do
|
172
|
-
it '
|
172
|
+
it 'recognizes & convert booleans' do
|
173
173
|
boolean_tests.each do |(literal, predicted)|
|
174
|
-
expect(
|
174
|
+
expect(dsl.to_datum(literal)).to eq(predicted)
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
|
-
it '
|
178
|
+
it 'recognizes & convert integer literals' do
|
179
179
|
integer_tests.each do |(literal, predicted)|
|
180
|
-
expect(
|
180
|
+
expect(dsl.to_datum(literal)).to eq(predicted)
|
181
181
|
end
|
182
182
|
end
|
183
183
|
|
184
|
-
it '
|
184
|
+
it 'recognizes & convert rational literals' do
|
185
185
|
rational_tests.each do |(literal, predicted)|
|
186
|
-
expect(
|
186
|
+
expect(dsl.to_datum(literal)).to eq(predicted)
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
190
|
-
it '
|
190
|
+
it 'recognizes & convert real number literals' do
|
191
191
|
real_tests.each do |(literal, predicted)|
|
192
|
-
expect(
|
192
|
+
expect(dsl.to_datum(literal)).to eq(predicted)
|
193
193
|
end
|
194
194
|
end
|
195
195
|
|
196
|
-
it '
|
196
|
+
it 'recognizes & convert string literals' do
|
197
197
|
string_tests.each do |(literal, predicted)|
|
198
|
-
expect(
|
198
|
+
expect(dsl.to_datum(literal)).to eq(predicted)
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
202
|
-
it '
|
202
|
+
it 'concerts nested compound datums' do
|
203
203
|
literals = [
|
204
204
|
'false', '123', '-1.41',
|
205
205
|
'foo', SkmVector.new(['uno', '2', 3.0]), 'bar'
|
206
206
|
]
|
207
|
-
result =
|
208
|
-
expect(result).to
|
207
|
+
result = dsl.list(literals)
|
208
|
+
expect(result).to be_a(SkmPair)
|
209
209
|
expect(result.to_a).to eq([false, 123, -1.41, 'foo', ['uno', 2, 3], 'bar'])
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
213
|
-
it '
|
214
|
-
f =
|
215
|
-
g =
|
216
|
-
one_list =
|
213
|
+
it 'duplicates a given list' do
|
214
|
+
f = dsl.identifier('f')
|
215
|
+
g = dsl.identifier('g')
|
216
|
+
one_list = dsl.list([f, g])
|
217
217
|
expect(one_list).to be_list
|
218
218
|
expect(one_list.to_a).to eq([f, g])
|
219
|
-
duplicate =
|
219
|
+
duplicate = dsl.to_datum(one_list)
|
220
220
|
expect(duplicate).to be_list
|
221
221
|
# $stderr.puts duplicate.inspect
|
222
222
|
expect(duplicate.to_a).to eq([f, g])
|
@@ -19,19 +19,19 @@ module Skeem
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# Default instantiation rule
|
22
|
-
subject {
|
22
|
+
subject(:visitor) { described_class.new(simple_datum) }
|
23
23
|
|
24
24
|
context 'Standard creation & initialization:' do
|
25
|
-
it '
|
26
|
-
expect {
|
25
|
+
it 'is initialized with a parse tree argument' do
|
26
|
+
expect { described_class.new(simple_datum) }.not_to raise_error
|
27
27
|
end
|
28
28
|
|
29
|
-
it '
|
30
|
-
expect(
|
29
|
+
it 'knows the parse tree to visit' do
|
30
|
+
expect(visitor.root).to eq(simple_datum)
|
31
31
|
end
|
32
32
|
|
33
|
-
it "
|
34
|
-
expect(
|
33
|
+
it "doesn't have subscribers at start" do
|
34
|
+
expect(visitor.subscribers).to be_empty
|
35
35
|
end
|
36
36
|
end # context
|
37
37
|
|
@@ -39,137 +39,137 @@ module Skeem
|
|
39
39
|
let(:listener1) { double('fake-subscriber1') }
|
40
40
|
let(:listener2) { double('fake-subscriber2') }
|
41
41
|
|
42
|
-
it '
|
43
|
-
|
44
|
-
expect(
|
45
|
-
expect(
|
42
|
+
it 'allows subscriptions' do
|
43
|
+
visitor.subscribe(listener1)
|
44
|
+
expect(visitor.subscribers.size).to eq(1)
|
45
|
+
expect(visitor.subscribers).to eq([listener1])
|
46
46
|
|
47
|
-
|
48
|
-
expect(
|
49
|
-
expect(
|
47
|
+
visitor.subscribe(listener2)
|
48
|
+
expect(visitor.subscribers.size).to eq(2)
|
49
|
+
expect(visitor.subscribers).to eq([listener1, listener2])
|
50
50
|
end
|
51
51
|
|
52
|
-
it '
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
expect(
|
57
|
-
expect(
|
58
|
-
|
59
|
-
expect(
|
52
|
+
it 'allows un-subcriptions' do
|
53
|
+
visitor.subscribe(listener1)
|
54
|
+
visitor.subscribe(listener2)
|
55
|
+
visitor.unsubscribe(listener2)
|
56
|
+
expect(visitor.subscribers.size).to eq(1)
|
57
|
+
expect(visitor.subscribers).to eq([listener1])
|
58
|
+
visitor.unsubscribe(listener1)
|
59
|
+
expect(visitor.subscribers).to be_empty
|
60
60
|
end
|
61
61
|
end # context
|
62
62
|
|
63
63
|
context 'Visiting simple datum:' do
|
64
64
|
let(:runtime) { double('fake-runtime') }
|
65
65
|
|
66
|
-
it '
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
expect(
|
66
|
+
it 'allows the visit of simple datum object' do
|
67
|
+
visitor.subscribe(listener)
|
68
|
+
allow(listener).to receive(:before_simple_datum).with(runtime, simple_datum)
|
69
|
+
allow(listener).to receive(:after_simple_datum).with(runtime, simple_datum)
|
70
|
+
visitor.start(runtime)
|
71
|
+
expect(visitor.runtime).to eq(runtime)
|
72
72
|
end
|
73
73
|
end # context
|
74
74
|
|
75
75
|
context 'Visiting compound datum:' do
|
76
76
|
let(:runtime) { double('fake-runtime') }
|
77
77
|
|
78
|
-
it '
|
78
|
+
it 'allows the visit of a flat list' do
|
79
79
|
ls = list ['#false', 3, 'foo']
|
80
|
-
instance =
|
80
|
+
instance = described_class.new(ls)
|
81
81
|
instance.subscribe(listener)
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
82
|
+
allow(listener).to receive(:before_pair).with(runtime, ls)
|
83
|
+
allow(listener).to receive(:before_car).with(runtime, ls, ls.car)
|
84
|
+
allow(listener).to receive(:before_simple_datum).with(runtime, ls.car)
|
85
|
+
allow(listener).to receive(:after_simple_datum).with(runtime, ls.car)
|
86
|
+
allow(listener).to receive(:after_car).with(runtime, ls, ls.car)
|
87
|
+
allow(listener).to receive(:before_cdr).with(runtime, ls, ls.cdr)
|
88
|
+
allow(listener).to receive(:before_pair).with(runtime, ls.cdr)
|
89
|
+
allow(listener).to receive(:before_car).with(runtime, ls.cdr, ls.cdr.car)
|
90
|
+
allow(listener).to receive(:before_simple_datum).with(runtime, ls.cdr.car)
|
91
|
+
allow(listener).to receive(:after_simple_datum).with(runtime, ls.cdr.car)
|
92
|
+
allow(listener).to receive(:after_car).with(runtime, ls.cdr, ls.cdr.car)
|
93
|
+
allow(listener).to receive(:before_cdr).with(runtime, ls.cdr, ls.cdr.cdr)
|
94
|
+
allow(listener).to receive(:before_pair).with(runtime, ls.cdr.cdr)
|
95
|
+
allow(listener).to receive(:before_car).with(runtime, ls.cdr.cdr, ls.cdr.cdr.car)
|
96
|
+
allow(listener).to receive(:before_simple_datum).with(runtime, ls.cdr.cdr.car)
|
97
|
+
allow(listener).to receive(:after_simple_datum).with(runtime, ls.cdr.cdr.car)
|
98
|
+
allow(listener).to receive(:after_car).with(runtime, ls.cdr.cdr, ls.cdr.cdr.car)
|
99
|
+
allow(listener).to receive(:before_cdr).with(runtime, ls.cdr.cdr, ls.cdr.cdr.cdr)
|
100
|
+
allow(listener).to receive(:before_empty_list).with(runtime, ls.cdr.cdr.cdr)
|
101
|
+
allow(listener).to receive(:after_empty_list).with(runtime, ls.cdr.cdr.cdr)
|
102
|
+
allow(listener).to receive(:after_cdr).with(runtime, ls.cdr.cdr, ls.cdr.cdr.cdr)
|
103
|
+
allow(listener).to receive(:after_pair).with(runtime, ls.cdr.cdr)
|
104
|
+
allow(listener).to receive(:after_cdr).with(runtime, ls.cdr, ls.cdr.cdr)
|
105
|
+
allow(listener).to receive(:after_pair).with(runtime, ls.cdr)
|
106
|
+
allow(listener).to receive(:after_cdr).with(runtime, ls, ls.cdr)
|
107
|
+
allow(listener).to receive(:after_pair).with(runtime, ls)
|
108
108
|
instance.start(runtime)
|
109
109
|
end
|
110
110
|
|
111
|
-
it '
|
111
|
+
it 'allows the visit of a flat vector' do
|
112
112
|
vec = vector ['#false', 3, 'foo']
|
113
|
-
instance =
|
113
|
+
instance = described_class.new(vec)
|
114
114
|
instance.subscribe(listener)
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
115
|
+
allow(listener).to receive(:before_compound_datum).with(runtime, vec)
|
116
|
+
allow(listener).to receive(:before_children).with(runtime, vec, vec.members)
|
117
|
+
allow(listener).to receive(:before_simple_datum).with(runtime, vec.members[0])
|
118
|
+
allow(listener).to receive(:after_simple_datum).with(runtime, vec.members[0])
|
119
|
+
allow(listener).to receive(:before_simple_datum).with(runtime, vec.members[1])
|
120
|
+
allow(listener).to receive(:after_simple_datum).with(runtime, vec.members[1])
|
121
|
+
allow(listener).to receive(:before_simple_datum).with(runtime, vec.members[2])
|
122
|
+
allow(listener).to receive(:after_simple_datum).with(runtime, vec.members[2])
|
123
|
+
allow(listener).to receive(:after_children).with(runtime, vec, vec.members)
|
124
|
+
allow(listener).to receive(:after_compound_datum).with(runtime, vec)
|
125
125
|
instance.start(runtime)
|
126
126
|
end
|
127
127
|
|
128
|
-
it '
|
128
|
+
it 'allows the visit of a nested compound datum' do
|
129
129
|
nested_list = list %w[uno twei three']
|
130
130
|
vec = vector ['#false', 3, nested_list, 'foo']
|
131
|
-
instance =
|
131
|
+
instance = described_class.new(vec)
|
132
132
|
instance.subscribe(listener)
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
133
|
+
allow(listener).to receive(:before_compound_datum).with(runtime, vec)
|
134
|
+
allow(listener).to receive(:before_children).with(runtime, vec, vec.members)
|
135
|
+
allow(listener).to receive(:before_simple_datum).with(runtime, vec.members[0])
|
136
|
+
allow(listener).to receive(:after_simple_datum).with(runtime, vec.members[0])
|
137
|
+
allow(listener).to receive(:before_simple_datum).with(runtime, vec.members[1])
|
138
|
+
allow(listener).to receive(:after_simple_datum).with(runtime, vec.members[1])
|
139
|
+
|
140
|
+
allow(listener).to receive(:before_pair).with(runtime, nested_list)
|
141
|
+
allow(listener).to receive(:before_car).with(runtime, nested_list, nested_list.car)
|
142
142
|
expect(nested_list.car).to eq('uno')
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
143
|
+
allow(listener).to receive(:before_simple_datum).with(runtime, nested_list.car)
|
144
|
+
allow(listener).to receive(:after_simple_datum).with(runtime, nested_list.car)
|
145
|
+
allow(listener).to receive(:after_car).with(runtime, nested_list, nested_list.car)
|
146
|
+
allow(listener).to receive(:before_cdr).with(runtime, nested_list, nested_list.cdr)
|
147
|
+
allow(listener).to receive(:before_pair).with(runtime, nested_list.cdr)
|
148
|
+
allow(listener).to receive(:before_car).with(runtime, nested_list.cdr, nested_list.cdr.car)
|
149
|
+
allow(listener).to receive(:before_simple_datum).with(runtime, nested_list.cdr.car)
|
150
|
+
allow(listener).to receive(:after_simple_datum).with(runtime, nested_list.cdr.car)
|
151
|
+
allow(listener).to receive(:after_car).with(runtime, nested_list.cdr, nested_list.cdr.car)
|
152
|
+
allow(listener).to receive(:before_cdr).with(runtime, nested_list.cdr, nested_list.cdr.cdr)
|
153
|
+
allow(listener).to receive(:before_pair).with(runtime, nested_list.cdr.cdr)
|
154
|
+
allow(listener).to receive(:before_car).with(runtime, nested_list.cdr.cdr, nested_list.cdr.cdr.car)
|
155
|
+
allow(listener).to receive(:before_simple_datum).with(runtime, nested_list.cdr.cdr.car)
|
156
|
+
allow(listener).to receive(:after_simple_datum).with(runtime, nested_list.cdr.cdr.car)
|
157
|
+
allow(listener).to receive(:after_car).with(runtime, nested_list.cdr.cdr, nested_list.cdr.cdr.car)
|
158
|
+
allow(listener).to receive(:before_cdr).with(runtime, nested_list.cdr.cdr, nested_list.cdr.cdr.cdr)
|
159
|
+
allow(listener).to receive(:before_empty_list).with(runtime, nested_list.cdr.cdr.cdr)
|
160
|
+
allow(listener).to receive(:after_empty_list).with(runtime, nested_list.cdr.cdr.cdr)
|
161
|
+
allow(listener).to receive(:after_cdr).with(runtime, nested_list.cdr.cdr, nested_list.cdr.cdr.cdr)
|
162
|
+
allow(listener).to receive(:after_pair).with(runtime, nested_list.cdr.cdr)
|
163
|
+
allow(listener).to receive(:after_cdr).with(runtime, nested_list.cdr, nested_list.cdr.cdr)
|
164
|
+
allow(listener).to receive(:after_pair).with(runtime, nested_list.cdr)
|
165
|
+
allow(listener).to receive(:after_cdr).with(runtime, nested_list, nested_list.cdr)
|
166
|
+
allow(listener).to receive(:after_pair).with(runtime, nested_list)
|
167
|
+
allow(listener).to receive(:before_simple_datum).with(runtime, vec.members[3])
|
168
|
+
allow(listener).to receive(:after_simple_datum).with(runtime, vec.members[3])
|
169
|
+
allow(listener).to receive(:after_children).with(runtime, vec, vec.members)
|
170
|
+
allow(listener).to receive(:after_compound_datum).with(runtime, vec)
|
171
171
|
instance.start(runtime)
|
172
172
|
end
|
173
173
|
end # context
|
174
174
|
end # describe
|
175
|
-
end #
|
175
|
+
end # modulecls
|