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.
@@ -29,66 +29,66 @@ module Skeem
29
29
  ->(_runtime, operands) { operands.length }
30
30
  end
31
31
 
32
- subject { PrimitiveProcedure.new('cube', unary, cube) }
32
+ subject(:primitive) { described_class.new('cube', unary, cube) }
33
33
 
34
- before(:each) { @passing = false }
34
+ before { @passing = false }
35
35
 
36
36
  context 'Initialization:' do
37
- it 'should be initialized with a name, arity and a lambda' do
38
- expect { PrimitiveProcedure.new('newline', nullary, newline_code) }.not_to raise_error
37
+ it 'is initialized with a name, arity and a lambda' do
38
+ expect { described_class.new('newline', nullary, newline_code) }.not_to raise_error
39
39
  end
40
40
 
41
- it 'should know its name' do
42
- expect(subject.identifier.value).to eq('cube')
41
+ it 'knows its name' do
42
+ expect(primitive.identifier.value).to eq('cube')
43
43
  end
44
44
 
45
- it 'should know its arity' do
46
- expect(subject.arity).to eq([1, 1])
45
+ it 'knows its arity' do
46
+ expect(primitive.arity).to eq([1, 1])
47
47
  end
48
48
 
49
- it 'should know its lambda' do
50
- expect(subject.code).to eq(cube)
49
+ it 'knows its lambda' do
50
+ expect(primitive.code).to eq(cube)
51
51
  end
52
52
 
53
- it 'should complain if third argument is not a lambda' do
53
+ it 'complains if third argument is not a lambda' do
54
54
  kode = proc { puts '' }
55
55
 
56
56
  err = StandardError
57
57
  err_msg = "Primitive procedure 'newline' must be implemented with a Ruby lambda."
58
- expect { PrimitiveProcedure.new('newline', nullary, kode) }.to raise_error(err, err_msg)
58
+ expect { described_class.new('newline', nullary, kode) }.to raise_error(err, err_msg)
59
59
  end
60
60
 
61
- it 'should complain if third argument is a nullary lambda' do
61
+ it 'complains if third argument is a nullary lambda' do
62
62
  kode = -> { puts '' } # Missing slot for Runtime object
63
63
 
64
64
  err = StandardError
65
65
  err_msg = "Primitive procedure 'newline' lambda takes no parameter."
66
- expect { PrimitiveProcedure.new('newline', nullary, kode) }.to raise_error(err, err_msg)
66
+ expect { described_class.new('newline', nullary, kode) }.to raise_error(err, err_msg)
67
67
  end
68
68
 
69
- it 'should complain when arity and parameter count mismatch' do
69
+ it 'complains when arity and parameter count mismatch' do
70
70
  err = StandardError
71
71
  msg1 = "Discrepancy in primitive procedure 'cube' "
72
72
 
73
73
  msg2 = 'between arity (0) + 1 and parameter count of lambda 2.'
74
- expect { PrimitiveProcedure.new('cube', nullary, cube) }.to raise_error(err, msg1 + msg2)
74
+ expect { described_class.new('cube', nullary, cube) }.to raise_error(err, msg1 + msg2)
75
75
 
76
76
  msg2 = 'between arity (2) + 1 and parameter count of lambda 2.'
77
- expect { PrimitiveProcedure.new('cube', binary, cube) }.to raise_error(err, msg1 + msg2)
77
+ expect { described_class.new('cube', binary, cube) }.to raise_error(err, msg1 + msg2)
78
78
 
79
79
  # Nasty; this discrepancy isn't detected
80
- expect { PrimitiveProcedure.new('cube', zero_or_more, cube) }.not_to raise_error
80
+ expect { described_class.new('cube', zero_or_more, cube) }.not_to raise_error
81
81
 
82
- expect { PrimitiveProcedure.new('cube', unary, cube) }.not_to raise_error
82
+ expect { described_class.new('cube', unary, cube) }.not_to raise_error
83
83
 
84
84
  msg2 = 'between arity (1) + 2 and parameter count of lambda 2.'
85
- expect { PrimitiveProcedure.new('cube', one_or_more, cube) }.to raise_error(err, msg1 + msg2)
85
+ expect { described_class.new('cube', one_or_more, cube) }.to raise_error(err, msg1 + msg2)
86
86
  end
