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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +33 -298
  3. data/CHANGELOG.md +17 -2
  4. data/LICENSE.txt +1 -1
  5. data/lib/skeem/grammar.rb +14 -15
  6. data/lib/skeem/interpreter.rb +1 -1
  7. data/lib/skeem/parser.rb +1 -1
  8. data/lib/skeem/primitive/primitive_builder.rb +4 -2
  9. data/lib/skeem/primitive/primitive_procedure.rb +1 -1
  10. data/lib/skeem/runtime.rb +3 -1
  11. data/lib/skeem/s_expr_builder.rb +7 -7
  12. data/lib/skeem/s_expr_nodes.rb +5 -3
  13. data/lib/skeem/skm_simple_datum.rb +2 -2
  14. data/lib/skeem/tokenizer.rb +18 -23
  15. data/lib/skeem/version.rb +1 -1
  16. data/lib/skeem.rb +2 -2
  17. data/skeem.gemspec +8 -5
  18. data/spec/skeem/datum_dsl_spec.rb +50 -50
  19. data/spec/skeem/element_visitor_spec.rb +108 -108
  20. data/spec/skeem/interpreter_spec.rb +171 -169
  21. data/spec/skeem/lambda_spec.rb +27 -27
  22. data/spec/skeem/parser_spec.rb +27 -25
  23. data/spec/skeem/primitive/primitive_builder_spec.rb +127 -131
  24. data/spec/skeem/primitive/primitive_procedure_spec.rb +28 -28
  25. data/spec/skeem/runtime_spec.rb +52 -51
  26. data/spec/skeem/s_expr_nodes_spec.rb +31 -31
  27. data/spec/skeem/skm_compound_datum_spec.rb +36 -35
  28. data/spec/skeem/skm_element_spec.rb +35 -34
  29. data/spec/skeem/skm_empty_list_spec.rb +19 -19
  30. data/spec/skeem/skm_frame_spec.rb +49 -46
  31. data/spec/skeem/skm_pair_spec.rb +93 -93
  32. data/spec/skeem/skm_procedure_exec_spec.rb +11 -11
  33. data/spec/skeem/skm_simple_datum_spec.rb +104 -95
  34. data/spec/skeem/skm_unary_expression_spec.rb +60 -61
  35. data/spec/skeem/tokenizer_spec.rb +52 -52
  36. data/spec/skeem_spec.rb +1 -1
  37. data/spec/spec_helper.rb +0 -2
  38. 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) { SkmSimpleDatum.create(3) }
19
- subject { SkmSimpleDatum.new(dummy_token, pos) }
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 'should be initialized with a token and a position' do
23
- expect { SkmSimpleDatum.new(dummy_token, pos) }.not_to raise_error
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 { SkmSimpleDatum.create(3) }.not_to raise_error
28
- expect(instance).to be_kind_of(SkmSimpleDatum)
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 'should know its token' do
33
- expect(subject.token).to eq(dummy_token)
34
+ it 'knows its token' do
35
+ expect(datum.token).to eq(dummy_token)
34
36
  end
35
37
 
36
- it 'should know its value' do
37
- expect(subject.value).to eq(sample_value)
38
+ it 'knows its value' do
39
+ expect(datum.value).to eq(sample_value)
38
40
  end
39
41
 
40
- it "should know the token's symbol" do
41
- expect(subject.symbol).to eq(dummy_symbol)
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 'should assert that it is equal to itself' do
49
- expect(subject).to eq(subject)
50
+ it 'asserts that it is equal to itself' do
51
+ expect(datum).to eq(datum)
50
52
  end
51
53
 
52
- it 'should assert the equality by value' do
54
+ it 'asserts the equality by value' do
53
55
  # Comparison with other instances
54
- expect(instance).to eq(SkmSimpleDatum.create(3))
55
- expect(instance).not_to eq(SkmSimpleDatum.create('foo'))
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 'should be equivalent to itself' do
63
- expect(subject).to be_eqv(subject)
64
+ it 'is equivalent to itself' do
65
+ expect(datum).to be_eqv(datum)
64
66
  end
65
67
 
