sequitur 0.1.13 → 0.1.14

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.
@@ -4,7 +4,6 @@ require_relative '../spec_helper'
4
4
  require_relative '../../lib/sequitur/sequitur_grammar'
5
5
 
6
6
  module Sequitur # Re-open the module to get rid of qualified names
7
-
8
7
  describe SequiturGrammar do
9
8
  # Factory method. Returns an empty enumerator (
10
9
  # i.e. without elements to iterate)
@@ -13,7 +12,6 @@ describe SequiturGrammar do
13
12
  end
14
13
 
15
14
  context 'Creation from an enumeration of tokens:' do
16
-
17
15
  it 'could be created with an empty enumerator' do
18
16
  expect { SequiturGrammar.new(empty_enum) }.not_to raise_error
19
17
 
@@ -124,7 +122,7 @@ describe SequiturGrammar do
124
122
  expect(instance.start.rhs).to eq([p3, p2, p3])
125
123
  expect(p1.rhs).to eq(%w(letter_b letter_e))
126
124
  expect(p2.rhs).to eq([p1, p1])
127
- expect(p3.rhs).to eq(['letter_b',p2, 'letter_e'])
125
+ expect(p3.rhs).to eq(['letter_b', p2, 'letter_e'])
128
126
  end
129
127
 
130
128
  it 'should work with Symbol instead of single char input tokens' do
@@ -287,7 +285,6 @@ SNIPPET
287
285
  end # context
288
286
 
289
287
  context 'Generating a text representation of itself:' do
290
-
291
288
  it 'should generate a text representation when empty' do
292
289
  instance = SequiturGrammar.new(empty_enum)
293
290
  expectation = "#{instance.start.object_id} : ."
@@ -301,7 +298,6 @@ SNIPPET
301
298
  expect(instance.to_string).to eq(expectation)
302
299
  end
303
300
  end # context
304
-
305
301
  end # describe
306
302
  end # module
307
303
 
