numerals 0.0.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +149 -5
  3. data/lib/numerals/conversions/bigdecimal.rb +209 -9
  4. data/lib/numerals/conversions/context_conversion.rb +40 -0
  5. data/lib/numerals/conversions/float.rb +106 -71
  6. data/lib/numerals/conversions/flt.rb +115 -44
  7. data/lib/numerals/conversions/integer.rb +32 -3
  8. data/lib/numerals/conversions/rational.rb +27 -3
  9. data/lib/numerals/conversions.rb +74 -33
  10. data/lib/numerals/digits.rb +8 -5
  11. data/lib/numerals/format/base_scaler.rb +160 -0
  12. data/lib/numerals/format/exp_setter.rb +218 -0
  13. data/lib/numerals/format/format.rb +257 -0
  14. data/lib/numerals/format/input.rb +140 -0
  15. data/lib/numerals/format/mode.rb +157 -0
  16. data/lib/numerals/format/notation.rb +51 -0
  17. data/lib/numerals/format/notations/html.rb +53 -0
  18. data/lib/numerals/format/notations/latex.rb +48 -0
  19. data/lib/numerals/format/notations/text.rb +141 -0
  20. data/lib/numerals/format/output.rb +167 -0
  21. data/lib/numerals/format/symbols.rb +565 -0
  22. data/lib/numerals/format/text_parts.rb +35 -0
  23. data/lib/numerals/format.rb +25 -0
  24. data/lib/numerals/formatting_aspect.rb +36 -0
  25. data/lib/numerals/numeral.rb +34 -21
  26. data/lib/numerals/repeat_detector.rb +99 -0
  27. data/lib/numerals/rounding.rb +340 -181
  28. data/lib/numerals/version.rb +1 -1
  29. data/lib/numerals.rb +4 -2
  30. data/numerals.gemspec +1 -1
  31. data/test/test_base_scaler.rb +189 -0
  32. data/test/test_big_conversions.rb +105 -0
  33. data/test/test_digits_definition.rb +23 -28
  34. data/test/test_exp_setter.rb +732 -0
  35. data/test/test_float_conversions.rb +48 -30
  36. data/test/test_flt_conversions.rb +476 -80
  37. data/test/test_format.rb +124 -0
  38. data/test/test_format_input.rb +226 -0
  39. data/test/test_format_mode.rb +124 -0
  40. data/test/test_format_output.rb +789 -0
  41. data/test/test_integer_conversions.rb +22 -22
  42. data/test/test_numeral.rb +35 -0
  43. data/test/test_rational_conversions.rb +28 -28
  44. data/test/test_repeat_detector.rb +72 -0
  45. data/test/test_rounding.rb +158 -0
  46. data/test/test_symbols.rb +32 -0
  47. metadata +38 -5
  48. data/lib/numerals/formatting/digits_definition.rb +0 -75