66
- it 'should be equivalent by value' do
67
- same = SkmSimpleDatum.create(3)
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 'should be Skeem equal to itself' do
72
- expect(subject).to be_skm_equal(subject)
73
+ it 'is Skeem equal to itself' do
74
+ expect(datum).to be_skm_equal(datum)
73
75
  end
74
76
 
75
- it 'should be Skeem equal by value' do
76
- same = SkmSimpleDatum.create(3)
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 'should be self-evaluating' do
81
- expect(subject.evaluate(runtime)).to be_equal(subject)
82
+ it 'is self-evaluating' do
83
+ expect(datum.evaluate(runtime)).to equal(datum)
82
84
  end
83
85
 
84
- it 'should be self-quasiquoting' do
85
- expect(subject.quasiquote(runtime)).to be_equal(subject)
86
+ it 'is self-quasiquoting' do
87
+ expect(datum.quasiquote(runtime)).to equal(datum)
86
88
  end
87
89
 
88
- it 'should return its text representation' do
89
- expect(subject.inspect).to eq('<Skeem::SkmSimpleDatum: sample-value>')
90
+ it 'returns its text representation' do
91
+ expect(datum.inspect).to eq('<Skeem::SkmSimpleDatum: sample-value>')
90
92
  end
91
93
 
92
- it 'should respond to visitor' do
94
+ it 'responds to visitor' do
93
95
  visitor = double('fake-visitor')
94
- expect(visitor).to receive(:visit_simple_datum).with(subject)
95
- expect { subject.accept(visitor) }.not_to raise_error
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
- subject { SkmBoolean.new(dummy_token, pos) }
112
+
113
+ subject(:boolean) { described_class.new(dummy_token, pos) }
111
114
 
112
115
  context 'Initialization:' do
113
- it 'should be initialized with a token and a position' do
114
- expect { SkmBoolean.new(dummy_token, pos) }.not_to raise_error
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 'should react positively to boolean? predicate' do
118
- expect(subject).to be_boolean
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 'should return its text representation' do
124
- expect(subject.inspect).to eq('<Skeem::SkmBoolean: false>')
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
- subject { SkmNumber.new(dummy_token, pos) }
142
+
143
+ subject(:number) { described_class.new(dummy_token, pos) }
140
144
 
141
145
  context 'Initialization:' do
142
- it 'should be initialized with a token and a position' do
143
- expect { SkmNumber.new(dummy_token, pos) }.not_to raise_error
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 'should react positively to number? predicate' do
149
- expect(subject).to be_number
152
+ it 'reacts positively to number? predicate' do
153
+ expect(number).to be_number
150
154
  end
151
155
 
152
- it 'should return its text representation' do
153
- expect(subject.inspect).to eq('<Skeem::SkmNumber: 0.51>')
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
- subject { SkmReal.new(dummy_token, pos) }
172
+
173
+ subject(:real) { described_class.new(dummy_token, pos) }
169
174
 
170
175
  context 'Provided services:' do
171
- it 'should react positively to number? predicate' do
172
- expect(subject).to be_number
176
+ it 'reacts positively to number? predicate' do
177
+ expect(real).to be_number
173
178
  end
174
179
 
175
- it 'should react positively to real? predicate' do
176
- expect(subject).to be_real
180
+ it 'reacts positively to real? predicate' do
181
+ expect(real).to be_real
177
182
  end
178
183
 
179
- it 'should react negatively to exact? predicate' do
180
- expect(subject).not_to be_exact
184
+ it 'reacts negatively to exact? predicate' do
185
+ expect(real).not_to be_exact
181
186
  end
182
187
 
183
- it 'should implement the eqv? predicate' do
184
- same = SkmReal.create(0.51)
185
- different = SkmReal.create(1.21)
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(subject).to be_eqv(subject)
188
- expect(subject).to be_eqv(same)
189
- expect(subject).not_to be_eqv(different)
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
- subject { SkmInteger.new(dummy_token, pos) }
209
+
210
+ subject(:integer) { described_class.new(dummy_token, pos) }
205
211
 
206
212
  context 'Provided services:' do
207
- it 'should react positively to number? predicate' do
208
- expect(subject).to be_number
213
+ it 'reacts positively to number? predicate' do
214
+ expect(integer).to be_number
209
215
  end
