scripref 0.15.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,6 @@
1
- # - encoding: utf-8 -
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  require 'test_helper'
3
5
 
4
6
  class TestBookname < Test::Unit::TestCase
@@ -6,7 +8,7 @@ class TestBookname < Test::Unit::TestCase
6
8
  include Scripref
7
9
 
8
10
  def setup
9
- @zef = Bookname.new(%w(Zefanja Zephanja), %w(Zef Zefan Zeph Zephan))
11
+ @zef = Bookname.new(osis_id: :Zeph, names: %w(Zefanja Zephanja), abbrevs: %w(Zef Zefan Zeph Zephan))
10
12
  end
11
13
 
12
14
  def test_name
data/test/test_english.rb CHANGED
@@ -1,4 +1,6 @@
1
- # - encoding: utf-8 -
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  require 'test_helper'
3
5
 
4
6
  class TestEnglish < Test::Unit::TestCase
@@ -30,21 +32,21 @@ class TestEnglish < Test::Unit::TestCase
30
32
  assert_match book_re, 'Rev'
31
33
  end
32
34
 
33
- def test_book2num
34
- assert_book_num 1, 'Genesis'
35
- assert_book_num 40, 'Matthew'
36
- assert_book_num 66, 'Revelation'
37
- assert_book_num 1, 'Gen'
38
- assert_book_num 1, 'Ge'
39
- assert_book_num 55, '2 Tim'
40
- assert_book_num 55, '2Tim'
41
- assert_book_num 55, '2Tm'
42
- assert_book_num 40, 'Mat'
43
- assert_book_num 66, 'Rev'
35
+ def test_book2osis_id
36
+ assert_osis_book_id :Gen, 'Genesis'
37
+ assert_osis_book_id :Matt, 'Matthew'
38
+ assert_osis_book_id :Rev, 'Revelation'
39
+ assert_osis_book_id :Gen, 'Gen'
40
+ assert_osis_book_id :Gen, 'Ge'
41
+ assert_osis_book_id :'2Tim', '2 Tim'
42
+ assert_osis_book_id :'2Tim', '2Tim'
43
+ assert_osis_book_id :'2Tim', '2Tm'
44
+ assert_osis_book_id :Matt, 'Mat'
45
+ assert_osis_book_id :Rev, 'Rev'
44
46
  end
45
47
 
46
- def assert_book_num num, str
47
- assert_equal num, @parser.parse(str).first.b1
48
+ def assert_osis_book_id id, str
49
+ assert_equal id, @parser.parse(str).first.b1
48
50
  end
49
51
 
50
52
  end
@@ -1,4 +1,6 @@
1
- # - encoding: utf-8 -
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  require 'test_helper'
3
5
 
4
6
  class TestFormatter < Test::Unit::TestCase
@@ -13,105 +15,105 @@ class TestFormatter < Test::Unit::TestCase
13
15
 
14
16
  def test_only_book
15
17
  text = 'Ruth'
16
- assert_formated_text_for_ast text, [pass(text: text, b1: 8, b2: 8)]
18
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Ruth, b2: :Ruth)]
17
19
  end
18
20
 
19
21
  def test_book_and_chapter
20
22
  text = 'Ruth 2'
21
- assert_formated_text_for_ast text, [pass(text: text, b1: 8, c1: 2, b2: 8, c2: 2)]
23
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Ruth, c1: 2, b2: :Ruth, c2: 2)]
22
24
  end
23
25
 
24
26
  def test_book_chapter_and_verse
25
27
  text = 'Ruth 2,5'
26
- assert_formated_text_for_ast text, [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5)]
28
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5)]
27
29
  end
28
30
 
29
31
  def test_verse_range
30
32
  text = 'Ruth 2,5-11'
31
- assert_formated_text_for_ast text, [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 11)]
33
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 11)]
32
34
  end
33
35
 
34
36
  def test_chapter_verse_range
35
37
  text = 'Ruth 2,5-3,7'
36
- assert_formated_text_for_ast text, [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 3, v2: 7)]
38
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 3, v2: 7)]
37
39
  end
38
40
 
39
41
  def test_chapter_range
40
42
  text = 'Ruth 2-3'
41
- assert_formated_text_for_ast text, [pass(text: text, b1: 8, c1: 2, b2: 8, c2: 3)]
43
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Ruth, c1: 2, b2: :Ruth, c2: 3)]
42
44
  end
43
45
 
44
46
  def test_book_range
45
47
  text = '1. Mose-Offenbarung'
46
- assert_formated_text_for_ast text, [pass(text: text, b1: 1, b2: 66)]
48
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Gen, b2: :Rev)]
47
49
  end
48
50
 
49
51
  def test_book_chapter_range
50
52
  text = '1. Mose 1-Offenbarung 22'
51
- assert_formated_text_for_ast text, [pass(text: text, b1: 1, c1: 1, b2: 66, c2: 22)]
53
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Gen, c1: 1, b2: :Rev, c2: 22)]
52
54
  end
53
55
 
54
56
  def test_book_chapter_verse_range
55
57
  text = '1. Mose 1,1-Offenbarung 22,21'
56
- assert_formated_text_for_ast text, [pass(text: text, b1: 1, c1: 1, v1: 1, b2: 66, c2: 22, v2: 21)]
58
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Gen, c1: 1, v1: 1, b2: :Rev, c2: 22, v2: 21)]
57
59
  end
58
60
 
59
61
  def test_one_following_verse
60
62
  text = 'Ruth 2,5f'
61
- assert_formated_text_for_ast text, [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: :f)]
63
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: :f)]
62
64
  end
63
65
 
64
66
  def test_more_following_verse
65
67
  text = 'Ruth 2,5ff'
66
- assert_formated_text_for_ast text, [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: :ff)]
68
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: :ff)]
67
69
  end
68
70
 
69
71
  def test_first_addon
70
72
  text = 'Ruth 2,5a'
