rley 0.3.01 → 0.3.04

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,7 +15,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
15
15
  end
16
16
 
17
17
  it 'should know its label' do
18
- allow(sample_nt).to receive(:to_s).and_return('NT')
18
+ expect(sample_nt).to receive(:to_s).and_return('NT')
19
19
  expect(subject.label).to eq('.NT')
20
20
  end
21
21
  end # context
@@ -224,7 +224,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
224
224
  [:after_pforest, [grm_abc_pforest1]]
225
225
  ]
226
226
  expectations.each do |(msg, args)|
227
- allow(listener1).to receive(msg).with(*args).ordered
227
+ expect(listener1).to receive(msg).with(*args).ordered
228
228
  end
229
229
 
230
230
  # Here we go...
@@ -206,7 +206,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
206
206
  [:after_ptree, [grm_abc_ptree1]]
207
207
  ]
208
208
  expectations.each do |(msg, args)|
209
- allow(listener1).to receive(msg).with(*args).ordered
209
+ expect(listener1).to receive(msg).with(*args).ordered
210
210
  end
211
211
 
212
212
  # Here we go...
@@ -317,12 +317,9 @@ SNIPPET
317
317
  parser.parse(tokens)
318
318
  end
319
319
 
320
- # Helper. Build a state tracker and a parse tree builder.
321
- def prepare_parse_forest(aParsing)
322
- # Accessing private methods by sending message
323
- entry_tracker = aParsing.send(:new_entry_tracker)
324
- builder = aParsing.send(:forest_builder, entry_tracker.entry_set_index)
325
- return [entry_tracker, builder]
320
+ it 'should build a parse forest' do
321
+ expect{subject.parse_forest }.not_to raise_error
322
+
326
323
  end
327
324
  =begin
328
325
  it 'should create the root of a parse forest' do
@@ -99,19 +99,19 @@ module Rley # Open this namespace to avoid module qualifier prefixes
99
99
 
100
100
  # Adding states
101
101
  subject.push_entry(entry1)
102
- allow(vertex1).to receive(:production).and_return(prod1)
103
- allow(vertex1).to receive(:"reduce_item?").and_return(true)
104
- allow(vertex1).to receive(:lhs).and_return(:something)
102
+ expect(vertex1).to receive(:production).and_return(prod1)
103
+ expect(vertex1).to receive(:"reduce_item?").and_return(true)
104
+ expect(vertex1).to receive(:lhs).and_return(:something)
105
105
  expect(subject.ambiguities.size).to eq(0)
106
- allow(vertex2).to receive(:production).and_return(prod2)
107
- allow(vertex2).to receive(:"reduce_item?").and_return(true)
108
- allow(vertex2).to receive(:lhs).and_return(:something_else)
106
+ expect(vertex2).to receive(:production).and_return(prod2)
107
+ expect(vertex2).to receive(:"reduce_item?").and_return(true)
108
+ expect(vertex2).to receive(:lhs).and_return(:something_else)
109
109
  subject.push_entry(entry2)
110
110
  expect(subject.ambiguities.size).to eq(0)
111
111
  # dotted_rule3 = double('fake_dotted_rule3')
112
- # allow(dotted_rule3).to receive(:production).and_return(prod2)
113
- # allow(dotted_rule3).to receive(:"reduce_item?").and_return(true)
114
- # allow(dotted_rule3).to receive(:lhs).and_return(:something_else)
112
+ # expect(dotted_rule3).to receive(:production).and_return(prod2)
113
+ # expect(dotted_rule3).to receive(:"reduce_item?").and_return(true)
114
+ # expect(dotted_rule3).to receive(:lhs).and_return(:something_else)
115
115
  # entry3 = ParseEntry.new(dotted_rule3, 5)
116
116
  subject.push_entry(entry3)
117
117
  expect(subject.ambiguities[0]).to eq([entry2, entry3])
@@ -125,8 +125,8 @@ module Rley # Open this namespace to avoid module qualifier prefixes
125
125
  # Adding states
126
126
  subject.push_entry(entry1)
127
127
  subject.push_entry(entry2)
128
- allow(vertex1).to receive(:next_symbol).and_return(:b)
129
- allow(vertex2).to receive(:next_symbol).and_return(:a)
128
+ expect(vertex1).to receive(:next_symbol).and_return(:b)
129
+ expect(vertex2).to receive(:next_symbol).and_return(:a)
130
130
  expect(subject.states_expecting(:a)).to eq([entry2])
131
131
  expect(subject.states_expecting(:b)).to eq([entry1])
132
132
  end
@@ -140,8 +140,8 @@ module Rley # Open this namespace to avoid module qualifier prefixes
140
140
  # Adding states
