simple-lazy 1.0.0 → 1.0.1
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Rakefile +6 -1
- data/lib/simple/lazy.rb +2 -2
- data/test/simple/lazy_test.rb +10 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df4524bc007b8fb0e402772f18c91b4d9fe8c531966f28cdfbe72691d3bb9dbd
|
4
|
+
data.tar.gz: 25dfcdb630ecebe6fbffabab38b2584d175f080cdd238a15ea3f0e91705892df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdfd870a9c0b4f32cef7cd05c04b47fa59d421af13a5ee4290babc20bf2e0b40d79c3b25237e246424e9472e210b1df38e62ff02c275013f8d4b9ba813200cc5
|
7
|
+
data.tar.gz: 06d8fa911efce4425f50f339d38fbb2b7bd9d9adc46b0c4da9fbd9ff6019e8704ff82d05d789e00e5b023bd7917b958af4789bc8269cca31d068779998772cfb
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
data/lib/simple/lazy.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Simple
|
2
2
|
class Lazy
|
3
|
-
VERSION = "1.0.
|
3
|
+
VERSION = "1.0.1"
|
4
4
|
|
5
5
|
attr_reader :value
|
6
6
|
|
@@ -28,7 +28,7 @@ module Simple
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def cached
|
31
|
-
unless @
|
31
|
+
unless @is_cached
|
32
32
|
@cached = @block.call(value)
|
33
33
|
@is_cached = true
|
34
34
|
end
|
data/test/simple/lazy_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "minitest/autorun"
|
2
|
+
require_relative "../../lib/simple/lazy"
|
2
3
|
|
3
4
|
class TestSimpleLazy < Minitest::Test
|
4
5
|
def test_1
|
@@ -23,11 +24,11 @@ class TestSimpleLazy < Minitest::Test
|
|
23
24
|
lazy.inspect
|
24
25
|
lazy.value
|
25
26
|
lazy.cached?
|
26
|
-
lazy == lazy
|
27
|
-
[lazy, lazy].sort
|
27
|
+
[lazy, lazy, (lazy == lazy) && 1, lazy.eql?(lazy) && 1].sort
|
28
28
|
lazy.hash
|
29
29
|
rescue => e
|
30
30
|
error = e
|
31
|
+
puts error.backtrace
|
31
32
|
end
|
32
33
|
|
33
34
|
assert_nil(error)
|
@@ -37,4 +38,11 @@ class TestSimpleLazy < Minitest::Test
|
|
37
38
|
lazy = Simple::Lazy.new(1) { |id| "oh" }
|
38
39
|
assert_equal("oh", lazy.to_s)
|
39
40
|
end
|
41
|
+
|
42
|
+
def test_5
|
43
|
+
lazy = Simple::Lazy.new(1) { nil }
|
44
|
+
assert_equal(false, lazy.cached?)
|
45
|
+
assert_equal("", lazy.to_s)
|
46
|
+
assert_equal(true, lazy.cached?)
|
47
|
+
end
|
40
48
|
end
|