71
- assert_formated_text_for_ast text, [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5, a1: :a)]
73
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5, a1: :a)]
72
74
  end
73
75
 
74
76
  def test_second_addon
75
77
  text = 'Ruth 2,5-7a'
76
- assert_formated_text_for_ast text, [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 7, a2: :a)]
78
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 7, a2: :a)]
77
79
  end
78
80
 
79
81
  def test_both_addons
80
82
  text = 'Ruth 2,5b-7a'
81
- assert_formated_text_for_ast text, [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 7, a1: :b, a2: :a)]
83
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 7, a1: :b, a2: :a)]
82
84
  end
83
85
 
84
86
  def test_reset_addons
85
87
  text = 'Ruth'
86
- assert_formated_text_for_ast text, [pass(text: text, b1: 8, b2: 8)]
88
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Ruth, b2: :Ruth)]
87
89
  end
88
90
 
89
91
  def test_book_with_only_one_chapter
90
92
  text = 'Obadja 3'
91
- assert_formated_text_for_ast text, [pass(text: text, b1: 31, c1: 1, v1: 3, b2: 31, c2: 1, v2: 3)]
93
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Obad, c1: 1, v1: 3, b2: :Obad, c2: 1, v2: 3)]
92
94
  text = 'Obadja 1'
93
- assert_formated_text_for_ast text, [pass(text: text, b1: 31, c1: 1, v1: 1, b2: 31, c2: 1, v2: 1)]
95
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Obad, c1: 1, v1: 1, b2: :Obad, c2: 1, v2: 1)]
94
96
  end
95
97
 
96
98
  def test_book_with_only_one_chapter_range
97
99
  text = 'Obadja 3-5'
98
- assert_formated_text_for_ast text, [pass(text: text, b1: 31, c1: 1, v1: 3, b2: 31, c2: 1, v2: 5)]
100
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Obad, c1: 1, v1: 3, b2: :Obad, c2: 1, v2: 5)]
99
101
  text = 'Obadja 1-4'
100
- assert_formated_text_for_ast text, [pass(text: text, b1: 31, c1: 1, v1: 1, b2: 31, c2: 1, v2: 4)]
102
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Obad, c1: 1, v1: 1, b2: :Obad, c2: 1, v2: 4)]
101
103
  end
102
104
 
103
105
  def test_book_with_only_one_chapter_at_begin_of_range
104
106
  text = 'Obadja-Jona'
105
- assert_formated_text_for_ast text, [pass(text: text, b1: 31, c1: 1, b2: 32)]
107
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Obad, c1: 1, b2: :Jonah)]
106
108
  text = 'Obadja 3-Jona 2,4'
107
- assert_formated_text_for_ast text, [pass(text: text, b1: 31, c1: 1, v1: 3, b2: 32, c2: 2, v2: 4)]
109
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Obad, c1: 1, v1: 3, b2: :Jonah, c2: 2, v2: 4)]
108
110
  end
109
111
 
110
112
  def test_book_with_only_one_chapter_at_end_of_range
111
113
  text = 'Amos 2,4-Obadja 3'
112
- assert_formated_text_for_ast text, [pass(text: text, b1: 30, c1: 2, v1: 4, b2: 31, c2: 1, v2: 3)]
114
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Amos, c1: 2, v1: 4, b2: :Obad, c2: 1, v2: 3)]
113
115
  text = 'Amos 2,4-Obadja 1'
114
- assert_formated_text_for_ast text, [pass(text: text, b1: 30, c1: 2, v1: 4, b2: 31, c2: 1, v2: 1)]
116
+ assert_formated_text_for_ast text, [pass(text: text, b1: :Amos, c1: 2, v1: 4, b2: :Obad, c2: 1, v2: 1)]
115
117
  end
116
118
 
117
119
  ######################################################################
@@ -121,49 +123,49 @@ class TestFormatter < Test::Unit::TestCase
121
123
  def test_two_books
122
124
  text = 'Ruth; Markus'
123
125
  t1, t2 = text.split(semi)
124
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, b2: 8), semi, pass(text: t2, b1: 41, b2: 41)]
126
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, b2: :Ruth), semi, pass(text: t2, b1: :Mark, b2: :Mark)]
125
127
  end
126
128
 
127
129
  def test_two_complete_refs
128
130
  text = 'Ruth 2,1; Markus 4,8'
129
131
  t1, t2 = text.split(semi)
130
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 1), semi, pass(text: t2, b1: 41, c1: 4, v1: 8, b2: 41, c2: 4, v2: 8)]
132
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 1), semi, pass(text: t2, b1: :Mark, c1: 4, v1: 8, b2: :Mark, c2: 4, v2: 8)]
131
133
  end
132
134
 
133
135
  def test_two_refs_same_book
134
136
  text = 'Ruth 2,1; 5,4'
135
137
  t1, t2 = text.split(semi)
136
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 1), semi, pass(text: t2, b1: 8, c1: 5, v1: 4, b2: 8, c2: 5, v2: 4)]
138
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 1), semi, pass(text: t2, b1: :Ruth, c1: 5, v1: 4, b2: :Ruth, c2: 5, v2: 4)]
137
139
  end
138
140
 
139
141
  def test_two_chapters_same_book
140
142
  text = 'Ruth 2; 5'
141
143
  t1, t2 = text.split(semi)
142
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, c1: 2, b2: 8, c2: 2), semi, pass(text: t2, b1: 8, c1: 5, b2: 8, c2: 5)]
144
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 2, b2: :Ruth, c2: 2), semi, pass(text: t2, b1: :Ruth, c1: 5, b2: :Ruth, c2: 5)]
143
145
  end
144
146
 
145
147
  def test_two_chapters_different_book
146
148
  text = 'Ruth 2; Markus 4'
147
149
  t1, t2 = text.split(semi)
148
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, c1: 2, b2: 8, c2: 2), semi, pass(text: t2, b1: 41, c1: 4, b2: 41, c2: 4)]
150
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 2, b2: :Ruth, c2: 2), semi, pass(text: t2, b1: :Mark, c1: 4, b2: :Mark, c2: 4)]
149
151
  end
150
152
 
151
153
  def test_two_verses
152
154
  text = 'Ruth 2,5.11'
153
155
  t1, t2 = text.split(dot)
154
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5), dot, pass(text: t2, b1: 8, c1: 2, v1: 11, b2: 8, c2: 2, v2: 11)]
156
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5), dot, pass(text: t2, b1: :Ruth, c1: 2, v1: 11, b2: :Ruth, c2: 2, v2: 11)]
155
157
  end
156
158
 
157
159
  def test_partial_passage_after_full_passage
158
160
  text = 'Ruth 2,5; 4'
159
161
  t1, t2 = text.split(semi)
160
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5), semi, pass(text: t2, b1: 8, c1: 4, b2: 8, c2: 4)]
162
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5), semi, pass(text: t2, b1: :Ruth, c1: 4, b2: :Ruth, c2: 4)]
161
163
  text = 'Ruth 2,5; Markus'
162
164
  t1, t2 = text.split(semi)
163
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5), semi, pass(text: t2, b1: 41, b2: 41)]
165
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5), semi, pass(text: t2, b1: :Mark, b2: :Mark)]
164
166
  text = 'Ruth 2,5; Markus 4'
165
167
  t1, t2 = text.split(semi)
166
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5), semi, pass(text: t2, b1: 41, c1: 4, b2: 41, c2: 4)]
168
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5), semi, pass(text: t2, b1: :Mark, c1: 4, b2: :Mark, c2: 4)]
167
169
  end
168
170
 
169
171
  ######################################################################
@@ -173,61 +175,61 @@ class TestFormatter < Test::Unit::TestCase
173
175
  def test_verse_range_and_separated_verse
174
176
  text = 'Ruth 2,1-3.11'
175
177
  t1, t2 = text.split(dot)
176
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 3), dot, pass(text: t2, b1: 8, c1: 2, v1: 11, b2: 8, c2: 2, v2: 11)]
178
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 3), dot, pass(text: t2, b1: :Ruth, c1: 2, v1: 11, b2: :Ruth, c2: 2, v2: 11)]
177
179
  end
178
180
 
179
181
  def test_separate_verse_and_verse_range
180
182
  text = 'Ruth 2,1.3-11'
181
183
  t1, t2 = text.split(dot)
182
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 1), dot, pass(text: t2, b1: 8, c1: 2, v1: 3, b2: 8, c2: 2, v2: 11)]
184
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 1), dot, pass(text: t2, b1: :Ruth, c1: 2, v1: 3, b2: :Ruth, c2: 2, v2: 11)]
183
185
  end
184
186
 
185
187
  def test_two_verse_ranges
186
188
  text = 'Ruth 2,1-3.7-11'
187
189
  t1, t2 = text.split(dot)
188
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 3), dot, pass(text: t2, b1: 8, c1: 2, v1: 7, b2: 8, c2: 2, v2: 11)]
190
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 3), dot, pass(text: t2, b1: :Ruth, c1: 2, v1: 7, b2: :Ruth, c2: 2, v2: 11)]
189
191
  end
190
192
 
191
193
  def test_two_verse_range_different_books
192
194
  text = 'Ruth 2,1-11; Markus 4,3-7'
193
195
  t1, t2 = text.split(semi)
194
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 11), semi, pass(text: t2, b1: 41, c1: 4, v1: 3, b2: 41, c2: 4, v2: 7)]
196
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 11), semi, pass(text: t2, b1: :Mark, c1: 4, v1: 3, b2: :Mark, c2: 4, v2: 7)]
195
197
  end
196
198
 
197
199
  def test_two_verse_range_different_chapters
198
200
  text = 'Ruth 2,1-11; 3,10-19'
199
201
  t1, t2 = text.split(semi)
200
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 11), semi, pass(text: t2, b1: 8, c1: 3, v1: 10, b2: 8, c2: 3, v2: 19)]
202
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 11), semi, pass(text: t2, b1: :Ruth, c1: 3, v1: 10, b2: :Ruth, c2: 3, v2: 19)]
201
203
  end
202
204
 
203
205
  def test_book_range_and_following_book
204
206
  text = 'Ruth-Markus; Johannes'
205
207
  t1, t2 = text.split(semi)
206
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, b2: 41), semi, pass(text: t2, b1: 43, b2: 43)]
208
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, b2: :Mark), semi, pass(text: t2, b1: :John, b2: :John)]
207
209
  end
208
210
 
209
211
  def test_chapter_range_and_following_book
210
212
  text = 'Ruth 1-2; Johannes 4'
211
213
  t1, t2 = text.split(semi)
212
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, c1: 1, b2: 8, c2: 2), semi, pass(text: t2, b1: 43, c1: 4, b2: 43, c2: 4)]
214
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 1, b2: :Ruth, c2: 2), semi, pass(text: t2, b1: :John, c1: 4, b2: :John, c2: 4)]
213
215
  end
214
216
 
215
217
  def test_chapter_range_and_following_chapter
216
218
  text = 'Ruth 1-2; 4'
217
219
  t1, t2 = text.split(semi)
218
- assert_formated_text_for_ast text, [pass(text: t1, b1: 8, c1: 1, b2: 8, c2: 2), semi, pass(text: t2, b1: 8, c1: 4, b2: 8, c2: 4)]
220
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 1, b2: :Ruth, c2: 2), semi, pass(text: t2, b1: :Ruth, c1: 4, b2: :Ruth, c2: 4)]
219
221
  end
220
222
 
221
223
  def test_book_only_after_full_passage
222
224
  text = 'Matthäus 3,4; Markus; Johannes 3,16'
223
225
  t1, t2, t3 = text.split(semi)