141
141
  subject.push_entry(entry1)
142
142
  subject.push_entry(entry2)
143
- allow(vertex1).to receive(:production).and_return(:dummy)
144
- allow(vertex2).to receive(:production).and_return(a_prod)
143
+ expect(vertex1).to receive(:production).and_return(:dummy)
144
+ expect(vertex2).to receive(:production).and_return(a_prod)
145
145
  expect(subject.states_for(a_prod)).to eq([entry2])
146
146
  end
147
147
 
@@ -153,11 +153,11 @@ module Rley # Open this namespace to avoid module qualifier prefixes
153
153
  # Adding states
154
154
  subject.push_entry(entry1)
155
155
  subject.push_entry(entry2)
156
- allow(vertex1).to receive(:production).and_return(prod1)
157
- allow(prod1).to receive(:lhs).and_return(:dummy)
158
- allow(vertex2).to receive(:production).and_return(prod2)
159
- allow(vertex2).to receive(:reduce_item?).and_return(true)
160
- allow(prod2).to receive(:lhs).and_return(non_term)
156
+ expect(vertex1).to receive(:production).and_return(prod1)
157
+ expect(prod1).to receive(:lhs).and_return(:dummy)
158
+ expect(vertex2).to receive(:production).and_return(prod2)
159
+ expect(vertex2).to receive(:reduce_item?).and_return(true)
160
+ expect(prod2).to receive(:lhs).and_return(non_term)
161
161
  expect(subject.states_rewriting(non_term)).to eq([entry2])
162
162
  end
163
163
 
@@ -166,7 +166,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
166
166
  it 'should complain when impossible predecessor of parse state' do
167
167
  subject.push_entry(entry1)
168
168
  subject.push_entry(entry2)
169
- allow(vertex1).to receive(:prev_position).and_return(nil)
169
+ expect(vertex1).to receive(:prev_position).and_return(nil)
170
170
  err = StandardError
171
171
  expect { subject.predecessor_state(entry1) }.to raise_error(err)
172
172
  end
@@ -110,13 +110,13 @@ module Rley # Open this namespace to avoid module qualifier prefixes
110
110
 
111
111
  # Case: item vertex not at end of rhs
112
112
  v1 = double('vertex-not-at-end')
113
- allow(v1).to receive(:complete?).and_return(false)
113
+ expect(v1).to receive(:complete?).and_return(false)
114
114
  instance3 = ParseEntry.new(v1, 3)
115
115
  expect(instance3).not_to be_exit_entry
116
116
 
117
117
  # Case: item vertex at end of rhs
118
118
  v2 = double('vertex-at-end')
119
- allow(v2).to receive(:complete?).and_return(true)
119
+ expect(v2).to receive(:complete?).and_return(true)
120
120
  instance4 = ParseEntry.new(v2, 3)
121
121
  expect(instance4).to be_exit_entry
122
122
  end
@@ -154,13 +154,13 @@ module Rley # Open this namespace to avoid module qualifier prefixes
154
154
 
155
155
  # Case: item vertex not at start of rhs
156
156
  v1 = double('vertex-not-at-start')
157
- allow(v1).to receive(:prev_symbol).and_return('symbol')
157
+ expect(v1).to receive(:prev_symbol).and_return('symbol')
158
158
  instance3 = ParseEntry.new(v1, 3)
159
159
  expect(instance3.prev_symbol).to eq('symbol')
160
160
 
161
161
  # Case: item vertex at start of rhs
162
162
  v2 = double('vertex-at-start')
163
- allow(v2).to receive(:prev_symbol).and_return(nil)
163
+ expect(v2).to receive(:prev_symbol).and_return(nil)
164
164
  instance4 = ParseEntry.new(v2, 0)
165
165
  expect(instance4.prev_symbol).to be_nil
166
166
  end
@@ -176,13 +176,13 @@ module Rley # Open this namespace to avoid module qualifier prefixes
176
176
 
177
177
  # Case: item vertex not at end of rhs
178
178
  v1 = double('vertex-not-at-end')
179
- allow(v1).to receive(:next_symbol).and_return('symbol')
179
+ expect(v1).to receive(:next_symbol).and_return('symbol')
180
180
  instance3 = ParseEntry.new(v1, 3)
181
181
  expect(instance3.next_symbol).to eq('symbol')
182
182
 
183
183
  # Case: item vertex at end of rhs
184
184
  v2 = double('vertex-at-end')
185
- allow(v2).to receive(:next_symbol).and_return(nil)
185
+ expect(v2).to receive(:next_symbol).and_return(nil)
186
186
  instance4 = ParseEntry.new(v2, 3)
187
187
  expect(instance4.next_symbol).to be_nil
188
188
  end