210
216
 
211
- it 'should react positively to real? predicate' do
212
- expect(subject).to be_real
217
+ it 'reacts positively to real? predicate' do
218
+ expect(integer).to be_real
213
219
  end
214
220
 
215
- it 'should react positively to integer? predicate' do
216
- expect(subject).to be_real
221
+ it 'reacts positively to integer? predicate' do
222
+ expect(integer).to be_real
217
223
  end
218
224
 
219
- it 'should react positively to exact? predicate' do
220
- expect(subject).to be_exact
225
+ it 'reacts positively to exact? predicate' do
226
+ expect(integer).to be_exact
221
227
  end
222
228
 
223
- it 'should implement the eqv? predicate' do
224
- three = SkmInteger.create(3)
229
+ it 'implements the eqv? predicate' do
230
+ three = described_class.create(3)
225
231
  real3 = SkmReal.create(3.0)
226
- four = SkmInteger.create(4)
232
+ four = described_class.create(4)
227
233
 
228
- expect(subject).to be_eqv(three)
229
- expect(subject).not_to be_eqv(real3)
230
- expect(subject).not_to be_eqv(four)
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
- subject { SkmString.new(dummy_token, pos) }
251
+
252
+ subject(:string) { described_class.new(dummy_token, pos) }
246
253
 
247
254
  context 'Provided services:' do
248
- it 'should react positively to string? predicate' do
249
- expect(subject).to be_string
255
+ it 'reacts positively to string? predicate' do
256
+ expect(string).to be_string
250
257
  end
251
258
 
252
- it 'should return its text representation' do
253
- expect(subject.inspect).to eq('<Skeem::SkmString: Hello>')
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
- subject { SkmIdentifier.new(dummy_token, pos) }
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 { SkmIdentifier.new(dummy_token, pos) }.not_to raise_error
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 { SkmIdentifier.new(dummy_token, pos, true) }.not_to raise_error
284
+ expect { described_class.new(dummy_token, pos, true) }.not_to raise_error
277
285
  end
278
286
 
279
- it 'should know whether it is used as a variable name' do
280
- expect(subject.is_var_name).to eq(false)
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 = SkmIdentifier.new(dummy_token, pos, true)
283
- expect(instance.is_var_name).to eq(true)
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 'should react positively to symbol? predicate' do
287
- expect(subject).to be_symbol
294
+ it 'reacts positively to symbol? predicate' do
295
+ expect(identifier).to be_symbol
288
296
  end
289
297
 
290
- it 'should react to verbatim? predicate' do
291
- expect(subject).to be_verbatim
292
- instance = SkmIdentifier.new(dummy_token, pos, true)
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 'should return its text representation' do
297
- expect(subject.inspect).to eq('<Skeem::SkmIdentifier: this-is-it!>')
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 { SkmUnaryExpression.new(pos, sample_child) }
13
+ subject(:unary_expr) { described_class.new(pos, sample_child) }
14
14
 
15
15
  context 'Initialization:' do
16
- it 'should be initialized with a position and a child element' do
17
- expect { SkmUnaryExpression.new(pos, sample_child) }.not_to raise_error
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 'should know its child' do
21
- expect(subject.child).to eq(sample_child)
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 'should respond to visitor' do
26
+ it 'responds to visitor' do
27
27
  visitor = double('fake-visitor')
28
- expect(visitor).to receive(:visit_unary_expression).with(subject)
29
- expect { subject.accept(visitor) }.not_to raise_error
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 { SkmQuotation.new(sample_literal) }
39
+ subject(:quotation) { described_class.new(sample_literal) }
40
40
 
41
41
  context 'Initialization:' do
42
- it 'should be initialized with a Skeem element' do
43
- expect { SkmQuotation.new(sample_literal) }.not_to raise_error
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 'should know its datum' do
47
- expect(subject.datum).to be_equal(sample_literal)
48
- expect(subject.datum).to be_equal(subject.child)
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 'should return the child(datum) at evaluation' do
56
- # expect(subject.evaluate(runtime)).to be_equal(subject.child)
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 'should implement quasiquotation' do
59
+ it 'implements quasiquotation' do
60
60
  # Case 1: child is idempotent with quasiquote
