skeem 0.2.20 → 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 -298
- data/CHANGELOG.md +17 -2
- data/LICENSE.txt +1 -1
- data/lib/skeem/grammar.rb +14 -15
- data/lib/skeem/interpreter.rb +1 -1
- data/lib/skeem/parser.rb +1 -1
- data/lib/skeem/primitive/primitive_builder.rb +4 -2
- data/lib/skeem/primitive/primitive_procedure.rb +1 -1
- data/lib/skeem/runtime.rb +3 -1
- data/lib/skeem/s_expr_builder.rb +7 -7
- data/lib/skeem/s_expr_nodes.rb +5 -3
- data/lib/skeem/skm_simple_datum.rb +2 -2
- data/lib/skeem/tokenizer.rb +18 -23
- 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 +104 -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 +61 -17
@@ -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
|