gosling 2.3.0 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,80 +1,80 @@
1
- class VectorCache
2
- def cache
3
- @cache
4
- end
5
- end
6
-
7
- describe VectorCache do
8
- describe '.get' do
9
- context 'when there are no Vec3 objects available' do
10
- before do
11
- VectorCache.instance.clear
12
- end
13
-
14
- it 'creates a new Vec3 and returns it' do
15
- new_vector = Snow::Vec3.new
16
- expect(Snow::Vec3).to receive(:new).and_return(new_vector)
17
- v = VectorCache.instance.get
18
- expect(v).to equal(new_vector)
19
- end
20
- end
21
-
22
- context 'when there are Vec3 objects available' do
23
- before do
24
- VectorCache.instance.clear
25
- @recycled_vector = Snow::Vec3.new
26
- VectorCache.instance.recycle(@recycled_vector)
27
- end
28
-
29
- it 'does not create a new Vec3' do
30
- expect(Snow::Vec3).not_to receive(:new)
31
- VectorCache.instance.get
32
- end
33
-
34
- it 'returns one of the cached Vec3' do
35
- expect(VectorCache.instance.get).to eq(@recycled_vector)
36
- end
37
- end
38
- end
39
-
40
- describe '.recycle' do
41
- it 'expects a Vec3' do
42
- expect{ VectorCache.instance.recycle(Snow::Vec3.new) }.not_to raise_error
43
- expect{ VectorCache.instance.recycle(:foo) }.to raise_error(ArgumentError)
44
- end
45
-
46
- it 'adds the Vec3 to the cache' do
47
- v = Snow::Vec3.new
48
- VectorCache.instance.recycle(v)
49
- expect(VectorCache.instance.cache.values).to include(v)
50
- end
51
-
52
- it 'zeros out the Vec3' do
53
- v = Snow::Vec3[1, 2, 3]
54
- VectorCache.instance.recycle(v)
55
- expect(v.x).to eq(0)
56
- expect(v.y).to eq(0)
57
- expect(v.z).to eq(0)
58
- end
59
- end
60
-
61
- describe '.clear' do
62
- it 'removes all Vec3 from the cache' do
63
- VectorCache.instance.recycle(Snow::Vec3.new)
64
- VectorCache.instance.recycle(Snow::Vec3.new)
65
- VectorCache.instance.recycle(Snow::Vec3.new)
66
- VectorCache.instance.clear
67
- expect(VectorCache.instance.size).to eq(0)
68
- end
69
- end
70
-
71
- describe '.size' do
72
- it 'returns the number of Vec3 in the cache' do
73
- VectorCache.instance.clear
74
- VectorCache.instance.recycle(Snow::Vec3.new)
75
- VectorCache.instance.recycle(Snow::Vec3.new)
76
- VectorCache.instance.recycle(Snow::Vec3.new)
77
- expect(VectorCache.instance.size).to eq(3)
78
- end
79
- end
80
- end
1
+ class VectorCache
2
+ def cache
3
+ @cache
4
+ end
5
+ end
6
+
7
+ describe VectorCache do
8
+ describe '.get' do
9
+ context 'when there are no Vec3 objects available' do
10
+ before do
11
+ VectorCache.instance.clear
12
+ end
13
+
14
+ it 'creates a new Vec3 and returns it' do
15
+ new_vector = Snow::Vec3.new
16
+ expect(Snow::Vec3).to receive(:new).and_return(new_vector)
17
+ v = VectorCache.instance.get
18
+ expect(v).to equal(new_vector)
19
+ end
20
+ end
21
+
22
+ context 'when there are Vec3 objects available' do
23
+ before do
24
+ VectorCache.instance.clear
25
+ @recycled_vector = Snow::Vec3.new
26
+ VectorCache.instance.recycle(@recycled_vector)
27
+ end
28
+
29
+ it 'does not create a new Vec3' do
30
+ expect(Snow::Vec3).not_to receive(:new)
31
+ VectorCache.instance.get
32
+ end
33
+
34
+ it 'returns one of the cached Vec3' do
35
+ expect(VectorCache.instance.get).to eq(@recycled_vector)
36
+ end
37
+ end
38
+ end
39
+
40
+ describe '.recycle' do
41
+ it 'expects a Vec3' do
42
+ expect{ VectorCache.instance.recycle(Snow::Vec3.new) }.not_to raise_error
43
+ expect{ VectorCache.instance.recycle(:foo) }.to raise_error(ArgumentError)
44
+ end
45
+
46
+ it 'adds the Vec3 to the cache' do
47
+ v = Snow::Vec3.new
48
+ VectorCache.instance.recycle(v)
49
+ expect(VectorCache.instance.cache.values).to include(v)
50
+ end
51
+
52
+ it 'zeros out the Vec3' do
53
+ v = Snow::Vec3[1, 2, 3]
54
+ VectorCache.instance.recycle(v)
55
+ expect(v.x).to eq(0)
56
+ expect(v.y).to eq(0)
57
+ expect(v.z).to eq(0)
58
+ end
59
+ end
60
+
61
+ describe '.clear' do
62
+ it 'removes all Vec3 from the cache' do
63
+ VectorCache.instance.recycle(Snow::Vec3.new)
64
+ VectorCache.instance.recycle(Snow::Vec3.new)
65
+ VectorCache.instance.recycle(Snow::Vec3.new)
66
+ VectorCache.instance.clear
67
+ expect(VectorCache.instance.size).to eq(0)
68
+ end
69
+ end
70
+
71
+ describe '.size' do
72
+ it 'returns the number of Vec3 in the cache' do
73
+ VectorCache.instance.clear
74
+ VectorCache.instance.recycle(Snow::Vec3.new)
75
+ VectorCache.instance.recycle(Snow::Vec3.new)
76
+ VectorCache.instance.recycle(Snow::Vec3.new)
77
+ expect(VectorCache.instance.size).to eq(3)
78
+ end
79
+ end
80
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosling
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Amos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-05 00:00:00.000000000 Z
11
+ date: 2019-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gosu
@@ -114,8 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
- rubyforge_project:
118
- rubygems_version: 2.5.2
117
+ rubygems_version: 3.0.6
119
118
  signing_key:
120
119
  specification_version: 4
121
120
  summary: A library for creating 2D apps