224
- assert_formated_text_for_ast text, [pass(text: t1, b1: 40, c1: 3, v1: 4, b2: 40, c2: 3, v2: 4), semi, pass(text: t2, b1: 41, b2: 41), semi, pass(text: t3, b1: 43, c1: 3, v1: 16, b2: 43, c2: 3, v2: 16)]
226
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Matt, c1: 3, v1: 4, b2: :Matt, c2: 3, v2: 4), semi, pass(text: t2, b1: :Mark, b2: :Mark), semi, pass(text: t3, b1: :John, c1: 3, v1: 16, b2: :John, c2: 3, v2: 16)]
225
227
  end
226
228
 
227
229
  def test_chapter_only_after_full_passage
228
230
  text = 'Matthäus 3,4; 8; Johannes 3,16'
229
231
  t1, t2, t3 = text.split(semi)
230
- assert_formated_text_for_ast text, [pass(text: t1, b1: 40, c1: 3, v1: 4, b2: 40, c2: 3, v2: 4), semi, pass(text: t2, b1: 40, c1: 8, b2: 40, c2: 8), semi, pass(text: t3, b1: 43, c1: 3, v1: 16, b2: 43, c2: 3, v2: 16)]
232
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Matt, c1: 3, v1: 4, b2: :Matt, c2: 3, v2: 4), semi, pass(text: t2, b1: :Matt, c1: 8, b2: :Matt, c2: 8), semi, pass(text: t3, b1: :John, c1: 3, v1: 16, b2: :John, c2: 3, v2: 16)]
231
233
  end
232
234
 
233
235
  ######################################################################
@@ -238,13 +240,13 @@ class TestFormatter < Test::Unit::TestCase
238
240
  text = 'Ruth 2,1-11.15; 3,7.9-12; Markus 4; 5,3.18-21'
239
241
  t1, t2, t3, t4, t5, t6, t7 = text.split(/; |\./)
240
242
  ast = [
241
- pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 11), dot,
242
- pass(text: t2, b1: 8, c1: 2, v1: 15, b2: 8, c2: 2, v2: 15), semi,
243
- pass(text: t3, b1: 8, c1: 3, v1: 7, b2: 8, c2: 3, v2: 7), dot,
244
- pass(text: t4, b1: 8, c1: 3, v1: 9, b2: 8, c2: 3, v2: 12), semi,
245
- pass(text: t5, b1: 41, c1: 4, b2: 41, c2: 4), semi,
246
- pass(text: t6, b1: 41, c1: 5, v1: 3, b2: 41, c2: 5, v2: 3), dot,
247
- pass(text: t7, b1: 41, c1: 5, v1: 18, b2: 41, c2: 5, v2: 21)
243
+ pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 11), dot,
244
+ pass(text: t2, b1: :Ruth, c1: 2, v1: 15, b2: :Ruth, c2: 2, v2: 15), semi,
245
+ pass(text: t3, b1: :Ruth, c1: 3, v1: 7, b2: :Ruth, c2: 3, v2: 7), dot,
246
+ pass(text: t4, b1: :Ruth, c1: 3, v1: 9, b2: :Ruth, c2: 3, v2: 12), semi,
247
+ pass(text: t5, b1: :Mark, c1: 4, b2: :Mark, c2: 4), semi,
248
+ pass(text: t6, b1: :Mark, c1: 5, v1: 3, b2: :Mark, c2: 5, v2: 3), dot,
249
+ pass(text: t7, b1: :Mark, c1: 5, v1: 18, b2: :Mark, c2: 5, v2: 21)
248
250
  ]
249
251
  assert_formated_text_for_ast text, ast
250
252
  end
@@ -257,13 +259,13 @@ class TestFormatter < Test::Unit::TestCase
257
259
  @german_formatter.bookformat = :abbrev
258
260
  text = 'Mat 3,4; Mar; Joh 3,16'
259
261
  t1, t2, t3 = text.split(semi)
260
- assert_formated_text_for_ast text, [pass(text: t1, b1: 40, c1: 3, v1: 4, b2: 40, c2: 3, v2: 4), semi, pass(text: t2, b1: 41, b2: 41), semi, pass(text: t3, b1: 43, c1: 3, v1: 16, b2: 43, c2: 3, v2: 16)]
262
+ assert_formated_text_for_ast text, [pass(text: t1, b1: :Matt, c1: 3, v1: 4, b2: :Matt, c2: 3, v2: 4), semi, pass(text: t2, b1: :Mark, b2: :Mark), semi, pass(text: t3, b1: :John, c1: 3, v1: 16, b2: :John, c2: 3, v2: 16)]
261
263
  end
262
264
 
263
265
  def test_exception_for_unhandled_bookformat
264
266
  assert_raise NoMethodError do
265
267
  @german_formatter.bookformat = :unknown
266
- @german_formatter.format [pass(text: 1, b1: 2, c1: 3, v1: 4, b2: 5, c2: 6, v2: 7)]
268
+ @german_formatter.format [pass(text: 1, b1: :Exod, c1: 3, v1: 4, b2: :Deut, c2: 6, v2: 7)]
267
269
  end
268
270
  end
269
271
  private
data/test/test_german.rb CHANGED
@@ -1,4 +1,6 @@
1
- # - encoding: utf-8 -
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  require 'test_helper'
3
5
 
4
6
  class TestGerman < Test::Unit::TestCase
@@ -31,15 +33,15 @@ class TestGerman < Test::Unit::TestCase
31
33
  end
32
34
 
33
35
  def test_book2num
34
- assert_book_num 1, '1. Mose'
35
- assert_book_num 40, 'Matthäus'
36
- assert_book_num 66, 'Offenbarung'
37
- assert_book_num 1, '1. Mo'
38
- assert_book_num 1, '1.Mo'
39
- assert_book_num 1, '1M'
40
- assert_book_num 40, 'Mat'
41
- assert_book_num 50, 'Phil'
42
- assert_book_num 66, 'Off'
36
+ assert_book_num :Gen, '1. Mose'
37
+ assert_book_num :Matt, 'Matthäus'
38
+ assert_book_num :Rev, 'Offenbarung'
39
+ assert_book_num :Gen, '1. Mo'
40
+ assert_book_num :Gen, '1.Mo'
41
+ assert_book_num :Gen, '1M'
42
+ assert_book_num :Matt, 'Mat'
43
+ assert_book_num :Phil, 'Phil'
44
+ assert_book_num :Rev, 'Off'
43
45
  end
