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
@@ -5,6 +5,7 @@ require_relative '../spec_helper' # Use the RSpec framework
|
|
5
5
|
require_relative '../../lib/skeem/skm_simple_datum' # Load the classes under test
|
6
6
|
|
7
7
|
module Skeem
|
8
|
+
# rubocop: disable Style/OpenStructUse
|
8
9
|
describe SkmSimpleDatum do
|
9
10
|
let(:pos) { double('fake-position') }
|
10
11
|
let(:dummy_symbol) { double('fake-symbol') }
|
@@ -15,84 +16,85 @@ module Skeem
|
|
15
16
|
obj.lexeme = sample_value
|
16
17
|
obj
|
17
18
|
end
|
18
|
-
let(:instance) {
|
19
|
-
|
19
|
+
let(:instance) { described_class.create(3) }
|
20
|
+
|
21
|
+
subject(:datum) { described_class.new(dummy_token, pos) }
|
20
22
|
|
21
23
|
context 'Initialization:' do
|
22
|
-
it '
|
23
|
-
expect {
|
24
|
+
it 'is initialized with a token and a position' do
|
25
|
+
expect { described_class.new(dummy_token, pos) }.not_to raise_error
|
24
26
|
end
|
25
27
|
|
26
28
|
it 'could be created with just a value' do
|
27
|
-
expect {
|
28
|
-
expect(instance).to
|
29
|
+
expect { described_class.create(3) }.not_to raise_error
|
30
|
+
expect(instance).to be_a(described_class)
|
29
31
|
expect(instance.value).to eq(3)
|
30
32
|
end
|
31
33
|
|
32
|
-
it '
|
33
|
-
expect(
|
34
|
+
it 'knows its token' do
|
35
|
+
expect(datum.token).to eq(dummy_token)
|
34
36
|
end
|
35
37
|
|
36
|
-
it '
|
37
|
-
expect(
|
38
|
+
it 'knows its value' do
|
39
|
+
expect(datum.value).to eq(sample_value)
|
38
40
|
end
|
39
41
|
|
40
|
-
it "
|
41
|
-
expect(
|
42
|
+
it "knows the token's symbol" do
|
43
|
+
expect(datum.symbol).to eq(dummy_symbol)
|
42
44
|
end
|
43
45
|
end # context
|
44
46
|
|
45
47
|
context 'Provided services:' do
|
46
48
|
let(:runtime) { double('fake-runtime') }
|
47
49
|
|
48
|
-
it '
|
49
|
-
expect(
|
50
|
+
it 'asserts that it is equal to itself' do
|
51
|
+
expect(datum).to eq(datum)
|
50
52
|
end
|
51
53
|
|
52
|
-
it '
|
54
|
+
it 'asserts the equality by value' do
|
53
55
|
# Comparison with other instances
|
54
|
-
expect(instance).to eq(
|
55
|
-
expect(instance).not_to eq(
|
56
|
+
expect(instance).to eq(described_class.create(3))
|
57
|
+
expect(instance).not_to eq(described_class.create('foo'))
|
56
58
|
|
57
59
|
# Comparison with PORO values
|
58
60
|
expect(instance).to eq(3)
|
59
61
|
expect(instance).not_to eq('foo')
|
60
62
|
end
|
61
63
|
|
62
|
-
it '
|
63
|
-
expect(
|
64
|
+
it 'is equivalent to itself' do
|
65
|
+
expect(datum).to be_eqv(datum)
|
64
66
|
end
|
65
67
|
|
66
|
-
it '
|
67
|
-
same =
|
68
|
+
it 'is equivalent by value' do
|
69
|
+
same = described_class.create(3)
|
68
70
|
expect(instance).to be_eqv(same)
|
69
71
|
end
|
70
72
|
|
71
|
-
it '
|
72
|
-
expect(
|
73
|
+
it 'is Skeem equal to itself' do
|
74
|
+
expect(datum).to be_skm_equal(datum)
|
73
75
|
end
|
74
76
|
|
75
|
-
it '
|
76
|
-
same =
|
77
|
+
it 'is Skeem equal by value' do
|
78
|
+
same = described_class.create(3)
|
77
79
|
expect(instance).to be_skm_equal(same)
|
78
80
|
end
|
79
81
|
|
80
|
-
it '
|
81
|
-
expect(
|
82
|
+
it 'is self-evaluating' do
|
83
|
+
expect(datum.evaluate(runtime)).to equal(datum)
|
82
84
|
end
|
83
85
|
|
84
|
-
it '
|
85
|
-
expect(
|
86
|
+
it 'is self-quasiquoting' do
|
87
|
+
expect(datum.quasiquote(runtime)).to equal(datum)
|
86
88
|
end
|
87
89
|
|
88
|
-
it '
|
89
|
-
expect(
|
90
|
+
it 'returns its text representation' do
|
91
|
+
expect(datum.inspect).to eq('<Skeem::SkmSimpleDatum: sample-value>')
|
90
92
|
end
|
91
93
|
|
92
|
-
it '
|
94
|
+
it 'responds to visitor' do
|
93
95
|
visitor = double('fake-visitor')
|
94
|
-
|
95
|
-
expect {
|
96
|
+
allow(visitor).to receive(:visit_simple_datum).with(datum)
|
97
|
+
expect { datum.accept(visitor) }.not_to raise_error
|
96
98
|
end
|
97
99
|
end # context
|
98
100
|
end # describe
|
@@ -107,21 +109,22 @@ module Skeem
|
|
107
109
|
obj.lexeme = sample_value
|
108
110
|
obj
|
109
111
|
end
|
110
|
-
|
112
|
+
|
113
|
+
subject(:boolean) { described_class.new(dummy_token, pos) }
|
111
114
|
|
112
115
|
context 'Initialization:' do
|
113
|
-
it '
|
114
|
-
expect {
|
116
|
+
it 'is initialized with a token and a position' do
|
117
|
+
expect { described_class.new(dummy_token, pos) }.not_to raise_error
|
115
118
|
end
|
116
119
|
|
117
|
-
it '
|
118
|
-
expect(
|
120
|
+
it 'reacts positively to boolean? predicate' do
|
121
|
+
expect(boolean).to be_boolean
|
119
122
|
end
|
120
123
|
end # context
|
121
124
|
|
122
125
|
context 'Provided services:' do
|
123
|
-
it '
|
124
|
-
expect(
|
126
|
+
it 'returns its text representation' do
|
127
|
+
expect(boolean.inspect).to eq('<Skeem::SkmBoolean: false>')
|
125
128
|
end
|
126
129
|
end # context
|
127
130
|
end # describe
|
@@ -136,21 +139,22 @@ module Skeem
|
|
136
139
|
obj.lexeme = sample_value
|
137
140
|
obj
|
138
141
|
end
|
139
|
-
|
142
|
+
|
143
|
+
subject(:number) { described_class.new(dummy_token, pos) }
|
140
144
|
|
141
145
|
context 'Initialization:' do
|
142
|
-
it '
|
143
|
-
expect {
|
146
|
+
it 'is initialized with a token and a position' do
|
147
|
+
expect { described_class.new(dummy_token, pos) }.not_to raise_error
|
144
148
|
end
|
145
149
|
end # context
|
146
150
|
|
147
151
|
context 'Provided services:' do
|
148
|
-
it '
|
149
|
-
expect(
|
152
|
+
it 'reacts positively to number? predicate' do
|
153
|
+
expect(number).to be_number
|
150
154
|
end
|
151
155
|
|
152
|
-
it '
|
153
|
-
expect(
|
156
|
+
it 'returns its text representation' do
|
157
|
+
expect(number.inspect).to eq('<Skeem::SkmNumber: 0.51>')
|
154
158
|
end
|
155
159
|
end # context
|
156
160
|
end # describe
|
@@ -165,28 +169,29 @@ module Skeem
|
|
165
169
|
obj.lexeme = sample_value
|
166
170
|
obj
|
167
171
|
end
|
168
|
-
|
172
|
+
|
173
|
+
subject(:real) { described_class.new(dummy_token, pos) }
|
169
174
|
|
170
175
|
context 'Provided services:' do
|
171
|
-
it '
|
172
|
-
expect(
|
176
|
+
it 'reacts positively to number? predicate' do
|
177
|
+
expect(real).to be_number
|
173
178
|
end
|
174
179
|
|
175
|
-
it '
|
176
|
-
expect(
|
180
|
+
it 'reacts positively to real? predicate' do
|
181
|
+
expect(real).to be_real
|
177
182
|
end
|
178
183
|
|
179
|
-
it '
|
180
|
-
expect(
|
184
|
+
it 'reacts negatively to exact? predicate' do
|
185
|
+
expect(real).not_to be_exact
|
181
186
|
end
|
182
187
|
|
183
|
-
it '
|
184
|
-
same =
|
185
|
-
different =
|
188
|
+
it 'implements the eqv? predicate' do
|
189
|
+
same = described_class.create(0.51)
|
190
|
+
different = described_class.create(1.21)
|
186
191
|
|
187
|
-
expect(
|
188
|
-
expect(
|
189
|
-
expect(
|
192
|
+
expect(real).to be_eqv(real)
|
193
|
+
expect(real).to be_eqv(same)
|
194
|
+
expect(real).not_to be_eqv(different)
|
190
195
|
end
|
191
196
|
end # context
|
192
197
|
end # describe
|
@@ -201,33 +206,34 @@ module Skeem
|
|
201
206
|
obj.lexeme = sample_value
|
202
207
|
obj
|
203
208
|
end
|
204
|
-
|
209
|
+
|
210
|
+
subject(:integer) { described_class.new(dummy_token, pos) }
|
205
211
|
|
206
212
|
context 'Provided services:' do
|
207
|
-
it '
|
208
|
-
expect(
|
213
|
+
it 'reacts positively to number? predicate' do
|
214
|
+
expect(integer).to be_number
|
209
215
|
end
|
210
216
|
|
211
|
-
it '
|
212
|
-
expect(
|
217
|
+
it 'reacts positively to real? predicate' do
|
218
|
+
expect(integer).to be_real
|
213
219
|
end
|
214
220
|
|
215
|
-
it '
|
216
|
-
expect(
|
221
|
+
it 'reacts positively to integer? predicate' do
|
222
|
+
expect(integer).to be_real
|
217
223
|
end
|
218
224
|
|
219
|
-
it '
|
220
|
-
expect(
|
225
|
+
it 'reacts positively to exact? predicate' do
|
226
|
+
expect(integer).to be_exact
|
221
227
|
end
|
222
228
|
|
223
|
-
it '
|
224
|
-
three =
|
229
|
+
it 'implements the eqv? predicate' do
|
230
|
+
three = described_class.create(3)
|
225
231
|
real3 = SkmReal.create(3.0)
|
226
|
-
four =
|
232
|
+
four = described_class.create(4)
|
227
233
|
|
228
|
-
expect(
|
229
|
-
expect(
|
230
|
-
expect(
|
234
|
+
expect(integer).to be_eqv(three)
|
235
|
+
expect(integer).not_to be_eqv(real3)
|
236
|
+
expect(integer).not_to be_eqv(four)
|
231
237
|
end
|
232
238
|
end # context
|
233
239
|
end # describe
|
@@ -242,15 +248,16 @@ module Skeem
|
|
242
248
|
obj.lexeme = sample_value
|
243
249
|
obj
|
244
250
|
end
|
245
|
-
|
251
|
+
|
252
|
+
subject(:string) { described_class.new(dummy_token, pos) }
|
246
253
|
|
247
254
|
context 'Provided services:' do
|
248
|
-
it '
|
249
|
-
expect(
|
255
|
+
it 'reacts positively to string? predicate' do
|
256
|
+
expect(string).to be_string
|
250
257
|
end
|
251
258
|
|
252
|
-
it '
|
253
|
-
expect(
|
259
|
+
it 'returns its text representation' do
|
260
|
+
expect(string.inspect).to eq('<Skeem::SkmString: Hello>')
|
254
261
|
end
|
255
262
|
end # context
|
256
263
|
end # describe
|
@@ -265,37 +272,39 @@ module Skeem
|
|
265
272
|
obj.lexeme = sample_value
|
266
273
|
obj
|
267
274
|
end
|
268
|
-
|
275
|
+
|
276
|
+
subject(:identifier) { described_class.new(dummy_token, pos) }
|
269
277
|
|
270
278
|
context 'Provided services:' do
|
271
279
|
it 'could be initialized with a token and a position' do
|
272
|
-
expect {
|
280
|
+
expect { described_class.new(dummy_token, pos) }.not_to raise_error
|
273
281
|
end
|
274
282
|
|
275
283
|
it 'could be initialized with a token, a position and a flag' do
|
276
|
-
expect {
|
284
|
+
expect { described_class.new(dummy_token, pos, true) }.not_to raise_error
|
277
285
|
end
|
278
286
|
|
279
|
-
it '
|
280
|
-
expect(
|
287
|
+
it 'knows whether it is used as a variable name' do
|
288
|
+
expect(identifier.is_var_name).to be(false)
|
281
289
|
|
282
|
-
instance =
|
283
|
-
expect(instance.is_var_name).to
|
290
|
+
instance = described_class.new(dummy_token, pos, true)
|
291
|
+
expect(instance.is_var_name).to be(true)
|
284
292
|
end
|
285
293
|
|
286
|
-
it '
|
287
|
-
expect(
|
294
|
+
it 'reacts positively to symbol? predicate' do
|
295
|
+
expect(identifier).to be_symbol
|
288
296
|
end
|
289
297
|
|
290
|
-
it '
|
291
|
-
expect(
|
292
|
-
instance =
|
298
|
+
it 'reacts to verbatim? predicate' do
|
299
|
+
expect(identifier).to be_verbatim
|
300
|
+
instance = described_class.new(dummy_token, pos, true)
|
293
301
|
expect(instance).not_to be_verbatim
|
294
302
|
end
|
295
303
|
|
296
|
-
it '
|
297
|
-
expect(
|
304
|
+
it 'returns its text representation' do
|
305
|
+
expect(identifier.inspect).to eq('<Skeem::SkmIdentifier: this-is-it!>')
|
298
306
|
end
|
299
307
|
end # context
|
300
308
|
end # describe
|
309
|
+
# rubocop: enable Style/OpenStructUse
|
301
310
|
end # module
|
@@ -10,23 +10,23 @@ module Skeem
|
|
10
10
|
let(:pos) { double('fake-position') }
|
11
11
|
let(:sample_child) { double('fake-child') }
|
12
12
|
|
13
|
-
subject {
|
13
|
+
subject(:unary_expr) { described_class.new(pos, sample_child) }
|
14
14
|
|
15
15
|
context 'Initialization:' do
|
16
|
-
it '
|
17
|
-
expect {
|
16
|
+
it 'is initialized with a position and a child element' do
|
17
|
+
expect { described_class.new(pos, sample_child) }.not_to raise_error
|
18
18
|
end
|
19
19
|
|
20
|
-
it '
|
21
|
-
expect(
|
20
|
+
it 'knows its child' do
|
21
|
+
expect(unary_expr.child).to eq(sample_child)
|
22
22
|
end
|
23
23
|
end # context
|
24
24
|
|
25
25
|
context 'Provided basic services:' do
|
26
|
-
it '
|
26
|
+
it 'responds to visitor' do
|
27
27
|
visitor = double('fake-visitor')
|
28
|
-
expect(visitor).to receive(:visit_unary_expression).with(
|
29
|
-
expect {
|
28
|
+
expect(visitor).to receive(:visit_unary_expression).with(unary_expr)
|
29
|
+
expect { unary_expr.accept(visitor) }.not_to raise_error
|
30
30
|
end
|
31
31
|
end # context
|
32
32
|
end # describe
|
@@ -36,42 +36,42 @@ module Skeem
|
|
36
36
|
|
37
37
|
let(:sample_literal) { string('foo') }
|
38
38
|
|
39
|
-
subject {
|
39
|
+
subject(:quotation) { described_class.new(sample_literal) }
|
40
40
|
|
41
41
|
context 'Initialization:' do
|
42
|
-
it '
|
43
|
-
expect {
|
42
|
+
it 'is initialized with a Skeem element' do
|
43
|
+
expect { described_class.new(sample_literal) }.not_to raise_error
|
44
44
|
end
|
45
45
|
|
46
|
-
it '
|
47
|
-
expect(
|
48
|
-
expect(
|
46
|
+
it 'knows its datum' do
|
47
|
+
expect(quotation.datum).to equal(sample_literal)
|
48
|
+
expect(quotation.datum).to equal(quotation.child)
|
49
49
|
end
|
50
50
|
end # context
|
51
51
|
|
52
52
|
context 'Provided services:' do
|
53
53
|
let(:runtime) { Runtime.new(SkmFrame.new) }
|
54
54
|
|
55
|
-
# it '
|
56
|
-
# expect(
|
55
|
+
# it 'returns the child(datum) at evaluation' do
|
56
|
+
# expect(unary_expr.evaluate(runtime)).to equal(unary_expr.child)
|
57
57
|
# end
|
58
58
|
|
59
|
-
it '
|
59
|
+
it 'implements quasiquotation' do
|
60
60
|
# Case 1: child is idempotent with quasiquote
|
61
|
-
expect(
|
61
|
+
expect(quotation.quasiquote(runtime)).to equal(quotation)
|
62
62
|
|
63
63
|
# Case 2: quasiquoted child is different
|
64
64
|
child = double('fake-child')
|
65
|
-
|
66
|
-
instance =
|
65
|
+
allow(child).to receive(:quasiquote).with(runtime).and_return(integer(3))
|
66
|
+
instance = described_class.new(child)
|
67
67
|
expect(instance.child).to eq(child)
|
68
68
|
quasi_result = instance.quasiquote(runtime)
|
69
|
-
expect(quasi_result).to eq(3)
|
69
|
+
expect(quasi_result.child.value).to eq(3)
|
70
70
|
end
|
71
71
|
|
72
|
-
it '
|
72
|
+
it 'returns its text representation' do
|
73
73
|
txt1 = '<Skeem::SkmQuotation: <Skeem::SkmString: foo>>'
|
74
|
-
expect(
|
74
|
+
expect(quotation.inspect).to eq(txt1)
|
75
75
|
end
|
76
76
|
end # context
|
77
77
|
end # describe
|
@@ -82,79 +82,78 @@ module Skeem
|
|
82
82
|
|
83
83
|
let(:sample_literal) { string('foo') }
|
84
84
|
|
85
|
-
subject {
|
85
|
+
subject(:quasiquote) { described_class.new(sample_literal) }
|
86
86
|
|
87
87
|
context 'Initialization:' do
|
88
|
-
it '
|
89
|
-
expect {
|
88
|
+
it 'is initialized with a Skeem element' do
|
89
|
+
expect { described_class.new(sample_literal) }.not_to raise_error
|
90
90
|
end
|
91
91
|
end # context
|
92
92
|
|
93
93
|
context 'Provided services:' do
|
94
94
|
let(:runtime) { Runtime.new(SkmFrame.new) }
|
95
95
|
|
96
|
-
it '
|
97
|
-
expect(
|
96
|
+
it 'returns the child(template) at evaluation' do
|
97
|
+
expect(quasiquote.evaluate(runtime)).to equal(quasiquote.child)
|
98
98
|
end
|
99
99
|
|
100
|
-
it '
|
100
|
+
it 'accepts quasiquotation' do
|
101
101
|
# Case 1: child is idempotent with quasiquote
|
102
|
-
expect(
|
102
|
+
expect(quasiquote.quasiquote(runtime)).to equal(quasiquote.child)
|
103
103
|
|
104
104
|
# Case 2: quasiquoted child is different
|
105
105
|
child = double('fake-child')
|
106
|
-
|
107
|
-
instance =
|
106
|
+
allow(child).to receive(:quasiquote).with(runtime).and_return(integer(3))
|
107
|
+
instance = described_class.new(child)
|
108
108
|
expect(instance.child).to eq(child)
|
109
109
|
quasi_result = instance.quasiquote(runtime)
|
110
|
-
expect(quasi_result
|
110
|
+
expect(quasi_result).to eq(3)
|
111
111
|
end
|
112
112
|
|
113
|
-
it '
|
113
|
+
it 'returns its text representation' do
|
114
114
|
txt1 = '<Skeem::SkmQuasiquotation: <Skeem::SkmString: foo>>'
|
115
|
-
expect(
|
115
|
+
expect(quasiquote.inspect).to eq(txt1)
|
116
116
|
end
|
117
117
|
end # context
|
118
118
|
end # describe
|
119
119
|
|
120
|
-
|
121
120
|
describe SkmUnquotation do
|
122
121
|
include DatumDSL
|
123
122
|
|
124
123
|
let(:sample_literal) { string('foo') }
|
125
124
|
|
126
|
-
subject {
|
125
|
+
subject(:unquote) { described_class.new(sample_literal) }
|
127
126
|
|
128
127
|
context 'Initialization:' do
|
129
|
-
it '
|
130
|
-
expect {
|
128
|
+
it 'is initialized with a Skeem element' do
|
129
|
+
expect { described_class.new(sample_literal) }.not_to raise_error
|
131
130
|
end
|
132
131
|
end # context
|
133
132
|
|
134
133
|
context 'Provided services:' do
|
135
134
|
let(:runtime) { Runtime.new(SkmFrame.new) }
|
136
135
|
|
137
|
-
it '
|
138
|
-
expect(
|
136
|
+
it 'returns the child(template) at evaluation' do
|
137
|
+
expect(unquote.evaluate(runtime)).to equal(unquote.child)
|
139
138
|
end
|
140
139
|
|
141
|
-
it '
|
140
|
+
it 'accepts quasiquotation' do
|
142
141
|
# Case 1: child is idempotent with evaluate
|
143
|
-
expect(
|
142
|
+
expect(unquote.quasiquote(runtime)).to equal(unquote.child)
|
144
143
|
|
145
144
|
# Case 2: quasiquoted child is different
|
146
145
|
child = double('fake-child')
|
147
|
-
|
148
|
-
|
149
|
-
instance =
|
146
|
+
allow(child).to receive(:unquoted!)
|
147
|
+
allow(child).to receive(:evaluate).with(runtime).and_return(integer(3))
|
148
|
+
instance = described_class.new(child)
|
150
149
|
expect(instance.child).to eq(child)
|
151
150
|
quasi_result = instance.quasiquote(runtime)
|
152
151
|
expect(quasi_result).to eq(3)
|
153
152
|
end
|
154
153
|
|
155
|
-
it '
|
154
|
+
it 'returns its text representation' do
|
156
155
|
txt1 = '<Skeem::SkmUnquotation: <Skeem::SkmString: foo>>'
|
157
|
-
expect(
|
156
|
+
expect(unquote.inspect).to eq(txt1)
|
158
157
|
end
|
159
158
|
end # context
|
160
159
|
end # describe
|
@@ -165,37 +164,37 @@ module Skeem
|
|
165
164
|
let(:pos) { double('fake-position') }
|
166
165
|
let(:sample_var) { identifier('three') }
|
167
166
|
|
168
|
-
subject {
|
167
|
+
subject(:var_ref) { described_class.new(pos, sample_var) }
|
169
168
|
|
170
169
|
context 'Initialization:' do
|
171
|
-
it '
|
172
|
-
expect {
|
170
|
+
it 'is initialized with a position and a symbol' do
|
171
|
+
expect { described_class.new(pos, sample_var) }.not_to raise_error
|
173
172
|
end
|
174
173
|
|
175
|
-
it '
|
176
|
-
expect(
|
177
|
-
expect(
|
174
|
+
it 'knows its variable' do
|
175
|
+
expect(var_ref.variable).to equal(sample_var)
|
176
|
+
expect(var_ref.variable).to equal(var_ref.child)
|
178
177
|
end
|
179
178
|
end # context
|
180
179
|
|
181
180
|
context 'Provided services:' do
|
182
181
|
let(:runtime) { Runtime.new(SkmFrame.new) }
|
183
182
|
|
184
|
-
before
|
183
|
+
before do
|
185
184
|
runtime.add_binding('three', integer(3))
|
186
185
|
end
|
187
186
|
|
188
|
-
it "
|
189
|
-
expect(
|
187
|
+
it "returns the variable's value at evaluation" do
|
188
|
+
expect(var_ref.evaluate(runtime)).to eq(3)
|
190
189
|
end
|
191
190
|
|
192
|
-
it '
|
193
|
-
expect(
|
191
|
+
it 'returns itself at quasiquotation' do
|
192
|
+
expect(var_ref.quasiquote(runtime)).to equal(var_ref)
|
194
193
|
end
|
195
194
|
|
196
|
-
it '
|
195
|
+
it 'returns its text representation' do
|
197
196
|
txt1 = '<Skeem::SkmVariableReference: <Skeem::SkmIdentifier: three>>'
|
198
|
-
expect(
|
197
|
+
expect(var_ref.inspect).to eq(txt1)
|
199
198
|
end
|
200
199
|
end # context
|
201
200
|
end # describe
|