@@ -1,124 +1,115 @@
1
- require_relative '../spec_helper'
2
-
3
- # Load the class under test
4
- require_relative '../../lib/sequitur/symbol_sequence'
5
- require_relative '../../lib/sequitur/production_ref'
6
- require_relative '../../lib/sequitur/production'
7
-
8
- module Sequitur # Re-open the module to get rid of qualified names
9
-
10
- describe SymbolSequence do
11
-
12
- let(:instance) { SymbolSequence.new }
13
-
14
- context 'Creation and initialization:' do
15
-
16
- it 'should be created without argument' do
17
- expect { SymbolSequence.new }.not_to raise_error
18
- end
19
-
20
- it 'should be empty at creation' do
21
- expect(subject).to be_empty
22
- end
23
-
24
- end # context
25
-
26
- context 'Provided services:' do
27
- let(:a_prod) { Production.new }
28
-
29
- subject do
30
- an_instance = SymbolSequence.new
31
- [:a, :b, :c].each { |a_sym| an_instance << a_sym }
32
- an_instance
33
- end
34
-
35
- it 'should deep-copy clone itself' do
36
- ref = ProductionRef.new(a_prod)
37
-
38
- a, c = 'a', 'c'
39
- [a, ref, c].each { |ch| instance << ch }
40
- clone_a = instance.clone
41
-
42
- # Check that cloning works
43
- expect(clone_a).to eq(instance)
44
-
45
- # Reference objects are distinct but points to same production
46
- expect(clone_a.symbols[1].object_id).not_to eq(instance.symbols[1])
47
-
48
- # Modifying the clone...
49
- clone_a.symbols[1] = 'diff'
50
- expect(clone_a).not_to eq(instance)
51
-
52
- # ... should leave original unchanged
53
- expect(instance.symbols[1]).to eq(ref)
54
- end
55
-
56
-
57
- it 'should tell that it is equal to itself' do
58
- # Case: Non-empty sequence
59
- expect(subject).to eq(subject)
60
-
61
- # Case: empty sequence
62
- expect(instance).to eq(instance)
63
- end
64
-
65
- it 'should know whether it is equal to another instance' do
66
- expect(instance).to eq(instance)
67
-
68
- expect(subject).not_to eq(instance)
69
- [:a, :b, :c].each { |a_sym| instance << a_sym }
70
- expect(subject).to eq(instance)
71
-
72
- # Check that element order is relevant
73
- instance.symbols.rotate!
74
- expect(subject).not_to eq(instance)
75
- end
76
-
77
- it 'should know whether it is equal to an array' do
78
- expect(subject).to eq([:a, :b, :c])
79
-
80
- # Check that element order is relevant
81
- expect(subject).not_to eq([:c, :b, :a])
82
- end
83
-
84
- it 'should know that is not equal to something else' do
85
- expect(subject).not_to eq(:abc)
86
- end
87
-
88
-
89
- it 'should know its references' do
90
- ref = ProductionRef.new(a_prod)
91
- 2.times { subject << ref }
92
-
93
- refs = subject.references
94
- expect(refs.size).to eq(2)
95
- expect(refs).to eq([ref, ref])
96
-
97
- refs = subject.references
98
- expect(refs.size).to eq(2)
99
- expect(refs).to eq([ref, ref])
100
- specific_refs = subject.references_of(a_prod)
101
- expect(specific_refs).to eq(refs)
102
-
103
-
104
- another = Production.new
105
- another_ref = ProductionRef.new(another)
106
- subject << another_ref
107
- refs = subject.references
108
- expect(refs.size).to eq(3)
109
- expect(refs).to eq([ref, ref, another])
110
- specific_refs = subject.references_of(a_prod)
111
- expect(specific_refs).to eq([ref, ref])
112
- specific_refs = subject.references_of(another)
113
- expect(specific_refs).to eq([another])
114
- end
115
-
116
- end # context
117
-
118
-
119
-
120
- end # describe
121
-
122
- end # module
123
-
124
- # End of file
1
+ require_relative '../spec_helper'
2
+
3
+ # Load the class under test
4
+ require_relative '../../lib/sequitur/symbol_sequence'
5
+ require_relative '../../lib/sequitur/production_ref'
6
+ require_relative '../../lib/sequitur/production'
7
+
8
+ module Sequitur # Re-open the module to get rid of qualified names
9
+ describe SymbolSequence do
10
+ let(:instance) { SymbolSequence.new }
11
+
12
+ context 'Creation and initialization:' do
13
+ it 'should be created without argument' do
14
+ expect { SymbolSequence.new }.not_to raise_error
15
+ end
16
+
17
+ it 'should be empty at creation' do
18
+ expect(subject).to be_empty
19
+ end
20
+ end # context
21
+
22
+ context 'Provided services:' do
23
+ let(:a_prod) { Production.new }
24
+
25
+ subject do
26
+ an_instance = SymbolSequence.new
27
+ [:a, :b, :c].each { |a_sym| an_instance << a_sym }
28
+ an_instance
29
+ end
30
+
31
+ it 'should deep-copy clone itself' do
32
+ ref = ProductionRef.new(a_prod)
33
+
34
+ a, c = 'a', 'c'
35
+ [a, ref, c].each { |ch| instance << ch }
36
+ clone_a = instance.clone
37
+
38
+ # Check that cloning works
39
+ expect(clone_a).to eq(instance)
40
+
41
+ # Reference objects are distinct but points to same production
42
+ expect(clone_a.symbols[1].object_id).not_to eq(instance.symbols[1])
43
+
44
+ # Modifying the clone...
45
+ clone_a.symbols[1] = 'diff'
46
+ expect(clone_a).not_to eq(instance)
47
+
48
+ # ... should leave original unchanged
49
+ expect(instance.symbols[1]).to eq(ref)
50
+ end
51
+
52
+
53
+ it 'should tell that it is equal to itself' do
54
+ # Case: Non-empty sequence
55
+ expect(subject).to eq(subject)
56
+
57
+ # Case: empty sequence
58
+ expect(instance).to eq(instance)
59
+ end
60
+
61
+ it 'should know whether it is equal to another instance' do
62
+ expect(instance).to eq(instance)
63
+
64
+ expect(subject).not_to eq(instance)
65
+ [:a, :b, :c].each { |a_sym| instance << a_sym }
66
+ expect(subject).to eq(instance)
67
+
68
+ # Check that element order is relevant
69
+ instance.symbols.rotate!
70
+ expect(subject).not_to eq(instance)
71
+ end
72
+
73
+ it 'should know whether it is equal to an array' do
74
+ expect(subject).to eq([:a, :b, :c])
75
+
76
+ # Check that element order is relevant
77
+ expect(subject).not_to eq([:c, :b, :a])
78
+ end
79
+
80
+ it 'should know that is not equal to something else' do
81
+ expect(subject).not_to eq(:abc)
82
+ end
83
+
84
+
85
+ it 'should know its references' do
86
+ ref = ProductionRef.new(a_prod)
87
+ 2.times { subject << ref }
88
+
89
+ refs = subject.references
90
+ expect(refs.size).to eq(2)
91
+ expect(refs).to eq([ref, ref])
92
+
93
+ refs = subject.references
94
+ expect(refs.size).to eq(2)
95
+ expect(refs).to eq([ref, ref])
96
+ specific_refs = subject.references_of(a_prod)
97
+ expect(specific_refs).to eq(refs)
98
+
99
+
100
+ another = Production.new
101
+ another_ref = ProductionRef.new(another)
102
+ subject << another_ref
103
+ refs = subject.references
104
+ expect(refs.size).to eq(3)
105
+ expect(refs).to eq([ref, ref, another])
106
+ specific_refs = subject.references_of(a_prod)
107
+ expect(specific_refs).to eq([ref, ref])
108
+ specific_refs = subject.references_of(another)
109
+ expect(specific_refs).to eq([another])
110
+ end
111
+ end # context
112
+ end # describe
113
+ end # module
114
+
115
+ # End of file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequitur
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake