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