44
46
 
45
47
  def assert_book_num num, str
data/test/test_helper.rb CHANGED
@@ -1,4 +1,6 @@
1
- # - encoding: utf-8 -
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  require 'scripref'
3
5
  require 'test/unit'
4
6
 
@@ -1,4 +1,6 @@
1
- # - encoding: utf-8 -
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  require 'test_helper'
3
5
 
4
6
  class TestIntegration < Test::Unit::TestCase
data/test/test_parser.rb CHANGED
@@ -1,4 +1,6 @@
1
- # - encoding: utf-8 -
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  require 'test_helper'
3
5
 
4
6
  class TestParser < Test::Unit::TestCase
@@ -12,21 +14,21 @@ class TestParser < Test::Unit::TestCase
12
14
 
13
15
  def test_only_book
14
16
  text = 'Ruth'
15
- assert_parsed_ast_for_text [pass(text: text, b1: 8, b2: 8)], text
17
+ assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, b2: :Ruth)], text
16
18
  end
17
19
 
18
20
  def test_book_abbrev
19
21
  text = 'Ru'
20
- assert_parsed_ast_for_text [pass(text: text, b1: 8, b2: 8)], text
22
+ assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, b2: :Ruth)], text
21
23
  text = 'Offb'
22
- assert_parsed_ast_for_text [pass(text: text, b1: 66, b2: 66)], text
24
+ assert_parsed_ast_for_text [pass(text: text, b1: :Rev, b2: :Rev)], text
23
25
  end
24
26
 
25
27
  def test_book_abbrev_with_period
26
28
  text = 'Ru.'
27
- assert_parsed_ast_for_text [pass(text: text, b1: 8, b2: 8)], text
29
+ assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, b2: :Ruth)], text
28
30
  text = 'Offb.'
29
- assert_parsed_ast_for_text [pass(text: text, b1: 66, b2: 66)], text
31
+ assert_parsed_ast_for_text [pass(text: text, b1: :Rev, b2: :Rev)], text
30
32
  end
31
33
 
32
34
  def test_ambiguous_book
@@ -38,115 +40,115 @@ class TestParser < Test::Unit::TestCase
38
40
 
39
41
  def test_book_and_chapter
40
42
  text = 'Ruth 2'
41
- assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, b2: 8, c2: 2)], text
43
+ assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, b2: :Ruth, c2: 2)], text
42
44
  end
43
45
 
44
46
  def test_book_chapter_and_verse
45
47
  text = 'Ruth 2,5'
46
- assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5)], text
48
+ assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5)], text
47
49
  end
48
50
 
49
51
  def test_verse_range
50
52
  text = 'Ruth 2,5-11'
51
- assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 11)], text
53
+ assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 11)], text
52
54
  end
53
55
 
54
56
  def test_chapter_verse_range
55
57
  text = 'Ruth 2,5-3,7'
56
- assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 3, v2: 7)], text
58
+ assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 3, v2: 7)], text
57
59
  end
58
60
 
59
61
  def test_chapter_range
60
62
  text = 'Ruth 2-3'
61
- assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, b2: 8, c2: 3)], text
63
+ assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, b2: :Ruth, c2: 3)], text
62
64
  end
63
65
 
64
66
  def test_book_range
65
67
  text = '1. Mose - Offenbarung'
66
- assert_parsed_ast_for_text [pass(text: text, b1: 1, b2: 66)], text
68
+ assert_parsed_ast_for_text [pass(text: text, b1: :Gen, b2: :Rev)], text
67
69
  end
68
70
 
69
71
  def test_book_chapter_range
70
72
  text = '1. Mose 1 - Offenbarung 22'
71
- assert_parsed_ast_for_text [pass(text: text, b1: 1, c1: 1, b2: 66, c2: 22)], text
73
+ assert_parsed_ast_for_text [pass(text: text, b1: :Gen, c1: 1, b2: :Rev, c2: 22)], text
72
74
  end
73
75
 
74
76
  def test_book_chapter_verse_range
75
77
  text = '1. Mose 1,1-Offenbarung 22,21'
76
- assert_parsed_ast_for_text [pass(text: text, b1: 1, c1: 1, v1: 1, b2: 66, c2: 22, v2: 21)], text
78
+ assert_parsed_ast_for_text [pass(text: text, b1: :Gen, c1: 1, v1: 1, b2: :Rev, c2: 22, v2: 21)], text
77
79
  end
78
80
 
79
81
  def test_one_following_verse
80
82
  text = 'Ruth 2,5f'
81
- assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: :f)], text
83
+ assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: :f)], text
82
84
  end
83
85
 
84
86
  def test_more_following_verse
85
87
  text = 'Ruth 2,5ff'
86
- assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: :ff)], text
88
+ assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: :ff)], text
87
89
  end
88
90
 
89
91
  def test_first_addon
90
92
  text = 'Ruth 2,5a'
91
- assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5, a1: :a)], text
93
+ assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5, a1: :a)], text
92
94
  end
93
95
 
94
96
  def test_second_addon
95
97
  text = 'Ruth 2,5-7a'
96
- assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 7, a2: :a)], text
98
+ assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 7, a2: :a)], text
97
99
  end
98
100
 
99
101
  def test_both_addons
100
102
  text = 'Ruth 2,5b-7a'
101
- assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 7, a1: :b, a2: :a)], text
103
+ assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 7, a1: :b, a2: :a)], text
102
104
  end
103
105
 
104
106
  def test_reset_addons