87
87
  end # context
88
88
 
89
89
  context 'Procedure invokation:' do
90
- it 'should support Skeem nullary procedure' do
91
- pproc = PrimitiveProcedure.new('newline', nullary, newline_code)
90
+ it 'supports Skeem nullary procedure' do
91
+ pproc = described_class.new('newline', nullary, newline_code)
92
92
  rtime = double('fake-runtime')
93
93
 
94
94
  expect(pproc.call(rtime, [])).to eq("\n")
@@ -99,8 +99,8 @@ module Skeem
99
99
  expect { pproc.call(rtime, ['superfluous']) }.to raise_error(err, ms1 + ms2)
100
100
  end
101
101
 
102
- it 'should support Skeem unary procedure' do
103
- pproc = PrimitiveProcedure.new('cube', unary, cube)
102
+ it 'supports Skeem unary procedure' do
103
+ pproc = described_class.new('cube', unary, cube)
104
104
  rtime = double('fake-runtime')
105
105
 
106
106
  args = [SkmInteger.create(3)]
@@ -118,8 +118,8 @@ module Skeem
118
118
  expect { pproc.call(rtime, too_much) }.to raise_error(err, ms1 + ms2)
119
119
  end
120
120
 
121
- it 'should support Skeem binary procedure' do
122
- pproc = PrimitiveProcedure.new('sum', binary, sum)
121
+ it 'supports Skeem binary procedure' do
122
+ pproc = described_class.new('sum', binary, sum)
123
123
  rtime = double('fake-runtime')
124
124
 
125
125
  args = [SkmInteger.create(3), SkmInteger.create(5)]
@@ -138,8 +138,8 @@ module Skeem
138
138
  expect { pproc.call(rtime, too_much) }.to raise_error(err, ms1 + ms2)
139
139
  end
140
140
 
141
- it 'should support Skeem variadic procedure' do
142
- pproc = PrimitiveProcedure.new('length', zero_or_more, length)
141
+ it 'supports Skeem variadic procedure' do
142
+ pproc = described_class.new('length', zero_or_more, length)
143
143
  rtime = double('fake-runtime')
144
144
 
145
145
  args = [SkmInteger.create(3), SkmInteger.create(5)]
@@ -12,79 +12,80 @@ module Skeem
12
12
  include DatumDSL
13
13
 
14
14
  let(:some_env) { SkmFrame.new }
15
- subject { Runtime.new(some_env) }
15
+
16
+ subject(:runtime) { described_class.new(some_env) }
16
17
 
17
18
  context 'Initialization:' do
18
- it 'should be initialized with an environment' do
19
- expect { Runtime.new(SkmFrame.new) }.not_to raise_error
19
+ it 'is initialized with an environment' do
20
+ expect { described_class.new(SkmFrame.new) }.not_to raise_error
20
21
  end
21
22
 
22
- it 'should know the environment' do
23
- expect(subject.environment).to eq(some_env)
23
+ it 'knows the environment' do
24
+ expect(runtime.environment).to eq(some_env)
24
25
  end
25
26
 
26
- it 'should have an empty call stack' do
27
- expect(subject.call_stack).to be_empty
27
+ it 'has an empty call stack' do
28
+ expect(runtime.call_stack).to be_empty
28
29
  end
29
30
  end # context
30
31
 
31
32
  context 'Provided services:' do
32
- it 'should add entries to the environment' do
33
+ it 'adds entries to the environment' do
33
34
  entry = double('dummy')
34
- expect(entry).to receive(:bound!)
35
- subject.add_binding('dummy', entry)
36
- expect(subject.environment.size).to eq(1)
35
+ allow(entry).to receive(:bound!)
36
+ runtime.add_binding('dummy', entry)
37
+ expect(runtime.environment.size).to eq(1)
37
38
  end
38
39
 
39
- it 'should know the keys in the environment' do
40
- expect(subject.include?('dummy')).to be_falsey
40
+ it 'knows the keys in the environment' do
41
+ expect(runtime).not_to include('dummy')
41
42
  entry = double('dummy')
42
- expect(entry).to receive(:bound!)
43
- subject.add_binding('dummy', entry)
44
- expect(subject.include?('dummy')).to be_truthy
43
+ allow(entry).to receive(:bound!)
44
+ runtime.add_binding('dummy', entry)
45
+ expect(runtime).to include('dummy')
45
46
  end