@@ -0,0 +1,732 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),'helper.rb'))
2
+
3
+ require 'numerals'
4
+ include Numerals
5
+
6
+ class TestExpSetter < Test::Unit::TestCase # < Minitest::Test
7
+
8
+ def check_setter(numeral, n=nil)
9
+ adjust = Format::ExpSetter[numeral]
10
+ adjust.integer_part_size = n if n
11
+ "#{adjust.integer_part.join}.#{adjust.fractional_part.join}<#{adjust.repeat_part.join}>E#{adjust.exponent}"
12
+ end
13
+
14
+ def test_approx_no_exp
15
+ digits_1_6 = (1..6).to_a
16
+
17
+ assert_equal ".00000000000000000000000000000000000000000000000000123456<>E0",
18
+ check_setter(Numeral[digits_1_6, point: -50, normalize: :approximate], nil)
19
+ assert_equal ".0000000000000000000000000123456<>E0",
20
+ check_setter(Numeral[digits_1_6, point: -25, normalize: :approximate], nil)
21
+ assert_equal ".000000123456<>E0",
22
+ check_setter(Numeral[digits_1_6, point: -6, normalize: :approximate], nil)
23
+ assert_equal ".00000123456<>E0",
24
+ check_setter(Numeral[digits_1_6, point: -5, normalize: :approximate], nil)
25
+ assert_equal ".0000123456<>E0",
26
+ check_setter(Numeral[digits_1_6, point: -4, normalize: :approximate], nil)
27
+ assert_equal ".000123456<>E0",
28
+ check_setter(Numeral[digits_1_6, point: -3, normalize: :approximate], nil)
29
+ assert_equal ".00123456<>E0",
30
+ check_setter(Numeral[digits_1_6, point: -2, normalize: :approximate], nil)
31
+ assert_equal ".0123456<>E0",
32
+ check_setter(Numeral[digits_1_6, point: -1, normalize: :approximate], nil)
33
+ assert_equal ".123456<>E0",
34
+ check_setter(Numeral[digits_1_6, point: 0, normalize: :approximate], nil)
35
+ assert_equal "1.23456<>E0",
36
+ check_setter(Numeral[digits_1_6, point: 1, normalize: :approximate], nil)
37
+ assert_equal "12.3456<>E0",
38
+ check_setter(Numeral[digits_1_6, point: 2, normalize: :approximate], nil)
39
+ assert_equal "123.456<>E0",
40
+ check_setter(Numeral[digits_1_6, point: 3, normalize: :approximate], nil)
41
+ assert_equal "1234.56<>E0",
42
+ check_setter(Numeral[digits_1_6, point: 4, normalize: :approximate], nil)
43
+ assert_equal "12345.6<>E0",
44
+ check_setter(Numeral[digits_1_6, point: 5, normalize: :approximate], nil)
45
+ assert_equal "123456.<>E0",
46
+ check_setter(Numeral[digits_1_6, point: 6, normalize: :approximate], nil)
47
+ assert_equal "1234560.<>E0",
48
+ check_setter(Numeral[digits_1_6, point: 7, normalize: :approximate], nil)
49
+ assert_equal "12345600.<>E0",
50
+ check_setter(Numeral[digits_1_6, point: 8, normalize: :approximate], nil)
51
+ assert_equal "123456000.<>E0",
52
+ check_setter(Numeral[digits_1_6, point: 9, normalize: :approximate], nil)
53
+ assert_equal "1234560000.<>E0",
54
+ check_setter(Numeral[digits_1_6, point: 10, normalize: :approximate], nil)
55
+ assert_equal "12345600000.<>E0",
56
+ check_setter(Numeral[digits_1_6, point: 11, normalize: :approximate], nil)
57
+ assert_equal "1234560000000000000000000.<>E0",
58
+ check_setter(Numeral[digits_1_6, point: 25, normalize: :approximate], nil)
59
+ assert_equal "12345600000000000000000000000000000000000000000000.<>E0",
60
+ check_setter(Numeral[digits_1_6, point: 50, normalize: :approximate], nil)
61
+ end
62
+
63
+ def test_approx_exp_1
64
+ digits_1_6 = (1..6).to_a
65
+
66
+ assert_equal "1.23456<>E-51",
67
+ check_setter(Numeral[digits_1_6, point: -50, normalize: :approximate], 1)
68
+ assert_equal "1.23456<>E-26",
69
+ check_setter(Numeral[digits_1_6, point: -25, normalize: :approximate], 1)
70
+ assert_equal "1.23456<>E-7",
71
+ check_setter(Numeral[digits_1_6, point: -6, normalize: :approximate], 1)
72
+ assert_equal "1.23456<>E-6",
73
+ check_setter(Numeral[digits_1_6, point: -5, normalize: :approximate], 1)
74
+ assert_equal "1.23456<>E-5",
75
+ check_setter(Numeral[digits_1_6, point: -4, normalize: :approximate], 1)
76
+ assert_equal "1.23456<>E-4",
77
+ check_setter(Numeral[digits_1_6, point: -3, normalize: :approximate], 1)
78
+ assert_equal "1.23456<>E-3",
79
+ check_setter(Numeral[digits_1_6, point: -2, normalize: :approximate], 1)
80
+ assert_equal "1.23456<>E-2",
81
+ check_setter(Numeral[digits_1_6, point: -1, normalize: :approximate], 1)
82
+ assert_equal "1.23456<>E-1",
83
+ check_setter(Numeral[digits_1_6, point: 0, normalize: :approximate], 1)
84
+ assert_equal "1.23456<>E0",
85
+ check_setter(Numeral[digits_1_6, point: 1, normalize: :approximate], 1)
86
+ assert_equal "1.23456<>E1",
87
+ check_setter(Numeral[digits_1_6, point: 2, normalize: :approximate], 1)
88
+ assert_equal "1.23456<>E2",
89
+ check_setter(Numeral[digits_1_6, point: 3, normalize: :approximate], 1)
90
+ assert_equal "1.23456<>E3",
91
+ check_setter(Numeral[digits_1_6, point: 4, normalize: :approximate], 1)
92
+ assert_equal "1.23456<>E4",
93
+ check_setter(Numeral[digits_1_6, point: 5, normalize: :approximate], 1)
94
+ assert_equal "1.23456<>E5",
95
+ check_setter(Numeral[digits_1_6, point: 6, normalize: :approximate], 1)
96
+ assert_equal "1.23456<>E6",
97
+ check_setter(Numeral[digits_1_6, point: 7, normalize: :approximate], 1)
98
+ assert_equal "1.23456<>E7",
99
+ check_setter(Numeral[digits_1_6, point: 8, normalize: :approximate], 1)
100
+ assert_equal "1.23456<>E8",
101
+ check_setter(Numeral[digits_1_6, point: 9, normalize: :approximate], 1)
102
+ assert_equal "1.23456<>E9",
103
+ check_setter(Numeral[digits_1_6, point: 10, normalize: :approximate], 1)
104
+ assert_equal "1.23456<>E10",
105
+ check_setter(Numeral[digits_1_6, point: 11, normalize: :approximate], 1)
106
+ assert_equal "1.23456<>E24",
107
+ check_setter(Numeral[digits_1_6, point: 25, normalize: :approximate], 1)
108
+ assert_equal "1.23456<>E49",
109
+ check_setter(Numeral[digits_1_6, point: 50, normalize: :approximate], 1)
110
+ end
111
+
112
+ def test_approx_exp_2
113
+ digits_1_6 = (1..6).to_a
114
+
115
+ assert_equal "12.3456<>E-52",
116
+ check_setter(Numeral[digits_1_6, point: -50, normalize: :approximate], 2)
117
+ assert_equal "12.3456<>E-27",
118
+ check_setter(Numeral[digits_1_6, point: -25, normalize: :approximate], 2)
119
+ assert_equal "12.3456<>E-8",
120
+ check_setter(Numeral[digits_1_6, point: -6, normalize: :approximate], 2)
121
+ assert_equal "12.3456<>E-7",
122
+ check_setter(Numeral[digits_1_6, point: -5, normalize: :approximate], 2)
123
+ assert_equal "12.3456<>E-6",
124
+ check_setter(Numeral[digits_1_6, point: -4, normalize: :approximate], 2)
125
+ assert_equal "12.3456<>E-5",
126
+ check_setter(Numeral[digits_1_6, point: -3, normalize: :approximate], 2)
127
+ assert_equal "12.3456<>E-4",
128
+ check_setter(Numeral[digits_1_6, point: -2, normalize: :approximate], 2)
129
+ assert_equal "12.3456<>E-3",
130
+ check_setter(Numeral[digits_1_6, point: -1, normalize: :approximate], 2)
131
+ assert_equal "12.3456<>E-2",
132
+ check_setter(Numeral[digits_1_6, point: 0, normalize: :approximate], 2)
133
+ assert_equal "12.3456<>E-1",
134
+ check_setter(Numeral[digits_1_6, point: 1, normalize: :approximate], 2)
135
+ assert_equal "12.3456<>E0",
136
+ check_setter(Numeral[digits_1_6, point: 2, normalize: :approximate], 2)
137
+ assert_equal "12.3456<>E1",
138
+ check_setter(Numeral[digits_1_6, point: 3, normalize: :approximate], 2)
139
+ assert_equal "12.3456<>E2",
140
+ check_setter(Numeral[digits_1_6, point: 4, normalize: :approximate], 2)
141
+ assert_equal "12.3456<>E3",
142
+ check_setter(Numeral[digits_1_6, point: 5, normalize: :approximate], 2)
143
+ assert_equal "12.3456<>E4",
144
+ check_setter(Numeral[digits_1_6, point: 6, normalize: :approximate], 2)
145
+ assert_equal "12.3456<>E5",
146
+ check_setter(Numeral[digits_1_6, point: 7, normalize: :approximate], 2)
147
+ assert_equal "12.3456<>E6",
148
+ check_setter(Numeral[digits_1_6, point: 8, normalize: :approximate], 2)
149
+ assert_equal "12.3456<>E7",
150
+ check_setter(Numeral[digits_1_6, point: 9, normalize: :approximate], 2)
151
+ assert_equal "12.3456<>E8",
152
+ check_setter(Numeral[digits_1_6, point: 10, normalize: :approximate], 2)
153
+ assert_equal "12.3456<>E9",
154
+ check_setter(Numeral[digits_1_6, point: 11, normalize: :approximate], 2)
155
+ assert_equal "12.3456<>E23",
156
+ check_setter(Numeral[digits_1_6, point: 25, normalize: :approximate], 2)
157
+ assert_equal "12.3456<>E48",
158
+ check_setter(Numeral[digits_1_6, point: 50, normalize: :approximate], 2)
159
+ end
160
+
161
+ def test_approx_exp_3
162
+ digits_1_6 = (1..6).to_a
163
+
164
+ assert_equal "123.456<>E-53",
165
+ check_setter(Numeral[digits_1_6, point: -50, normalize: :approximate], 3)
166
+ assert_equal "123.456<>E-28",
167
+ check_setter(Numeral[digits_1_6, point: -25, normalize: :approximate], 3)
168
+ assert_equal "123.456<>E-9",
169
+ check_setter(Numeral[digits_1_6, point: -6, normalize: :approximate], 3)
170
+ assert_equal "123.456<>E-8",
171
+ check_setter(Numeral[digits_1_6, point: -5, normalize: :approximate], 3)
172
+ assert_equal "123.456<>E-7",
173
+ check_setter(Numeral[digits_1_6, point: -4, normalize: :approximate], 3)
174
+ assert_equal "123.456<>E-6",
175
+ check_setter(Numeral[digits_1_6, point: -3, normalize: :approximate], 3)
176
+ assert_equal "123.456<>E-5",
177
+ check_setter(Numeral[digits_1_6, point: -2, normalize: :approximate], 3)
178
+ assert_equal "123.456<>E-4",
179
+ check_setter(Numeral[digits_1_6, point: -1, normalize: :approximate], 3)
180
+ assert_equal "123.456<>E-3",
181
+ check_setter(Numeral[digits_1_6, point: 0, normalize: :approximate], 3)
182
+ assert_equal "123.456<>E-2",
183
+ check_setter(Numeral[digits_1_6, point: 1, normalize: :approximate], 3)
184
+ assert_equal "123.456<>E-1",
185
+ check_setter(Numeral[digits_1_6, point: 2, normalize: :approximate], 3)
186
+ assert_equal "123.456<>E0",
187
+ check_setter(Numeral[digits_1_6, point: 3, normalize: :approximate], 3)
188
+ assert_equal "123.456<>E1",
189
+ check_setter(Numeral[digits_1_6, point: 4, normalize: :approximate], 3)
190
+ assert_equal "123.456<>E2",
191
+ check_setter(Numeral[digits_1_6, point: 5, normalize: :approximate], 3)
192
+ assert_equal "123.456<>E3",
193
+ check_setter(Numeral[digits_1_6, point: 6, normalize: :approximate], 3)
194
+ assert_equal "123.456<>E4",
195
+ check_setter(Numeral[digits_1_6, point: 7, normalize: :approximate], 3)
196
+ assert_equal "123.456<>E5",
197
+ check_setter(Numeral[digits_1_6, point: 8, normalize: :approximate], 3)
198
+ assert_equal "123.456<>E6",
199
+ check_setter(Numeral[digits_1_6, point: 9, normalize: :approximate], 3)
200
+ assert_equal "123.456<>E7",
201
+ check_setter(Numeral[digits_1_6, point: 10, normalize: :approximate], 3)
202
+ assert_equal "123.456<>E8",
203
+ check_setter(Numeral[digits_1_6, point: 11, normalize: :approximate], 3)
204
+ assert_equal "123.456<>E22",
205
+ check_setter(Numeral[digits_1_6, point: 25, normalize: :approximate], 3)
206
+ assert_equal "123.456<>E47",
207
+ check_setter(Numeral[digits_1_6, point: 50, normalize: :approximate], 3)
208
+ end
209
+
210
+ def test_approx_exp_m1
211
+ digits_1_6 = (1..6).to_a
212
+
213
+ assert_equal ".0123456<>E-49",
214
+ check_setter(Numeral[digits_1_6, point: -50, normalize: :approximate], -1)
215
+ assert_equal ".0123456<>E-24",
216
+ check_setter(Numeral[digits_1_6, point: -25, normalize: :approximate], -1)
217
+ assert_equal ".0123456<>E-5",
218
+ check_setter(Numeral[digits_1_6, point: -6, normalize: :approximate], -1)
219
+ assert_equal ".0123456<>E-4",
220
+ check_setter(Numeral[digits_1_6, point: -5, normalize: :approximate], -1)
221
+ assert_equal ".0123456<>E-3",
222
+ check_setter(Numeral[digits_1_6, point: -4, normalize: :approximate], -1)
223
+ assert_equal ".0123456<>E-2",
224
+ check_setter(Numeral[digits_1_6, point: -3, normalize: :approximate], -1)
225
+ assert_equal ".0123456<>E-1",
226
+ check_setter(Numeral[digits_1_6, point: -2, normalize: :approximate], -1)
227
+ assert_equal ".0123456<>E0",
228
+ check_setter(Numeral[digits_1_6, point: -1, normalize: :approximate], -1)
229
+ assert_equal ".0123456<>E1",
230
+ check_setter(Numeral[digits_1_6, point: 0, normalize: :approximate], -1)
231
+ assert_equal ".0123456<>E2",
232
+ check_setter(Numeral[digits_1_6, point: 1, normalize: :approximate], -1)
233
+ assert_equal ".0123456<>E3",
234
+ check_setter(Numeral[digits_1_6, point: 2, normalize: :approximate], -1)
235
+ assert_equal ".0123456<>E4",
236
+ check_setter(Numeral[digits_1_6, point: 3, normalize: :approximate], -1)
237
+ assert_equal ".0123456<>E5",
238
+ check_setter(Numeral[digits_1_6, point: 4, normalize: :approximate], -1)
239
+ assert_equal ".0123456<>E6",
240
+ check_setter(Numeral[digits_1_6, point: 5, normalize: :approximate], -1)
241
+ assert_equal ".0123456<>E7",
242
+ check_setter(Numeral[digits_1_6, point: 6, normalize: :approximate], -1)
243
+ assert_equal ".0123456<>E8",
244
+ check_setter(Numeral[digits_1_6, point: 7, normalize: :approximate], -1)
245
+ assert_equal ".0123456<>E9",
246
+ check_setter(Numeral[digits_1_6, point: 8, normalize: :approximate], -1)
247
+ assert_equal ".0123456<>E10",
248
+ check_setter(Numeral[digits_1_6, point: 9, normalize: :approximate], -1)
249
+ assert_equal ".0123456<>E11",
250
+ check_setter(Numeral[digits_1_6, point: 10, normalize: :approximate], -1)
251
+ assert_equal ".0123456<>E12",
252
+ check_setter(Numeral[digits_1_6, point: 11, normalize: :approximate], -1)
253
+ assert_equal ".0123456<>E26",
254
+ check_setter(Numeral[digits_1_6, point: 25, normalize: :approximate], -1)
255
+ assert_equal ".0123456<>E51",
256
+ check_setter(Numeral[digits_1_6, point: 50, normalize: :approximate], -1)
257
+
258
+ end
259
+
260
+ def test_approx_exp_m2
261
+ digits_1_6 = (1..6).to_a
262
+
263
+ assert_equal ".00123456<>E-48",
264
+ check_setter(Numeral[digits_1_6, point: -50, normalize: :approximate], -2)
265
+ assert_equal ".00123456<>E-23",
266
+ check_setter(Numeral[digits_1_6, point: -25, normalize: :approximate], -2)
267
+ assert_equal ".00123456<>E-4",
268
+ check_setter(Numeral[digits_1_6, point: -6, normalize: :approximate], -2)
269
+ assert_equal ".00123456<>E-3",
270
+ check_setter(Numeral[digits_1_6, point: -5, normalize: :approximate], -2)
271
+ assert_equal ".00123456<>E-2",
272
+ check_setter(Numeral[digits_1_6, point: -4, normalize: :approximate], -2)
273
+ assert_equal ".00123456<>E-1",
274
+ check_setter(Numeral[digits_1_6, point: -3, normalize: :approximate], -2)
275
+ assert_equal ".00123456<>E0",
276
+ check_setter(Numeral[digits_1_6, point: -2, normalize: :approximate], -2)
277
+ assert_equal ".00123456<>E1",
278
+ check_setter(Numeral[digits_1_6, point: -1, normalize: :approximate], -2)
279
+ assert_equal ".00123456<>E2",
280
+ check_setter(Numeral[digits_1_6, point: 0, normalize: :approximate], -2)
281
+ assert_equal ".00123456<>E3",
282
+ check_setter(Numeral[digits_1_6, point: 1, normalize: :approximate], -2)
283
+ assert_equal ".00123456<>E4",
284
+ check_setter(Numeral[digits_1_6, point: 2, normalize: :approximate], -2)
285
+ assert_equal ".00123456<>E5",
286
+ check_setter(Numeral[digits_1_6, point: 3, normalize: :approximate], -2)
287
+ assert_equal ".00123456<>E6",
288
+ check_setter(Numeral[digits_1_6, point: 4, normalize: :approximate], -2)
289
+ assert_equal ".00123456<>E7",
290
+ check_setter(Numeral[digits_1_6, point: 5, normalize: :approximate], -2)
291
+ assert_equal ".00123456<>E8",
292
+ check_setter(Numeral[digits_1_6, point: 6, normalize: :approximate], -2)
293
+ assert_equal ".00123456<>E9",
294
+ check_setter(Numeral[digits_1_6, point: 7, normalize: :approximate], -2)
295
+ assert_equal ".00123456<>E10",
296
+ check_setter(Numeral[digits_1_6, point: 8, normalize: :approximate], -2)
297
+ assert_equal ".00123456<>E11",
298
+ check_setter(Numeral[digits_1_6, point: 9, normalize: :approximate], -2)
299
+ assert_equal ".00123456<>E12",
300
+ check_setter(Numeral[digits_1_6, point: 10, normalize: :approximate], -2)
301
+ assert_equal ".00123456<>E13",
302
+ check_setter(Numeral[digits_1_6, point: 11, normalize: :approximate], -2)
303
+ assert_equal ".00123456<>E27",
304
+ check_setter(Numeral[digits_1_6, point: 25, normalize: :approximate], -2)
305
+ assert_equal ".00123456<>E52",
306
+ check_setter(Numeral[digits_1_6, point: 50, normalize: :approximate], -2)
307
+ end
308
+
309
+ def test_repeating_no_exp
310
+ digits_1_9 = (1..9).to_a
311
+
312
+ assert_equal ".00000000000000000000000000000000000000000000000000123456<789>E0",
313
+ check_setter(Numeral[digits_1_9, point: -50, repeat: 6], nil)
314
+ assert_equal ".0000000000000000000000000123456<789>E0",
315
+ check_setter(Numeral[digits_1_9, point: -25, repeat: 6], nil)
316
+ assert_equal ".000000123456<789>E0",
317
+ check_setter(Numeral[digits_1_9, point: -6, repeat: 6], nil)
318
+ assert_equal ".00000123456<789>E0",
319
+ check_setter(Numeral[digits_1_9, point: -5, repeat: 6], nil)
320
+ assert_equal ".0000123456<789>E0",
321
+ check_setter(Numeral[digits_1_9, point: -4, repeat: 6], nil)
322
+ assert_equal ".000123456<789>E0",
323
+ check_setter(Numeral[digits_1_9, point: -3, repeat: 6], nil)
324
+ assert_equal ".00123456<789>E0",
325
+ check_setter(Numeral[digits_1_9, point: -2, repeat: 6], nil)
326
+ assert_equal ".0123456<789>E0",
327
+ check_setter(Numeral[digits_1_9, point: -1, repeat: 6], nil)
328
+ assert_equal ".123456<789>E0",
329
+ check_setter(Numeral[digits_1_9, point: 0, repeat: 6], nil)
330
+ assert_equal "1.23456<789>E0",
331
+ check_setter(Numeral[digits_1_9, point: 1, repeat: 6], nil)
332
+ assert_equal "12.3456<789>E0",
333
+ check_setter(Numeral[digits_1_9, point: 2, repeat: 6], nil)
334
+ assert_equal "123.456<789>E0",
335
+ check_setter(Numeral[digits_1_9, point: 3, repeat: 6], nil)
336
+ assert_equal "1234.56<789>E0",
337
+ check_setter(Numeral[digits_1_9, point: 4, repeat: 6], nil)
338
+ assert_equal "12345.6<789>E0",
339
+ check_setter(Numeral[digits_1_9, point: 5, repeat: 6], nil)
340
+ assert_equal "123456.<789>E0",
341
+ check_setter(Numeral[digits_1_9, point: 6, repeat: 6], nil)
342
+ assert_equal "1234567.<897>E0",
343
+ check_setter(Numeral[digits_1_9, point: 7, repeat: 6], nil)
344
+ assert_equal "12345678.<978>E0",
345
+ check_setter(Numeral[digits_1_9, point: 8, repeat: 6], nil)
346
+ assert_equal "123456789.<789>E0",
347
+ check_setter(Numeral[digits_1_9, point: 9, repeat: 6], nil)
348
+ assert_equal "1234567897.<897>E0",
349
+ check_setter(Numeral[digits_1_9, point: 10, repeat: 6], nil)
350
+ assert_equal "12345678978.<978>E0",
351
+ check_setter(Numeral[digits_1_9, point: 11, repeat: 6], nil)
352
+ assert_equal "123456789789.<789>E0",
353
+ check_setter(Numeral[digits_1_9, point: 12, repeat: 6], nil)
354
+ assert_equal "1234567897897.<897>E0",
355
+ check_setter(Numeral[digits_1_9, point: 13, repeat: 6], nil)
356
+ assert_equal "12345678978978.<978>E0",
357
+ check_setter(Numeral[digits_1_9, point: 14, repeat: 6], nil)
358
+ assert_equal "1234567897897897897897897.<897>E0",
359
+ check_setter(Numeral[digits_1_9, point: 25, repeat: 6], nil)
360
+ assert_equal "12345678978978978978978978978978978978978978978978.<978>E0",
361
+ check_setter(Numeral[digits_1_9, point: 50, repeat: 6], nil)
362
+ end
363
+
364
+
365
+ def test_repeating_no_exp_2
366
+ digits_2_9 = (2..9).to_a
367
+
368
+ assert_equal ".0000000000000000000000000000000000000000000000000023456<789>E0",
369
+ check_setter(Numeral[digits_2_9, point: -50, repeat: 5], nil)
370
+ assert_equal ".000000000000000000000000023456<789>E0",
371
+ check_setter(Numeral[digits_2_9, point: -25, repeat: 5], nil)
372
+ assert_equal ".00000023456<789>E0",
373
+ check_setter(Numeral[digits_2_9, point: -6, repeat: 5], nil)
374
+ assert_equal ".0000023456<789>E0",
375
+ check_setter(Numeral[digits_2_9, point: -5, repeat: 5], nil)
376
+ assert_equal ".000023456<789>E0",
377
+ check_setter(Numeral[digits_2_9, point: -4, repeat: 5], nil)
378
+ assert_equal ".00023456<789>E0",
379
+ check_setter(Numeral[digits_2_9, point: -3, repeat: 5], nil)
380
+ assert_equal ".0023456<789>E0",
381
+ check_setter(Numeral[digits_2_9, point: -2, repeat: 5], nil)
382
+ assert_equal ".023456<789>E0",
383
+ check_setter(Numeral[digits_2_9, point: -1, repeat: 5], nil)
384
+ assert_equal ".23456<789>E0",
385
+ check_setter(Numeral[digits_2_9, point: 0, repeat: 5], nil)
386
+ assert_equal "2.3456<789>E0",
387
+ check_setter(Numeral[digits_2_9, point: 1, repeat: 5], nil)
388
+ assert_equal "23.456<789>E0",
389
+ check_setter(Numeral[digits_2_9, point: 2, repeat: 5], nil)
390
+ assert_equal "234.56<789>E0",
391
+ check_setter(Numeral[digits_2_9, point: 3, repeat: 5], nil)
392
+ assert_equal "2345.6<789>E0",
393
+ check_setter(Numeral[digits_2_9, point: 4, repeat: 5], nil)
394
+ assert_equal "23456.<789>E0",
395
+ check_setter(Numeral[digits_2_9, point: 5, repeat: 5], nil)
396
+ assert_equal "234567.<897>E0",
397
+ check_setter(Numeral[digits_2_9, point: 6, repeat: 5], nil)
398
+ assert_equal "2345678.<978>E0",
399
+ check_setter(Numeral[digits_2_9, point: 7, repeat: 5], nil)
400
+ assert_equal "23456789.<789>E0",
401
+ check_setter(Numeral[digits_2_9, point: 8, repeat: 5], nil)
402
+ assert_equal "234567897.<897>E0",
403
+ check_setter(Numeral[digits_2_9, point: 9, repeat: 5], nil)
404
+ assert_equal "2345678978.<978>E0",
405
+ check_setter(Numeral[digits_2_9, point: 10, repeat: 5], nil)
406
+ assert_equal "23456789789.<789>E0",
407
+ check_setter(Numeral[digits_2_9, point: 11, repeat: 5], nil)
408
+ assert_equal "234567897897.<897>E0",
409
+ check_setter(Numeral[digits_2_9, point: 12, repeat: 5], nil)
410
+ assert_equal "2345678978978.<978>E0",
411
+ check_setter(Numeral[digits_2_9, point: 13, repeat: 5], nil)
412
+ assert_equal "234567897897897897897897.<897>E0",
413
+ check_setter(Numeral[digits_2_9, point: 24, repeat: 5], nil)
414
+ assert_equal "2345678978978978978978978978978978978978978978978.<978>E0",
415
+ check_setter(Numeral[digits_2_9, point: 49, repeat: 5], nil)
416
+ end
417
+
418
+
419
+ def test_repeating_exp_1
420
+ digits_1_9 = (1..9).to_a
421
+
422
+ assert_equal "1.23456<789>E-51",
423
+ check_setter(Numeral[digits_1_9, point: -50, repeat: 6], 1)
424
+ assert_equal "1.23456<789>E-26",
425
+ check_setter(Numeral[digits_1_9, point: -25, repeat: 6], 1)
426
+ assert_equal "1.23456<789>E-7",
427
+ check_setter(Numeral[digits_1_9, point: -6, repeat: 6], 1)
428
+ assert_equal "1.23456<789>E-6",
429
+ check_setter(Numeral[digits_1_9, point: -5, repeat: 6], 1)
430
+ assert_equal "1.23456<789>E-5",
431
+ check_setter(Numeral[digits_1_9, point: -4, repeat: 6], 1)
432
+ assert_equal "1.23456<789>E-4",
433
+ check_setter(Numeral[digits_1_9, point: -3, repeat: 6], 1)
434
+ assert_equal "1.23456<789>E-3",
435
+ check_setter(Numeral[digits_1_9, point: -2, repeat: 6], 1)
436
+ assert_equal "1.23456<789>E-2",
437
+ check_setter(Numeral[digits_1_9, point: -1, repeat: 6], 1)
438
+ assert_equal "1.23456<789>E-1",
439
+ check_setter(Numeral[digits_1_9, point: 0, repeat: 6], 1)
440
+ assert_equal "1.23456<789>E0",
441
+ check_setter(Numeral[digits_1_9, point: 1, repeat: 6], 1)
442
+ assert_equal "1.23456<789>E1",
443
+ check_setter(Numeral[digits_1_9, point: 2, repeat: 6], 1)
444
+ assert_equal "1.23456<789>E2",
445
+ check_setter(Numeral[digits_1_9, point: 3, repeat: 6], 1)
446
+ assert_equal "1.23456<789>E3",
447
+ check_setter(Numeral[digits_1_9, point: 4, repeat: 6], 1)
448
+ assert_equal "1.23456<789>E4",
449
+ check_setter(Numeral[digits_1_9, point: 5, repeat: 6], 1)
450
+ assert_equal "1.23456<789>E5",
451
+ check_setter(Numeral[digits_1_9, point: 6, repeat: 6], 1)
452
+ assert_equal "1.23456<789>E6",
453
+ check_setter(Numeral[digits_1_9, point: 7, repeat: 6], 1)
454
+ assert_equal "1.23456<789>E7",
455
+ check_setter(Numeral[digits_1_9, point: 8, repeat: 6], 1)
456
+ assert_equal "1.23456<789>E8",
457
+ check_setter(Numeral[digits_1_9, point: 9, repeat: 6], 1)
458
+ assert_equal "1.23456<789>E9",
459
+ check_setter(Numeral[digits_1_9, point: 10, repeat: 6], 1)
460
+ assert_equal "1.23456<789>E10",
461
+ check_setter(Numeral[digits_1_9, point: 11, repeat: 6], 1)
462
+ assert_equal "1.23456<789>E11",
463
+ check_setter(Numeral[digits_1_9, point: 12, repeat: 6], 1)
464
+ assert_equal "1.23456<789>E12",
465
+ check_setter(Numeral[digits_1_9, point: 13, repeat: 6], 1)
466
+ assert_equal "1.23456<789>E13",
467
+ check_setter(Numeral[digits_1_9, point: 14, repeat: 6], 1)
468
+ assert_equal "1.23456<789>E24",
469
+ check_setter(Numeral[digits_1_9, point: 25, repeat: 6], 1)
470
+ assert_equal "1.23456<789>E49",
471
+ check_setter(Numeral[digits_1_9, point: 50, repeat: 6], 1)
472
+ end
473
+
474
+ def test_repeating_exp_2
475
+ digits_1_9 = (1..9).to_a
476
+
477
+ assert_equal "12.3456<789>E-52",
478
+ check_setter(Numeral[digits_1_9, point: -50, repeat: 6], 2)
479
+ assert_equal "12.3456<789>E-27",
480
+ check_setter(Numeral[digits_1_9, point: -25, repeat: 6], 2)
481
+ assert_equal "12.3456<789>E-8",
482
+ check_setter(Numeral[digits_1_9, point: -6, repeat: 6], 2)
483
+ assert_equal "12.3456<789>E-7",
484
+ check_setter(Numeral[digits_1_9, point: -5, repeat: 6], 2)
485
+ assert_equal "12.3456<789>E-6",
486
+ check_setter(Numeral[digits_1_9, point: -4, repeat: 6], 2)
487
+ assert_equal "12.3456<789>E-5",
488
+ check_setter(Numeral[digits_1_9, point: -3, repeat: 6], 2)
489
+ assert_equal "12.3456<789>E-4",
490
+ check_setter(Numeral[digits_1_9, point: -2, repeat: 6], 2)
491
+ assert_equal "12.3456<789>E-3",
492
+ check_setter(Numeral[digits_1_9, point: -1, repeat: 6], 2)
493
+ assert_equal "12.3456<789>E-2",
494
+ check_setter(Numeral[digits_1_9, point: 0, repeat: 6], 2)
495
+ assert_equal "12.3456<789>E-1",
496
+ check_setter(Numeral[digits_1_9, point: 1, repeat: 6], 2)
497
+ assert_equal "12.3456<789>E0",
498
+ check_setter(Numeral[digits_1_9, point: 2, repeat: 6], 2)
499
+ assert_equal "12.3456<789>E1",
500
+ check_setter(Numeral[digits_1_9, point: 3, repeat: 6], 2)
501
+ assert_equal "12.3456<789>E2",
502
+ check_setter(Numeral[digits_1_9, point: 4, repeat: 6], 2)
503
+ assert_equal "12.3456<789>E3",
504
+ check_setter(Numeral[digits_1_9, point: 5, repeat: 6], 2)
505
+ assert_equal "12.3456<789>E4",
506
+ check_setter(Numeral[digits_1_9, point: 6, repeat: 6], 2)
507
+ assert_equal "12.3456<789>E5",
508
+ check_setter(Numeral[digits_1_9, point: 7, repeat: 6], 2)
509
+ assert_equal "12.3456<789>E6",
510
+ check_setter(Numeral[digits_1_9, point: 8, repeat: 6], 2)
511
+ assert_equal "12.3456<789>E7",
512
+ check_setter(Numeral[digits_1_9, point: 9, repeat: 6], 2)
513
+ assert_equal "12.3456<789>E8",
514
+ check_setter(Numeral[digits_1_9, point: 10, repeat: 6], 2)
515
+ assert_equal "12.3456<789>E9",
516
+ check_setter(Numeral[digits_1_9, point: 11, repeat: 6], 2)
517
+ assert_equal "12.3456<789>E10",
518
+ check_setter(Numeral[digits_1_9, point: 12, repeat: 6], 2)
519
+ assert_equal "12.3456<789>E11",
520
+ check_setter(Numeral[digits_1_9, point: 13, repeat: 6], 2)
521
+ assert_equal "12.3456<789>E12",
522
+ check_setter(Numeral[digits_1_9, point: 14, repeat: 6], 2)
523
+ assert_equal "12.3456<789>E23",
524
+ check_setter(Numeral[digits_1_9, point: 25, repeat: 6], 2)
525
+ assert_equal "12.3456<789>E48",
526
+ check_setter(Numeral[digits_1_9, point: 50, repeat: 6], 2)
527
+ end
528
+
529
+ def test_repeating_exp_3
530
+ digits_1_9 = (1..9).to_a
531
+
532
+ assert_equal "123.456<789>E-53",
533
+ check_setter(Numeral[digits_1_9, point: -50, repeat: 6], 3)
534
+ assert_equal "123.456<789>E-28",
535
+ check_setter(Numeral[digits_1_9, point: -25, repeat: 6], 3)
536
+ assert_equal "123.456<789>E-9",
537
+ check_setter(Numeral[digits_1_9, point: -6, repeat: 6], 3)
538
+ assert_equal "123.456<789>E-8",
539
+ check_setter(Numeral[digits_1_9, point: -5, repeat: 6], 3)
540
+ assert_equal "123.456<789>E-7",
541
+ check_setter(Numeral[digits_1_9, point: -4, repeat: 6], 3)
542
+ assert_equal "123.456<789>E-6",
543
+ check_setter(Numeral[digits_1_9, point: -3, repeat: 6], 3)
544
+ assert_equal "123.456<789>E-5",
545
+ check_setter(Numeral[digits_1_9, point: -2, repeat: 6], 3)
546
+ assert_equal "123.456<789>E-4",
547
+ check_setter(Numeral[digits_1_9, point: -1, repeat: 6], 3)
548
+ assert_equal "123.456<789>E-3",
549
+ check_setter(Numeral[digits_1_9, point: 0, repeat: 6], 3)
550
+ assert_equal "123.456<789>E-2",
551
+ check_setter(Numeral[digits_1_9, point: 1, repeat: 6], 3)
552
+ assert_equal "123.456<789>E-1",
553
+ check_setter(Numeral[digits_1_9, point: 2, repeat: 6], 3)
554
+ assert_equal "123.456<789>E0",
555
+ check_setter(Numeral[digits_1_9, point: 3, repeat: 6], 3)
556
+ assert_equal "123.456<789>E1",
557
+ check_setter(Numeral[digits_1_9, point: 4, repeat: 6], 3)
558
+ assert_equal "123.456<789>E2",
559
+ check_setter(Numeral[digits_1_9, point: 5, repeat: 6], 3)
560
+ assert_equal "123.456<789>E3",
561
+ check_setter(Numeral[digits_1_9, point: 6, repeat: 6], 3)
562
+ assert_equal "123.456<789>E4",
563
+ check_setter(Numeral[digits_1_9, point: 7, repeat: 6], 3)
564
+ assert_equal "123.456<789>E5",
565
+ check_setter(Numeral[digits_1_9, point: 8, repeat: 6], 3)
566
+ assert_equal "123.456<789>E6",
567
+ check_setter(Numeral[digits_1_9, point: 9, repeat: 6], 3)
568
+ assert_equal "123.456<789>E7",
569
+ check_setter(Numeral[digits_1_9, point: 10, repeat: 6], 3)
570
+ assert_equal "123.456<789>E8",
571
+ check_setter(Numeral[digits_1_9, point: 11, repeat: 6], 3)
572
+ assert_equal "123.456<789>E9",
573
+ check_setter(Numeral[digits_1_9, point: 12, repeat: 6], 3)
574
+ assert_equal "123.456<789>E10",
575
+ check_setter(Numeral[digits_1_9, point: 13, repeat: 6], 3)
576
+ assert_equal "123.456<789>E11",
577
+ check_setter(Numeral[digits_1_9, point: 14, repeat: 6], 3)
578
+ assert_equal "123.456<789>E22",
579
+ check_setter(Numeral[digits_1_9, point: 25, repeat: 6], 3)
580
+ assert_equal "123.456<789>E47",
581
+ check_setter(Numeral[digits_1_9, point: 50, repeat: 6], 3)
582
+ end
583
+
584
+ def test_repeating_exp_m1
585
+ digits_1_9 = (1..9).to_a
586
+
587
+ assert_equal ".0123456<789>E-49",
588
+ check_setter(Numeral[digits_1_9, point: -50, repeat: 6], -1)
589
+ assert_equal ".0123456<789>E-24",
590
+ check_setter(Numeral[digits_1_9, point: -25, repeat: 6], -1)
591
+ assert_equal ".0123456<789>E-5",
592
+ check_setter(Numeral[digits_1_9, point: -6, repeat: 6], -1)
593
+ assert_equal ".0123456<789>E-4",
594
+ check_setter(Numeral[digits_1_9, point: -5, repeat: 6], -1)
595
+ assert_equal ".0123456<789>E-3",
596
+ check_setter(Numeral[digits_1_9, point: -4, repeat: 6], -1)
597
+ assert_equal ".0123456<789>E-2",
598
+ check_setter(Numeral[digits_1_9, point: -3, repeat: 6], -1)
599
+ assert_equal ".0123456<789>E-1",
600
+ check_setter(Numeral[digits_1_9, point: -2, repeat: 6], -1)
601
+ assert_equal ".0123456<789>E0",
602
+ check_setter(Numeral[digits_1_9, point: -1, repeat: 6], -1)
603
+ assert_equal ".0123456<789>E1",
604
+ check_setter(Numeral[digits_1_9, point: 0, repeat: 6], -1)
605
+ assert_equal ".0123456<789>E2",
606
+ check_setter(Numeral[digits_1_9, point: 1, repeat: 6], -1)
607
+ assert_equal ".0123456<789>E3",
608
+ check_setter(Numeral[digits_1_9, point: 2, repeat: 6], -1)
609
+ assert_equal ".0123456<789>E4",
610
+ check_setter(Numeral[digits_1_9, point: 3, repeat: 6], -1)
611
+ assert_equal ".0123456<789>E5",
612
+ check_setter(Numeral[digits_1_9, point: 4, repeat: 6], -1)
613
+ assert_equal ".0123456<789>E6",
614
+ check_setter(Numeral[digits_1_9, point: 5, repeat: 6], -1)
615
+ assert_equal ".0123456<789>E7",
616
+ check_setter(Numeral[digits_1_9, point: 6, repeat: 6], -1)
617
+ assert_equal ".0123456<789>E8",
618
+ check_setter(Numeral[digits_1_9, point: 7, repeat: 6], -1)
619
+ assert_equal ".0123456<789>E9",
620
+ check_setter(Numeral[digits_1_9, point: 8, repeat: 6], -1)
621
+ assert_equal ".0123456<789>E10",
622
+ check_setter(Numeral[digits_1_9, point: 9, repeat: 6], -1)
623
+ assert_equal ".0123456<789>E11",
624
+ check_setter(Numeral[digits_1_9, point: 10, repeat: 6], -1)
625
+ assert_equal ".0123456<789>E12",
626
+ check_setter(Numeral[digits_1_9, point: 11, repeat: 6], -1)
627
+ assert_equal ".0123456<789>E13",
628
+ check_setter(Numeral[digits_1_9, point: 12, repeat: 6], -1)
629
+ assert_equal ".0123456<789>E14",
630
+ check_setter(Numeral[digits_1_9, point: 13, repeat: 6], -1)
631
+ assert_equal ".0123456<789>E15",
632
+ check_setter(Numeral[digits_1_9, point: 14, repeat: 6], -1)
633
+ assert_equal ".0123456<789>E26",
634
+ check_setter(Numeral[digits_1_9, point: 25, repeat: 6], -1)
635
+ assert_equal ".0123456<789>E51",
636
+ check_setter(Numeral[digits_1_9, point: 50, repeat: 6], -1)
637
+ end
638
+
639
+ def test_repeating_exp_m2
640
+ digits_1_9 = (1..9).to_a
641
+
642
+ assert_equal ".00123456<789>E-48",
643
+ check_setter(Numeral[digits_1_9, point: -50, repeat: 6], -2)
644
+ assert_equal ".00123456<789>E-23",
645
+ check_setter(Numeral[digits_1_9, point: -25, repeat: 6], -2)
646
+ assert_equal ".00123456<789>E-4",
647
+ check_setter(Numeral[digits_1_9, point: -6, repeat: 6], -2)
648
+ assert_equal ".00123456<789>E-3",
649
+ check_setter(Numeral[digits_1_9, point: -5, repeat: 6], -2)
650
+ assert_equal ".00123456<789>E-2",
651
+ check_setter(Numeral[digits_1_9, point: -4, repeat: 6], -2)
652
+ assert_equal ".00123456<789>E-1",
653
+ check_setter(Numeral[digits_1_9, point: -3, repeat: 6], -2)
654
+ assert_equal ".00123456<789>E0",
655
+ check_setter(Numeral[digits_1_9, point: -2, repeat: 6], -2)
656
+ assert_equal ".00123456<789>E1",
657
+ check_setter(Numeral[digits_1_9, point: -1, repeat: 6], -2)
658
+ assert_equal ".00123456<789>E2",
659
+ check_setter(Numeral[digits_1_9, point: 0, repeat: 6], -2)
660
+ assert_equal ".00123456<789>E3",
661
+ check_setter(Numeral[digits_1_9, point: 1, repeat: 6], -2)
662
+ assert_equal ".00123456<789>E4",
663
+ check_setter(Numeral[digits_1_9, point: 2, repeat: 6], -2)
664
+ assert_equal ".00123456<789>E5",
665
+ check_setter(Numeral[digits_1_9, point: 3, repeat: 6], -2)
666
+ assert_equal ".00123456<789>E6",
667
+ check_setter(Numeral[digits_1_9, point: 4, repeat: 6], -2)
668
+ assert_equal ".00123456<789>E7",
669
+ check_setter(Numeral[digits_1_9, point: 5, repeat: 6], -2)
670
+ assert_equal ".00123456<789>E8",
671
+ check_setter(Numeral[digits_1_9, point: 6, repeat: 6], -2)
672
+ assert_equal ".00123456<789>E9",
673
+ check_setter(Numeral[digits_1_9, point: 7, repeat: 6], -2)
674
+ assert_equal ".00123456<789>E10",
675
+ check_setter(Numeral[digits_1_9, point: 8, repeat: 6], -2)
676
+ assert_equal ".00123456<789>E11",
677
+ check_setter(Numeral[digits_1_9, point: 9, repeat: 6], -2)
678
+ assert_equal ".00123456<789>E12",
679
+ check_setter(Numeral[digits_1_9, point: 10, repeat: 6], -2)
680
+ assert_equal ".00123456<789>E13",
681
+ check_setter(Numeral[digits_1_9, point: 11, repeat: 6], -2)
682
+ assert_equal ".00123456<789>E14",
683
+ check_setter(Numeral[digits_1_9, point: 12, repeat: 6], -2)
684
+ assert_equal ".00123456<789>E15",
685
+ check_setter(Numeral[digits_1_9, point: 13, repeat: 6], -2)
686
+ assert_equal ".00123456<789>E16",
687
+ check_setter(Numeral[digits_1_9, point: 14, repeat: 6], -2)
688
+ assert_equal ".00123456<789>E27",
689
+ check_setter(Numeral[digits_1_9, point: 25, repeat: 6], -2)
690
+ assert_equal ".00123456<789>E52",
691
+ check_setter(Numeral[digits_1_9, point: 50, repeat: 6], -2)
692
+ end
693
+
694
+ def test_special_cases
695
+ # 0.0123<0000000000123>
696
+ num = Numeral[1,2,3, repeat: -10, point: -1]
697
+ assert_equal ".0123<0000000000123>E0", check_setter(num, nil)
698
+ parts = Format::ExpSetter[num]
699
+ assert_equal -1, parts.integer_part_size
700
+ assert_equal 0, parts.integer_part.size
701
+ assert_equal 4, parts.fractional_part_size
702
+ assert_equal 13, parts.repeat_part_size
703
+ assert_equal [], parts.integer_part.to_a
704
+ assert_equal [0,1,2,3], parts.fractional_part.to_a
705
+ assert_equal [0,0,0,0,0,0,0,0,0,0,1,2,3], parts.repeat_part.to_a
706
+
707
+ # 0.123<0000000000123>
708
+ num = Numeral[1,2,3, repeat: -10, point: 0]
709
+ assert_equal ".123<0000000000123>E0", check_setter(num, nil)
710
+ parts = Format::ExpSetter[num]
711
+ assert_equal 0, parts.integer_part_size
712
+ assert_equal 0, parts.integer_part.size
713
+ assert_equal 3, parts.fractional_part_size
714
+ assert_equal 13, parts.repeat_part_size
715
+ assert_equal [], parts.integer_part.to_a
716
+ assert_equal [1,2,3], parts.fractional_part.to_a
717
+ assert_equal [0,0,0,0,0,0,0,0,0,0,1,2,3], parts.repeat_part.to_a
718
+
719
+ # 1.<23<0000000001>
720
+ num = Numeral[1,2,3, repeat: -10, point: 1]
721
+ assert_equal "1.<2300000000001>E0", check_setter(num, nil)
722
+ parts = Format::ExpSetter[num]
723
+ assert_equal 1, parts.integer_part_size
724
+ assert_equal 1, parts.integer_part.size
725
+ assert_equal 0, parts.fractional_part_size
726
+ assert_equal 13, parts.repeat_part_size
727
+ assert_equal [1], parts.integer_part.to_a
728
+ assert_equal [], parts.fractional_part.to_a
729
+ assert_equal [2,3,0,0,0,0,0,0,0,0,0,0,1], parts.repeat_part.to_a
730
+ end
731
+
732
+ end