61
- expect(subject.quasiquote(runtime)).to be_equal(subject)
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
- expect(child).to receive(:quasiquote).with(runtime).and_return(integer(3))
66
- instance = SkmQuasiquotation.new(child)
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 'should return its text representation' do
72
+ it 'returns its text representation' do
73
73
  txt1 = '<Skeem::SkmQuotation: <Skeem::SkmString: foo>>'
74
- expect(subject.inspect).to eq(txt1)
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 { SkmQuasiquotation.new(sample_literal) }
85
+ subject(:quasiquote) { described_class.new(sample_literal) }
86
86
 
87
87
  context 'Initialization:' do
88
- it 'should be initialized with a Skeem element' do
89
- expect { SkmQuasiquotation.new(sample_literal) }.not_to raise_error
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 'should return the child(template) at evaluation' do
97
- expect(subject.evaluate(runtime)).to be_equal(subject.child)
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 'should accept quasiquotation' do
100
+ it 'accepts quasiquotation' do
101
101
  # Case 1: child is idempotent with quasiquote
102
- expect(subject.quasiquote(runtime)).to be_equal(subject.child)
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
- expect(child).to receive(:quasiquote).with(runtime).and_return(integer(3))
107
- instance = SkmQuotation.new(child)
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.child).to eq(3)
110
+ expect(quasi_result).to eq(3)
111
111
  end
112
112
 
113
- it 'should return its text representation' do
113
+ it 'returns its text representation' do
114
114
  txt1 = '<Skeem::SkmQuasiquotation: <Skeem::SkmString: foo>>'
115
- expect(subject.inspect).to eq(txt1)
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 { SkmUnquotation.new(sample_literal) }
125
+ subject(:unquote) { described_class.new(sample_literal) }
127
126
 
128
127
  context 'Initialization:' do
129
- it 'should be initialized with a Skeem element' do
130
- expect { SkmUnquotation.new(sample_literal) }.not_to raise_error
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 'should return the child(template) at evaluation' do
138
- expect(subject.evaluate(runtime)).to be_equal(subject.child)
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 'should accept quasiquotation' do
140
+ it 'accepts quasiquotation' do
142
141
  # Case 1: child is idempotent with evaluate
143
- expect(subject.quasiquote(runtime)).to be_equal(subject.child)
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
- expect(child).to receive(:unquoted!)
148
- expect(child).to receive(:evaluate).with(runtime).and_return(integer(3))
149
- instance = SkmUnquotation.new(child)
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 'should return its text representation' do
154
+ it 'returns its text representation' do
156
155
  txt1 = '<Skeem::SkmUnquotation: <Skeem::SkmString: foo>>'
157
- expect(subject.inspect).to eq(txt1)
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 { SkmVariableReference.new(pos, sample_var) }
167
+ subject(:var_ref) { described_class.new(pos, sample_var) }
169
168
 
170
169
  context 'Initialization:' do
171
- it 'should be initialized with a position and a symbol' do
172
- expect { SkmVariableReference.new(pos, sample_var) }.not_to raise_error
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 'should know its variable' do
176
- expect(subject.variable).to be_equal(sample_var)
177
- expect(subject.variable).to be_equal(subject.child)
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(:each) do
183
+ before do
185
184
  runtime.add_binding('three', integer(3))
186
185
  end
187
186
 
188
- it "should return the variable's value at evaluation" do
189
- expect(subject.evaluate(runtime)).to eq(3)
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 'should return itself at quasiquotation' do
193
- expect(subject.quasiquote(runtime)).to be_equal(subject)
191
+ it 'returns itself at quasiquotation' do
192
+ expect(var_ref.quasiquote(runtime)).to equal(var_ref)
194
193
  end
195
194
 
196
- it 'should return its text representation' do
195
+ it 'returns its text representation' do
197
196
  txt1 = '<Skeem::SkmVariableReference: <Skeem::SkmIdentifier: three>>'
198
- expect(subject.inspect).to eq(txt1)
197
+ expect(var_ref.inspect).to eq(txt1)
199
198
  end
200
199
  end # context
201
200
  end # describe