46
47
  end # context
47
48
 
48
49
  context 'Evaluation:' do
49
50
  include Primitive::PrimitiveBuilder
50
51
 
51
- # it 'should evaluate a given entry' do
52
+ # it 'evaluates a given entry' do
52
53
  # entry = integer(3)
53
54
  # result = double('fake-procedure')
54
- # expect(entry).to receive(:expression).and_return(result)
55
- # expect(result).to receive(:evaluate).with(subject).and_return(integer(3))
56
- # subject.define('three', entry)
57
- # expect(subject.evaluate('three')).to eq(3)
55
+ # expect(entry).to have_received(:expression).and_return(result)
56
+ # expect(result).to have_received(:evaluate).with(runtime).and_return(integer(3))
57
+ # runtime.define('three', entry)
58
+ # expect(runtime.evaluate('three')).to eq(3)
58
59
  # end
59
60
 
60
- it 'should evaluate a given list' do
61
- add_primitives(subject)
61
+ it 'evaluates a given list' do
62
+ add_primitives(runtime)
62
63
  sum = list([identifier('+'), 3, 4])
63
64
 
64
- expect(subject.evaluate_form(sum)).to eq(7)
65
+ expect(runtime.evaluate_form(sum)).to eq(7)
65
66
  end
66
67
  end # context
67
68
 
68
69
  context 'Environment nesting:' do
69
- it 'should add nested environment' do
70
- expect(subject.depth).to eq(1)
71
- env_before = subject.environment
72
- subject.nest
73
-
74
- expect(subject.environment).not_to eq(env_before)
75
- expect(subject.environment.parent).to eq(env_before)
76
- expect(subject.depth).to eq(2)
70
+ it 'adds nested environment' do
71
+ expect(runtime.depth).to eq(1)
72
+ env_before = runtime.environment
73
+ runtime.nest
74
+
75
+ expect(runtime.environment).not_to eq(env_before)
76
+ expect(runtime.environment.parent).to eq(env_before)
77
+ expect(runtime.depth).to eq(2)
77
78
  end
78
79
 
79
- it 'should remove nested environment' do
80
- expect(subject.depth).to eq(1)
81
- subject.nest
82
- parent_before = subject.environment.parent
83
- expect(subject.depth).to eq(2)
80
+ it 'removes nested environment' do
81
+ expect(runtime.depth).to eq(1)
82
+ runtime.nest
83
+ parent_before = runtime.environment.parent
84
+ expect(runtime.depth).to eq(2)
84
85
 
85
- subject.unnest
86
- expect(subject.environment).to eq(parent_before)
87
- expect(subject.depth).to eq(1)
86
+ runtime.unnest
87
+ expect(runtime.environment).to eq(parent_before)
88
+ expect(runtime.depth).to eq(1)
88
89
  end
89
90
  end # context
90
91
 
@@ -94,23 +95,23 @@ module Skeem
94
95
  ProcedureCall.new(pos, identifier('boolean?'), [integer(42)])
95
96
  end
96
97
 
97
- it 'should push a call to the stack call' do
98
- expect { subject.push_call(sample_call) }.not_to raise_error
99
- expect(subject.call_stack.size).to eq(1)
100
- expect(subject.caller).to eq(sample_call)
98
+ it 'pushes a call to the stack call' do
99
+ expect { runtime.push_call(sample_call) }.not_to raise_error
100
+ expect(runtime.call_stack.size).to eq(1)
101
+ expect(runtime.caller).to eq(sample_call)
101
102
 
102
- subject.push_call(sample_call.clone)
103
- expect(subject.call_stack.size).to eq(2)
103
+ runtime.push_call(sample_call.clone)
104
+ expect(runtime.call_stack.size).to eq(2)
104
105
  end
105
106
 
106
- it 'should pop a call from the call stack' do
107
- subject.push_call(sample_call)
108
- expect { subject.pop_call }.not_to raise_error
109
- expect(subject.call_stack).to be_empty
107
+ it 'pops a call from the call stack' do
108
+ runtime.push_call(sample_call)
109
+ expect { runtime.pop_call }.not_to raise_error
110
+ expect(runtime.call_stack).to be_empty
110
111
 
111
112
  err = StandardError