105
107
  @parser.parse 'Ruth 2,5b-7a'
106
108
  text = 'Ruth'
107
- assert_parsed_ast_for_text [pass(text: text, b1: 8, b2: 8)], text
109
+ assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, b2: :Ruth)], text
108
110
  end
109
111
 
110
112
  def test_book_with_only_one_chapter
111
113
  text = 'Obad 3'
112
- assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 3, b2: 31, c2: 1, v2: 3)], text
114
+ assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 3, b2: :Obad, c2: 1, v2: 3)], text
113
115
  text = 'Obad 1,3'
114
- assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 3, b2: 31, c2: 1, v2: 3)], text
116
+ assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 3, b2: :Obad, c2: 1, v2: 3)], text
115
117
  text = 'Obad 1'
116
- assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 1, b2: 31, c2: 1, v2: 1)], text
118
+ assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 1, b2: :Obad, c2: 1, v2: 1)], text
117
119
  text = 'Obad 1,1'
118
- assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 1, b2: 31, c2: 1, v2: 1)], text
120
+ assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 1, b2: :Obad, c2: 1, v2: 1)], text
119
121
  end
120
122
 
121
123
  def test_book_with_only_one_chapter_range
122
124
  text = 'Obad 3-5'
123
- assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 3, b2: 31, c2: 1, v2: 5)], text
125
+ assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 3, b2: :Obad, c2: 1, v2: 5)], text
124
126
  text = 'Obad 1,3-5'
125
- assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 3, b2: 31, c2: 1, v2: 5)], text
127
+ assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 3, b2: :Obad, c2: 1, v2: 5)], text
126
128
  text = 'Obad 1-4'
127
- assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 1, b2: 31, c2: 1, v2: 4)], text
129
+ assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 1, b2: :Obad, c2: 1, v2: 4)], text
128
130
  text = 'Obad 1,1-4'
129
- assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 1, b2: 31, c2: 1, v2: 4)], text
131
+ assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 1, b2: :Obad, c2: 1, v2: 4)], text
130
132
  end
131
133
 
132
134
  def test_book_with_only_one_chapter_at_begin_of_range
133
135
  text = 'Obad - Jona'
134
- assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, b2: 32)], text
136
+ assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, b2: :Jonah)], text
135
137
  text = 'Obad 3 - Jona 2,4'
136
- assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 3, b2: 32, c2: 2, v2: 4)], text
138
+ assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 3, b2: :Jonah, c2: 2, v2: 4)], text
137
139
  text = 'Obad 1,3 - Jona 2,4'
138
- assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 3, b2: 32, c2: 2, v2: 4)], text
140
+ assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 3, b2: :Jonah, c2: 2, v2: 4)], text
139
141
  end
140
142
 
141
143
  def test_book_with_only_one_chapter_at_end_of_range
142
144
  text = 'Amos 2,4 - Obad 3'
143
- assert_parsed_ast_for_text [pass(text: text, b1: 30, c1: 2, v1: 4, b2: 31, c2: 1, v2: 3)], text
145
+ assert_parsed_ast_for_text [pass(text: text, b1: :Amos, c1: 2, v1: 4, b2: :Obad, c2: 1, v2: 3)], text
144
146
  text = 'Amos 2,4 - Obad 1,3'
145
- assert_parsed_ast_for_text [pass(text: text, b1: 30, c1: 2, v1: 4, b2: 31, c2: 1, v2: 3)], text
147
+ assert_parsed_ast_for_text [pass(text: text, b1: :Amos, c1: 2, v1: 4, b2: :Obad, c2: 1, v2: 3)], text
146
148
  text = 'Amos 2,4 - Obad 1'
147
- assert_parsed_ast_for_text [pass(text: text, b1: 30, c1: 2, v1: 4, b2: 31, c2: 1, v2: 1)], text
149
+ assert_parsed_ast_for_text [pass(text: text, b1: :Amos, c1: 2, v1: 4, b2: :Obad, c2: 1, v2: 1)], text
148
150
  text = 'Amos 2,4 - Obad 1,1'
149
- assert_parsed_ast_for_text [pass(text: text, b1: 30, c1: 2, v1: 4, b2: 31, c2: 1, v2: 1)], text
151
+ assert_parsed_ast_for_text [pass(text: text, b1: :Amos, c1: 2, v1: 4, b2: :Obad, c2: 1, v2: 1)], text
150
152
  end
151
153
 
152
154
  ######################################################################
@@ -156,49 +158,49 @@ class TestParser < Test::Unit::TestCase
156
158
  def test_two_books
157
159
  text = 'Ruth; Markus'
158
160
  t1, t2 = text.split(semi)
159
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, b2: 8), semi, pass(text: t2, b1: 41, b2: 41)], text
161
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, b2: :Ruth), semi, pass(text: t2, b1: :Mark, b2: :Mark)], text
160
162
  end
161
163
 
162
164
  def test_two_complete_refs
163
165
  text = 'Ruth 2,1; Markus 4,8'
164
166
  t1, t2 = text.split(semi)
165
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 1), semi, pass(text: t2, b1: 41, c1: 4, v1: 8, b2: 41, c2: 4, v2: 8)], text
167
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 1), semi, pass(text: t2, b1: :Mark, c1: 4, v1: 8, b2: :Mark, c2: 4, v2: 8)], text
166
168
  end
167
169
 
168
170
  def test_two_refs_same_book
169
171
  text = 'Ruth 2,1; 5,4'
170
172
  t1, t2 = text.split(semi)
171
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 1), semi, pass(text: t2, b1: 8, c1: 5, v1: 4, b2: 8, c2: 5, v2: 4)], text
173
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 1), semi, pass(text: t2, b1: :Ruth, c1: 5, v1: 4, b2: :Ruth, c2: 5, v2: 4)], text
172
174
  end
173
175
 
174
176
  def test_two_chapters_same_book
