flex_array 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/flex_array/array.rb +55 -0
- data/lib/flex_array/flex_array_append.rb +51 -0
- data/lib/flex_array/flex_array_each.rb +98 -0
- data/lib/flex_array/flex_array_index.rb +42 -0
- data/lib/flex_array/flex_array_new.rb +98 -0
- data/lib/flex_array/flex_array_process.rb +103 -0
- data/lib/flex_array/flex_array_reshape.rb +46 -0
- data/lib/flex_array/flex_array_transpose.rb +17 -0
- data/lib/flex_array/flex_array_validate.rb +37 -0
- data/lib/flex_array/integer.rb +34 -0
- data/lib/flex_array/object.rb +29 -0
- data/lib/flex_array/range.rb +44 -0
- data/lib/flex_array/spec_component.rb +71 -0
- data/lib/flex_array.rb +89 -0
- data/license.txt +21 -0
- data/rakefile.rb +44 -0
- data/readme.txt +2 -0
- data/reek.txt +29 -0
- data/tests/array_test.rb +62 -0
- data/tests/flex_array_append_test.rb +82 -0
- data/tests/flex_array_each_test.rb +120 -0
- data/tests/flex_array_index_test.rb +222 -0
- data/tests/flex_array_new_test.rb +131 -0
- data/tests/flex_array_reshape_test.rb +76 -0
- data/tests/flex_array_test.rb +58 -0
- data/tests/flex_array_transpose_test.rb +32 -0
- data/tests/flex_array_validate_test.rb +29 -0
- data/tests/integer_test.rb +40 -0
- data/tests/object_test.rb +38 -0
- data/tests/range_test.rb +41 -0
- data/tests/spec_component_test.rb +88 -0
- metadata +144 -0
@@ -0,0 +1,88 @@
|
|
1
|
+
require_relative '../lib/flex_array/spec_component'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class SpecComponentTester < MiniTest::Unit::TestCase
|
5
|
+
$do_this_only_one_time = "" unless defined? $do_this_only_one_time
|
6
|
+
|
7
|
+
def initialize(*all)
|
8
|
+
if $do_this_only_one_time != __FILE__
|
9
|
+
puts
|
10
|
+
puts "Running test file: #{File.split(__FILE__)[1]}"
|
11
|
+
$do_this_only_one_time = __FILE__
|
12
|
+
end
|
13
|
+
|
14
|
+
super(*all)
|
15
|
+
end
|
16
|
+
|
17
|
+
def setup
|
18
|
+
@lc = SpecComponent.new(1..5, 10)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_the_range
|
22
|
+
assert_equal(1..5, @lc.range)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_the_stride
|
26
|
+
assert_equal(10, @lc.stride)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_the_equality_operator
|
30
|
+
a = SpecComponent.new(1..5, 1)
|
31
|
+
b = SpecComponent.new(1..6, 10)
|
32
|
+
|
33
|
+
assert(@lc == a)
|
34
|
+
refute(@lc == b)
|
35
|
+
refute(a == b)
|
36
|
+
|
37
|
+
#Make sure our == operator plays well with arrays.
|
38
|
+
assert([@lc] == [a])
|
39
|
+
refute([@lc] == [b])
|
40
|
+
refute([a] == [b])
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_the_threequal_operator
|
44
|
+
refute(@lc === 0)
|
45
|
+
assert(@lc === 1)
|
46
|
+
assert(@lc === 5)
|
47
|
+
refute(@lc === 6)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_out_min
|
51
|
+
assert_equal(1, @lc.min)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_out_max
|
55
|
+
assert_equal(5, @lc.max)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_out_span
|
59
|
+
assert_equal(5, @lc.span)
|
60
|
+
|
61
|
+
@lc = SpecComponent.new(0...0, 10)
|
62
|
+
assert_equal(0, @lc.span)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_out_each
|
66
|
+
i = (1..5).each
|
67
|
+
@lc.each {|v| assert_equal(i.next, v)}
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_out_index_step
|
71
|
+
assert_equal(0, @lc.index_step(1))
|
72
|
+
assert_equal(40, @lc.index_step(5))
|
73
|
+
|
74
|
+
@lc = SpecComponent.new(0...0, 10)
|
75
|
+
assert_raises(TypeError) { @lc.index_step(1) }
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_the_enlarge_method
|
79
|
+
assert_equal(5, @lc.span)
|
80
|
+
@lc.enlarge(5)
|
81
|
+
assert_equal(10, @lc.span)
|
82
|
+
|
83
|
+
@lc = SpecComponent.new(0...0, 10)
|
84
|
+
assert_equal(0, @lc.span)
|
85
|
+
@lc.enlarge(5)
|
86
|
+
assert_equal(5, @lc.span)
|
87
|
+
end
|
88
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flex_array
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Camilleri
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: reek
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: in_array
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: ! 'A flexible array class. '
|
70
|
+
email: peter.c.camilleri@gmail.com
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files:
|
74
|
+
- license.txt
|
75
|
+
files:
|
76
|
+
- lib/flex_array.rb
|
77
|
+
- lib/flex_array/array.rb
|
78
|
+
- lib/flex_array/flex_array_append.rb
|
79
|
+
- lib/flex_array/flex_array_each.rb
|
80
|
+
- lib/flex_array/flex_array_index.rb
|
81
|
+
- lib/flex_array/flex_array_new.rb
|
82
|
+
- lib/flex_array/flex_array_process.rb
|
83
|
+
- lib/flex_array/flex_array_reshape.rb
|
84
|
+
- lib/flex_array/flex_array_transpose.rb
|
85
|
+
- lib/flex_array/flex_array_validate.rb
|
86
|
+
- lib/flex_array/integer.rb
|
87
|
+
- lib/flex_array/object.rb
|
88
|
+
- lib/flex_array/range.rb
|
89
|
+
- lib/flex_array/spec_component.rb
|
90
|
+
- tests/array_test.rb
|
91
|
+
- tests/flex_array_append_test.rb
|
92
|
+
- tests/flex_array_each_test.rb
|
93
|
+
- tests/flex_array_index_test.rb
|
94
|
+
- tests/flex_array_new_test.rb
|
95
|
+
- tests/flex_array_reshape_test.rb
|
96
|
+
- tests/flex_array_test.rb
|
97
|
+
- tests/flex_array_transpose_test.rb
|
98
|
+
- tests/flex_array_validate_test.rb
|
99
|
+
- tests/integer_test.rb
|
100
|
+
- tests/object_test.rb
|
101
|
+
- tests/range_test.rb
|
102
|
+
- tests/spec_component_test.rb
|
103
|
+
- rakefile.rb
|
104
|
+
- license.txt
|
105
|
+
- readme.txt
|
106
|
+
- reek.txt
|
107
|
+
homepage: http://teuthida-technologies.com/
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: 1.9.3
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 2.1.4
|
128
|
+
signing_key:
|
129
|
+
specification_version: 4
|
130
|
+
summary: A flexible array class.
|
131
|
+
test_files:
|
132
|
+
- tests/array_test.rb
|
133
|
+
- tests/flex_array_append_test.rb
|
134
|
+
- tests/flex_array_each_test.rb
|
135
|
+
- tests/flex_array_index_test.rb
|
136
|
+
- tests/flex_array_new_test.rb
|
137
|
+
- tests/flex_array_reshape_test.rb
|
138
|
+
- tests/flex_array_test.rb
|
139
|
+
- tests/flex_array_transpose_test.rb
|
140
|
+
- tests/flex_array_validate_test.rb
|
141
|
+
- tests/integer_test.rb
|
142
|
+
- tests/object_test.rb
|
143
|
+
- tests/range_test.rb
|
144
|
+
- tests/spec_component_test.rb
|