112
113
  msg = 'Skeem call stack empty!'
113
- expect { subject.pop_call }.to raise_error(err, msg)
114
+ expect { runtime.pop_call }.to raise_error(err, msg)
114
115
  end
115
116
  end # context
116
117
  end # describe
@@ -12,27 +12,27 @@ module Skeem
12
12
  let(:operator) { SkmIdentifier.create('+') }
13
13
  let(:operands) { [1, 2, 3] }
14
14
 
15
- subject { ProcedureCall.new(pos, operator, operands) }
15
+ subject(:proc_call) { described_class.new(pos, operator, operands) }
16
16
 
17
17
  context 'Initialization:' do
18
- it 'should be initialized with an operator symbol and its operands' do
19
- expect { ProcedureCall.new(pos, operator, operands) }.not_to raise_error
18
+ it 'is initialized with an operator symbol and its operands' do
19
+ expect { described_class.new(pos, operator, operands) }.not_to raise_error
20
20
  end
21
21
 
22
- it 'should know its operator' do
23
- expect(subject.operator).to eq(operator)
22
+ it 'knows its operator' do
23
+ expect(proc_call.operator).to eq(operator)
24
24
  end
25
25
 
26
- it 'should know its operands' do
27
- expect(subject.operands.inspect).to eq('<Skeem::SkmPair: 1, 2, 3>')
26
+ it 'knows its operands' do
27
+ expect(proc_call.operands.inspect).to eq('<Skeem::SkmPair: 1, 2, 3>')
28
28
  end
29
29
  end # context
30
30
 
31
31
  context 'Provided services:' do
32
- it 'should return its text representation' do
32
+ it 'returns its text representation' do
33
33
  txt1 = '<Skeem::ProcedureCall: <Skeem::SkmIdentifier: +>, '
34
34
  txt2 = '@operands <Skeem::SkmPair: 1, 2, 3>>'
35
- expect(subject.inspect).to eq(txt1 + txt2)
35
+ expect(proc_call.inspect).to eq(txt1 + txt2)
36
36
  end
37
37
  end # context
38
38
  end # describe
@@ -43,32 +43,32 @@ module Skeem
43
43
  let(:s_consequent) { double('fake-consequent') }
44
44
  let(:s_alt) { double('fake-alternate') }
45
45
 
46
- subject { SkmCondition.new(pos, s_test, s_consequent, s_alt) }
46
+ subject(:condition) { described_class.new(pos, s_test, s_consequent, s_alt) }
47
47
 
48
48
  context 'Initialization:' do
49
- it 'should be initialized with a pos and 3 expressions' do
50
- expect { SkmCondition.new(pos, s_test, s_consequent, s_alt) }.not_to raise_error
49
+ it 'is initialized with a pos and 3 expressions' do
50
+ expect { described_class.new(pos, s_test, s_consequent, s_alt) }.not_to raise_error
51
51
  end
52
52
 
53
- it 'should know its test' do
54
- expect(subject.test).to eq(s_test)
53
+ it 'knows its test' do
54
+ expect(condition.test).to eq(s_test)
55
55
  end
56
56
 
57
- it 'should know its consequent' do
58
- expect(subject.consequent).to eq(s_consequent)
57
+ it 'knows its consequent' do
58
+ expect(condition.consequent).to eq(s_consequent)
59
59
  end
60
60
 
61
- it 'should know its alternate' do
62
- expect(subject.alternate).to eq(s_alt)
61
+ it 'knows its alternate' do
62
+ expect(condition.alternate).to eq(s_alt)
63
63
  end
64
64
  end # context
65
65
 
66
66
  context 'Provided services:' do
67
- it 'should return its text representation' do
67
+ it 'returns its text representation' do
68
68
  txt1 = '<Skeem::SkmCondition: @test #<Double "fake-test">, '
69
69
  txt2 = '@consequent #<Double "fake-consequent">, '
70
70
  txt3 = '@alternate #<Double "fake-alternate">>'
71
- expect(subject.inspect).to eq(txt1 + txt2 + txt3)
71
+ expect(condition.inspect).to eq(txt1 + txt2 + txt3)
72
72
  end
73
73
  end # context
74
74
  end # describe
@@ -80,33 +80,33 @@ module Skeem
80
80
  let(:s_sequence) { double('fake-sequence') }
