fibonacci_rng 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aeaeffd9970516773ff376f31c7e9b937b40ad1e
4
- data.tar.gz: f81169d59987565caf00d8f0f58f5c055193c2ce
3
+ metadata.gz: 5064c4df22e9527ed30a68a7c7b4470721fd2e6c
4
+ data.tar.gz: a4f2d50bb58bf04fac0f66f7dfd57b7f0be5a6a7
5
5
  SHA512:
6
- metadata.gz: 539bd740b23b2466e8832f75138842c4b060154a3a1170686e0a6ee1aac9c6dc3690e3f2bf0f57e48ab976c6424f8eb6b16dd435a8f078fe5627f9109f586c20
7
- data.tar.gz: 14948121de4868db91145c8ff37fb45ff91c05fc7ccf08d8085c26de49a67391a507ba686585b2c5c0b67140b19a399d644fe576009704efdeeb43d2a4e6c0ba
6
+ metadata.gz: a4c4f246d53887844cb1e0a42cce67a99519da7c6c6070a5ca7de651c8468a87925d93f5648ae72714bdbf196700dd8e02e10a412f7990786d20f0b97ebb9a30
7
+ data.tar.gz: 5896d20ae29c6798376fc6961c08e1bd2eceff8eb2626a2f08a3f71c7a2e345d3a8da97efb1c21818a4a81b27e25af371753fd08af28795fd7301927228e337a
@@ -57,6 +57,8 @@ class FibonacciRng
57
57
  ASCII_7_BIT = (' '..'~').to_a.join
58
58
 
59
59
  #Create a random string
60
+ #<br>Endemic Code Smells.
61
+ #* :reek:FeatureEnvy
60
62
  def string(length, set=ASCII_7_BIT)
61
63
  set_length = set.length
62
64
  result = ""
@@ -7,13 +7,28 @@ class FibonacciRng
7
7
  def srand(seed=FibonacciRng.new_seed)
8
8
  @seed = seed
9
9
  @buffer = Array.new(@depth+2, 0)
10
- seedsrc = (seed.to_s + seed.class.to_s + 'Leonardo Pisano').each_byte.cycle
10
+ seedsrc = (seed.to_s + fudge(seed) + 'Leonardo Pisano').each_byte.cycle
11
11
  indxsrc = (0...depth).cycle
12
12
  do_reseed(indxsrc, seedsrc)
13
13
  end
14
14
 
15
15
  private
16
16
 
17
+ #A patch for the seeder class name bug.
18
+ #<br>Endemic Code Smells
19
+ #* :reek:UtilityFunction
20
+ def fudge(seed)
21
+ if seed.is_a?(Integer)
22
+ if (-1073741824..1073741823) === seed
23
+ "Fixnum"
24
+ else
25
+ "Bignum"
26
+ end
27
+ else
28
+ seed.class.to_s
29
+ end
30
+ end
31
+
17
32
  #A class instance variable to hold the tickle value.
18
33
  @tickle = '0'
19
34
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  #The class of Fibonacci inspired random number generators.
4
4
  class FibonacciRng
5
- VERSION = "1.1.1"
5
+ VERSION = "1.2.0"
6
6
  end
@@ -173,4 +173,21 @@ class FibonacciRngTester < Minitest::Test
173
173
  assert_equal('khto lk si', rng.string(10, 'Always look on the bright side of life.'))
174
174
  end
175
175
 
176
+ def test_for_data_stability
177
+ #Make sure incompatibilities do not creep in.
178
+ expected = [184, 93, 0, 240, 34, 184, 4, 220, 126, 132,
179
+ 13, 67, 166, 107, 165, 66, 68, 120, 102, 110,
180
+ 212, 99, 80, 167, 9, 56, 47, 167, 127, 195,
181
+ 169, 34, 184, 97, 136, 176, 214, 104, 218, 103,
182
+ 180, 16, 83, 204, 128, 81, 63, 56, 237, 165,
183
+ 0, 88, 129, 40, 152, 44, 189, 35, 205, 249,
184
+ 77, 94, 142, 18, 60, 248, 49, 172, 235, 83,
185
+ 84, 65, 181, 117, 16, 170, 222, 97, 130, 217]
186
+
187
+ prng = FibonacciRng.new("%s*08^_Tg{NnirtZ-94)q9z2l+~bB5")
188
+ result = Array.new(80) { prng.byte }
189
+
190
+ assert_equal(expected, result)
191
+ end
192
+
176
193
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fibonacci_rng
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Camilleri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-13 00:00:00.000000000 Z
11
+ date: 2016-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest_visible