175
177
  text = 'Ruth 2; 5'
176
178
  t1, t2 = text.split(semi)
177
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, b2: 8, c2: 2), semi, pass(text: t2, b1: 8, c1: 5, b2: 8, c2: 5)], text
179
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, b2: :Ruth, c2: 2), semi, pass(text: t2, b1: :Ruth, c1: 5, b2: :Ruth, c2: 5)], text
178
180
  end
179
181
 
180
182
  def test_two_chapters_different_book
181
183
  text = 'Ruth 2; Markus 4'
182
184
  t1, t2 = text.split(semi)
183
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, b2: 8, c2: 2), semi, pass(text: t2, b1: 41, c1: 4, b2: 41, c2: 4)], text
185
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, b2: :Ruth, c2: 2), semi, pass(text: t2, b1: :Mark, c1: 4, b2: :Mark, c2: 4)], text
184
186
  end
185
187
 
186
188
  def test_two_verses
187
189
  text = 'Ruth 2,5.11'
188
190
  t1, t2 = text.split(dot)
189
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5), dot, pass(text: t2, b1: 8, c1: 2, v1: 11, b2: 8, c2: 2, v2: 11)], text
191
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5), dot, pass(text: t2, b1: :Ruth, c1: 2, v1: 11, b2: :Ruth, c2: 2, v2: 11)], text
190
192
  end
191
193
 
192
194
  def test_partial_passage_after_full_passage
193
195
  text = 'Ruth 2,5; 4'
194
196
  t1, t2 = text.split(semi)
195
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5), semi, pass(text: t2, b1: 8, c1: 4, b2: 8, c2: 4)], text
197
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5), semi, pass(text: t2, b1: :Ruth, c1: 4, b2: :Ruth, c2: 4)], text
196
198
  text = 'Ruth 2,5; Markus'
197
199
  t1, t2 = text.split(semi)
198
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5), semi, pass(text: t2, b1: 41, b2: 41)], text
200
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5), semi, pass(text: t2, b1: :Mark, b2: :Mark)], text
199
201
  text = 'Ruth 2,5; Markus 4'
200
202
  t1, t2 = text.split(semi)
201
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5), semi, pass(text: t2, b1: 41, c1: 4, b2: 41, c2: 4)], text
203
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5), semi, pass(text: t2, b1: :Mark, c1: 4, b2: :Mark, c2: 4)], text
202
204
  end
203
205
 
204
206
  ######################################################################
@@ -208,61 +210,61 @@ class TestParser < Test::Unit::TestCase
208
210
  def test_verse_range_and_separated_verse
209
211
  text = 'Ruth 2,1-3.11'
210
212
  t1, t2 = text.split(dot)
211
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 3), dot, pass(text: t2, b1: 8, c1: 2, v1: 11, b2: 8, c2: 2, v2: 11)], text
213
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 3), dot, pass(text: t2, b1: :Ruth, c1: 2, v1: 11, b2: :Ruth, c2: 2, v2: 11)], text
212
214
  end
213
215
 
214
216
  def test_separate_verse_and_verse_range
215
217
  text = 'Ruth 2,1.3-11'
216
218
  t1, t2 = text.split(dot)
217
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 1), dot, pass(text: t2, b1: 8, c1: 2, v1: 3, b2: 8, c2: 2, v2: 11)], text
219
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 1), dot, pass(text: t2, b1: :Ruth, c1: 2, v1: 3, b2: :Ruth, c2: 2, v2: 11)], text
218
220
  end
219
221
 
220
222
  def test_two_verse_ranges
221
223
  text = 'Ruth 2,1-3.7-11'
222
224
  t1, t2 = text.split(dot)
223
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 3), dot, pass(text: t2, b1: 8, c1: 2, v1: 7, b2: 8, c2: 2, v2: 11)], text
225
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 3), dot, pass(text: t2, b1: :Ruth, c1: 2, v1: 7, b2: :Ruth, c2: 2, v2: 11)], text
224
226
  end
225
227
 
226
228
  def test_two_verse_range_different_books
227
229
  text = 'Ruth 2,1-11; Markus 4,3-7'
228
230
  t1, t2 = text.split(semi)
229
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 11), semi, pass(text: t2, b1: 41, c1: 4, v1: 3, b2: 41, c2: 4, v2: 7)], text
231
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 11), semi, pass(text: t2, b1: :Mark, c1: 4, v1: 3, b2: :Mark, c2: 4, v2: 7)], text
230
232
  end
231
233
 
232
234
  def test_two_verse_range_different_chapters
233
235
  text = 'Ruth 2,1-11; 3,10-19'
234
236
  t1, t2 = text.split(semi)
235
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 11), semi, pass(text: t2, b1: 8, c1: 3, v1: 10, b2: 8, c2: 3, v2: 19)], text
237
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 11), semi, pass(text: t2, b1: :Ruth, c1: 3, v1: 10, b2: :Ruth, c2: 3, v2: 19)], text
236
238
  end
237
239
 
238
240
  def test_book_range_and_following_book
239
241
  text = 'Ruth-Markus; Johannes'
240
242
  t1, t2 = text.split(semi)
241
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, b2: 41), semi, pass(text: t2, b1: 43, b2: 43)], text
243
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, b2: :Mark), semi, pass(text: t2, b1: :John, b2: :John)], text
242
244
  end
243
245
 
244
246
  def test_chapter_range_and_following_book
245
247
  text = 'Ruth 1-2; Joh 4'
246
248
  t1, t2 = text.split(semi)
247
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 1, b2: 8, c2: 2), semi, pass(text: t2, b1: 43, c1: 4, b2: 43, c2: 4)], text
249
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 1, b2: :Ruth, c2: 2), semi, pass(text: t2, b1: :John, c1: 4, b2: :John, c2: 4)], text
248
250
  end
249
251
 
250
252
  def test_chapter_range_and_following_chapter
251
253
  text = 'Ruth 1-2; 4'