81
81
  let(:s_body) { { defs: s_defs, sequence: s_sequence } }
82
82
 
83
- subject { SkmLambdaRep.new(pos, s_formals, s_body) }
83
+ subject(:lambda_rep) { described_class.new(pos, s_formals, s_body) }
84
84
 
85
85
  context 'Initialization:' do
86
- it 'should be initialized with a pos and 3 expressions' do
87
- expect { SkmLambdaRep.new(pos, s_formals, s_body) }.not_to raise_error
86
+ it 'is initialized with a pos and 3 expressions' do
87
+ expect { described_class.new(pos, s_formals, s_body) }.not_to raise_error
88
88
  end
89
89
 
90
- it 'should know its formals' do
91
- expect(subject.formals).to eq(s_formals)
90
+ it 'knows its formals' do
91
+ expect(lambda_rep.formals).to eq(s_formals)
92
92
  end
93
93
 
94
- it 'should know its definitions' do
95
- expect(subject.definitions).to eq(s_defs)
94
+ it 'knows its definitions' do
95
+ expect(lambda_rep.definitions).to eq(s_defs)
96
96
  end
97
97
 
98
- it 'should know its sequence' do
99
- expect(subject.sequence).to eq(s_sequence)
98
+ it 'knows its sequence' do
99
+ expect(lambda_rep.sequence).to eq(s_sequence)
100
100
  end
101
101
  end # context
102
102
 
103
103
  context 'Provided services:' do
104
- it 'should return its text representation' do
104
+ it 'returns its text representation' do
105
105
  txt1 = '<Skeem::SkmLambdaRep: @formals #<Double "fake-formals">, '
106
106
  txt2 = '@definitions #<Double "fake-definitions">, '
107
107
  txt3 = '@sequence #<Double "fake-sequence">>>'
108
108
  # Remove "unpredictable" part of actual text
109
- expectation = subject.inspect.gsub(/@object_id=[0-9a-z]+, /, '')
109
+ expectation = lambda_rep.inspect.gsub(/@object_id=[0-9a-z]+, /, '')
110
110
  expect(expectation).to eq(txt1 + txt2 + txt3)
111
111
  end
112
112
  end # context
@@ -8,49 +8,49 @@ module Skeem
8
8
  describe SkmCompoundDatum do
9
9
  include DatumDSL
10
10
 
11
- let(:sample_members) { [1, 2, 3] }
12
11
  let(:sample_members) { [integer(1), integer(2), integer(3)] }
13
- subject { SkmCompoundDatum.new(sample_members) }
12
+
13
+ subject(:datum) { described_class.new(sample_members) }
14
14
 
15
15
  context 'Initialization:' do
16
- it 'should be initialized with its members' do
17
- expect { SkmCompoundDatum.new(sample_members) }.not_to raise_error
16
+ it 'is initialized with its members' do
17
+ expect { described_class.new(sample_members) }.not_to raise_error
18
18
  end
19
19
 
20
- it 'should know its members' do
21
- expect(subject.members).to eq(sample_members)
20
+ it 'knows its members' do
21
+ expect(datum.members).to eq(sample_members)
22
22
 
23
- other = SkmCompoundDatum.new([])
23
+ other = described_class.new([])
24
24
  expect(other.members).to be_empty
25
25
  end
26
26
  end # context
27
27
 
28
28
  context 'Provided basic services:' do
29
- it 'should assert that it is equal to itself' do
30
- expect(subject).to eq(subject)
29
+ it 'asserts that it is equal to itself' do
30
+ expect(datum).to eq(datum)
31
31
  end
32
32
 
33
- it 'should assert the equality by member values' do
33
+ it 'asserts the equality by member values' do
34
34
  # Comparison with other instances
35
- expect(subject).to eq(SkmCompoundDatum.new(sample_members))
36
- expect(subject).not_to eq(SkmCompoundDatum.new([]))
37
- expect(subject).not_to eq(SkmCompoundDatum.new(sample_members.rotate))
35
+ expect(datum).to eq(described_class.new(sample_members))
36
+ expect(datum).not_to eq(described_class.new([]))
37
+ expect(datum).not_to eq(described_class.new(sample_members.rotate))
38
38
 
39
39
  # Comparison with array of values
40
- expect(subject).to eq(sample_members)
41
- expect(subject).not_to eq(sample_members.rotate)
40
+ expect(datum).to eq(sample_members)
41
+ expect(datum).not_to eq(sample_members.rotate)
42
42
  end
43
43
 
44
- it 'should respond to visitor' do
44
+ it 'responds to visitor' do
45
45
  visitor = double('fake-visitor')
46
- expect(visitor).to receive(:visit_compound_datum).with(subject)
47
- expect { subject.accept(visitor) }.not_to raise_error
46
+ allow(visitor).to receive(:visit_compound_datum).with(datum)
47
+ expect { datum.accept(visitor) }.not_to raise_error
48
48
  end
49
49
 
50
- it 'should return its text representation' do
50
+ it 'returns its text representation' do
51
51
  txt1 = '<Skeem::SkmCompoundDatum: <Skeem::SkmInteger: 1>,'
52
52
  txt2 = '<Skeem::SkmInteger: 2>, <Skeem::SkmInteger: 3>>'
53
- expect(subject.inspect).to eq("#{txt1} #{txt2}")
53
+ expect(datum.inspect).to eq("#{txt1} #{txt2}")
54
54
  end
55
55
  end # context
56
56
 
@@ -59,39 +59,40 @@ module Skeem
59
59
  let(:quirk_members) { [integer(1), quirk_datum, integer(3)] }
60
60
  let(:runtime) { double('fake-runtime') }
61
61
 
62
- it 'should evaluate its members' do
62
+ it 'evaluates its members' do
63
63
  # subject contains simple literals
64
- expect(subject.evaluate(runtime)).to eq(subject)
64
+ expect(datum.evaluate(runtime)).to eq(datum)
65
65
 
66
66
  # Check that members receive the 'evaluate' message
67
- expect(quirk_datum).to receive(:evaluate).with(runtime).and_return(integer(2))
68
- instance = SkmCompoundDatum.new(quirk_members)
69
- expect(instance.evaluate(runtime)).to eq(subject)
67
+ allow(quirk_datum).to receive(:evaluate).with(runtime).and_return(integer(2))
68
+ instance = described_class.new(quirk_members)
69
+ expect(instance.evaluate(runtime)).to eq(datum)
70
70
  end
71
71
 
72
- it 'should quasiquoting its members' do
72
+ it 'quasiquotes its members' do
73
73
  # subject contains simple literals
74
- expect(subject.quasiquote(runtime)).to eq(subject)
74
+ expect(datum.quasiquote(runtime)).to eq(datum)
75
75
 
76
76
  # Check that members receive the 'quasiquote' message
77
- expect(quirk_datum).to receive(:quasiquote).with(runtime).and_return(integer(2))
78
- instance = SkmCompoundDatum.new(quirk_members)
79
- expect(instance.quasiquote(runtime)).to eq(subject)
77
+ allow(quirk_datum).to receive(:quasiquote).with(runtime).and_return(integer(2))
78
+ instance = described_class.new(quirk_members)
79
+ expect(instance.quasiquote(runtime)).to eq(datum)
80
80
  end
81
81
  end # context
82
82
  end # describe
83
83
 
84
84
  describe SkmVector do
85
85
  let(:sample_members) { [1, 2, 3] }
86
- subject { SkmVector.new(sample_members) }
86
+
87
+ subject(:vector) { described_class.new(sample_members) }
87
88
 
88
89
  context 'Initialization:' do
89
- it 'should be initialized with its members' do
90
- expect { SkmVector.new(sample_members) }.not_to raise_error
90
+ it 'is initialized with its members' do
91
+ expect { described_class.new(sample_members) }.not_to raise_error
91
92
  end
92
93
 
93
- it 'should react positively to vector? predicate' do
94
- expect(subject).to be_vector
94
+ it 'reacts positively to vector? predicate' do
95
+ expect(vector).to be_vector
95
96
  end
96
97
  end # context
97
98
  end # describe
@@ -6,30 +6,31 @@ require_relative '../../lib/skeem/skm_element' # Load the class under test
6
6
  module Skeem
7
7
  describe SkmElement do
8
8
  let(:pos) { double('fake-position') }
9
- subject { SkmElement.new(pos) }
9
+
10
+ subject(:element) { described_class.new(pos) }
10
11
 
11
12
  context 'Initialization:' do
12
- it 'should be initialized with a position' do
13
- expect { SkmElement.new(pos) }.not_to raise_error
13
+ it 'is initialized with a position' do
14
+ expect { described_class.new(pos) }.not_to raise_error
14
15
  end
15
16
 
16
- it 'should know its position' do
17
- expect(subject.position).to eq(pos)
17
+ it 'knows its position' do
18
+ expect(element.position).to eq(pos)
18
19
  end
19
20
 
20
21
  # Default (overridable) behavior of SkmElement
21
- it 'should react by default to predicates' do
22
- expect(subject).not_to be_boolean
23
- expect(subject).not_to be_number
24
- expect(subject).not_to be_real
25
- expect(subject).not_to be_integer
26
- expect(subject).not_to be_string
27
- expect(subject).not_to be_symbol
28
- expect(subject).not_to be_list
29
- expect(subject).not_to be_null
30
- expect(subject).not_to be_pair
31
- expect(subject).not_to be_vector
32
- expect(subject).not_to be_verbatim
22
+ it 'reacts by default to predicates' do
23
+ expect(element).not_to be_boolean
24
+ expect(element).not_to be_number
25
+ expect(element).not_to be_real
26
+ expect(element).not_to be_integer
27
+ expect(element).not_to be_string
28
+ expect(element).not_to be_symbol
29
+ expect(element).not_to be_list
30
+ expect(element).not_to be_null
31
+ expect(element).not_to be_pair
32
+ expect(element).not_to be_vector
33
+ expect(element).not_to be_verbatim
33
34
  end
34
35
  end # context
35
36
 
@@ -38,38 +39,38 @@ module Skeem
38
39
  let(:visitor) { double('fake-visitor') }
39
40
  let(:not_implemented) { NotImplementedError }
40
41
 
41
- it 'should be equivalent to itself' do
42
- expect(subject).to be_eqv(subject)
43
- expect(subject).not_to be_eqv(subject.clone)
42
+ it 'is equivalent to itself' do
43
+ expect(element).to be_eqv(element)
44
+ expect(element).not_to be_eqv(element.clone)
44
45
  end
45
46
 
46
- it "should ignore the 'done!' message" do
47
- expect { subject.done! }.not_to raise_error
47
+ it "ignores the 'done!' message" do
48
+ expect { element.done! }.not_to raise_error
48
49
  end
49
50
 
50
- it "should ignore the 'quoted!' message" do
51
- expect { subject.quoted! }.not_to raise_error
51
+ it "ignores the 'quoted!' message" do
52
+ expect { element.quoted! }.not_to raise_error
52
53
  end
53
54
 
54
- it "should ignore the 'unquoted!' message" do
55
- expect { subject.unquoted! }.not_to raise_error
55
+ it "ignores the 'unquoted!' message" do
56
+ expect { element.unquoted! }.not_to raise_error
56
57
  end
57
58
 
58
- it "should complain when receiving 'skm_equal?' message" do
59
+ it "complains when receiving 'skm_equal?' message" do
59
60
  msg = 'Missing implementation of method Skeem::SkmElement#skm_equal?'
60
- expect { subject.skm_equal?('omg') }.to raise_error(NotImplementedError, msg)
61
+ expect { element.skm_equal?('omg') }.to raise_error(NotImplementedError, msg)
61
62
  end
62
63
 
63
- it "should complain when receiving 'evaluate' message" do
64
- expect { subject.evaluate(runtime) }.to raise_error(not_implemented)
64
+ it "complains when receiving 'evaluate' message" do
65
+ expect { element.evaluate(runtime) }.to raise_error(not_implemented)
65
66
  end
66
67
 
67
- it "should complain when receiving 'quasiquote' message" do
68
- expect { subject.quasiquote(runtime) }.to raise_error(not_implemented)
68
+ it "complains when receiving 'quasiquote' message" do
69
+ expect { element.quasiquote(runtime) }.to raise_error(not_implemented)
69
70
  end
70
71
 
71
- it "should complain when receiving 'accept' message" do
72
- expect { subject.accept(visitor) }.to raise_error(not_implemented)
72
+ it "complains when receiving 'accept' message" do
73
+ expect { element.accept(visitor) }.to raise_error(not_implemented)
73
74
  end
74
75
  end # context
75
76
  end # describe