252
254
  t1, t2 = text.split(semi)
253
- assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 1, b2: 8, c2: 2), semi, pass(text: t2, b1: 8, c1: 4, b2: 8, c2: 4)], text
255
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 1, b2: :Ruth, c2: 2), semi, pass(text: t2, b1: :Ruth, c1: 4, b2: :Ruth, c2: 4)], text
254
256
  end
255
257
 
256
258
  def test_book_only_after_full_passage
257
259
  text = 'Matt 3,4; Mar; Joh 3,16'
258
260
  t1, t2, t3 = text.split(semi)
259
- assert_parsed_ast_for_text [pass(text: t1, b1: 40, c1: 3, v1: 4, b2: 40, c2: 3, v2: 4), semi, pass(text: t2, b1: 41, b2: 41), semi, pass(text: t3, b1: 43, c1: 3, v1: 16, b2: 43, c2: 3, v2: 16)], text
261
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Matt, c1: 3, v1: 4, b2: :Matt, c2: 3, v2: 4), semi, pass(text: t2, b1: :Mark, b2: :Mark), semi, pass(text: t3, b1: :John, c1: 3, v1: 16, b2: :John, c2: 3, v2: 16)], text
260
262
  end
261
263
 
262
264
  def test_chapter_only_after_full_passage
263
265
  text = 'Matt 3,4; 8; Joh 3,16'
264
266
  t1, t2, t3 = text.split(semi)
265
- assert_parsed_ast_for_text [pass(text: t1, b1: 40, c1: 3, v1: 4, b2: 40, c2: 3, v2: 4), semi, pass(text: t2, b1: 40, c1: 8, b2: 40, c2: 8), semi, pass(text: t3, b1: 43, c1: 3, v1: 16, b2: 43, c2: 3, v2: 16)], text
267
+ assert_parsed_ast_for_text [pass(text: t1, b1: :Matt, c1: 3, v1: 4, b2: :Matt, c2: 3, v2: 4), semi, pass(text: t2, b1: :Matt, c1: 8, b2: :Matt, c2: 8), semi, pass(text: t3, b1: :John, c1: 3, v1: 16, b2: :John, c2: 3, v2: 16)], text
266
268
  end
267
269
 
268
270
  ######################################################################
@@ -273,13 +275,13 @@ class TestParser < Test::Unit::TestCase
273
275
  text = 'Ruth 2,1-11.15; 3,7.9-12; Markus 4; 5,3.18-21'
274
276
  t1, t2, t3, t4, t5, t6, t7 = text.split(/; |\./)
275
277
  ast = [
276
- pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 11), dot,
277
- pass(text: t2, b1: 8, c1: 2, v1: 15, b2: 8, c2: 2, v2: 15), semi,
278
- pass(text: t3, b1: 8, c1: 3, v1: 7, b2: 8, c2: 3, v2: 7), dot,
279
- pass(text: t4, b1: 8, c1: 3, v1: 9, b2: 8, c2: 3, v2: 12), semi,
280
- pass(text: t5, b1: 41, c1: 4, b2: 41, c2: 4), semi,
281
- pass(text: t6, b1: 41, c1: 5, v1: 3, b2: 41, c2: 5, v2: 3), dot,
282
- pass(text: t7, b1: 41, c1: 5, v1: 18, b2: 41, c2: 5, v2: 21)
278
+ pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 11), dot,
279
+ pass(text: t2, b1: :Ruth, c1: 2, v1: 15, b2: :Ruth, c2: 2, v2: 15), semi,
280
+ pass(text: t3, b1: :Ruth, c1: 3, v1: 7, b2: :Ruth, c2: 3, v2: 7), dot,
281
+ pass(text: t4, b1: :Ruth, c1: 3, v1: 9, b2: :Ruth, c2: 3, v2: 12), semi,
282
+ pass(text: t5, b1: :Mark, c1: 4, b2: :Mark, c2: 4), semi,
283
+ pass(text: t6, b1: :Mark, c1: 5, v1: 3, b2: :Mark, c2: 5, v2: 3), dot,
284
+ pass(text: t7, b1: :Mark, c1: 5, v1: 18, b2: :Mark, c2: 5, v2: 21)
283
285
  ]
284
286
  assert_parsed_ast_for_text ast, text
285
287
  end
@@ -318,17 +320,17 @@ class TestParser < Test::Unit::TestCase
318
320
  # but in German the abbrev "Phil" is generally used for "Philipper",
319
321
  # so the parser should be able to support such behaviour.
320
322
  text = 'Phil 4,4'
321
- assert_parsed_ast_for_text [pass(text: text, b1: 50, c1: 4, v1: 4, b2: 50, c2: 4, v2: 4)], text
323
+ assert_parsed_ast_for_text [pass(text: text, b1: :Phil, c1: 4, v1: 4, b2: :Phil, c2: 4, v2: 4)], text
322
324
  # It must also work with a dot
323
325
  text = 'Phil. 4,4'
324
- assert_parsed_ast_for_text [pass(text: text, b1: 50, c1: 4, v1: 4, b2: 50, c2: 4, v2: 4)], text
326
+ assert_parsed_ast_for_text [pass(text: text, b1: :Phil, c1: 4, v1: 4, b2: :Phil, c2: 4, v2: 4)], text
325
327
  end
326
328
 
327
329
  def test_book_abbrev_which_seems_to_be_ambiguous
328
330
  # Abbreviation 'Psm' matches 'Psalm' and 'Psalmen' which is the same
329
331
  # book so it is not an ambiguous error.
330
332
  text = 'Psm 23,6'
331
- assert_parsed_ast_for_text [pass(text: text, b1: 19, c1: 23, v1: 6, b2: 19, c2: 23, v2: 6)], text
333
+ assert_parsed_ast_for_text [pass(text: text, b1: :Ps, c1: 23, v1: 6, b2: :Ps, c2: 23, v2: 6)], text
332
334
  end
333
335
 
334
336
  private