reflexion 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/.doc/ext/reflex/application.cpp +35 -76
  2. data/.doc/ext/reflex/defs.cpp +8 -0
  3. data/.doc/ext/reflex/key.cpp +38 -43
  4. data/.doc/ext/reflex/native.cpp +6 -4
  5. data/.doc/ext/reflex/points.cpp +47 -52
  6. data/.doc/ext/reflex/reflex.cpp +12 -13
  7. data/.doc/ext/reflex/view.cpp +242 -0
  8. data/.doc/ext/reflex/window.cpp +87 -178
  9. data/.gitignore +14 -0
  10. data/Rakefile +6 -31
  11. data/VERSION +1 -1
  12. data/examples/hello/.gitignore +2 -0
  13. data/examples/ruby/app.rb +2 -2
  14. data/examples/ruby/checker.rb +3 -3
  15. data/examples/ruby/fps.rb +14 -14
  16. data/examples/ruby/grid.rb +65 -0
  17. data/examples/ruby/hello.rb +19 -7
  18. data/examples/ruby/key.rb +4 -4
  19. data/examples/ruby/shapes.rb +6 -6
  20. data/examples/ruby/text.rb +20 -17
  21. data/examples/ruby/views.rb +88 -0
  22. data/examples/ruby/visuals.rb +27 -0
  23. data/ext/reflex/application.cpp +36 -76
  24. data/ext/reflex/defs.cpp +8 -0
  25. data/ext/reflex/defs.h +1 -18
  26. data/ext/reflex/extconf.rb +16 -8
  27. data/ext/reflex/key.cpp +39 -43
  28. data/ext/reflex/native.cpp +6 -4
  29. data/ext/reflex/points.cpp +48 -52
  30. data/ext/reflex/reflex.cpp +12 -13
  31. data/ext/reflex/view.cpp +260 -0
  32. data/ext/reflex/window.cpp +89 -178
  33. data/include/reflex/application.h +14 -7
  34. data/include/reflex/defs.h +8 -6
  35. data/include/reflex/exception.h +1 -1
  36. data/include/reflex/ruby/application.h +31 -10
  37. data/include/reflex/ruby/key.h +3 -3
  38. data/include/reflex/ruby/points.h +3 -3
  39. data/include/reflex/ruby/view.h +106 -0
  40. data/include/reflex/ruby/window.h +83 -12
  41. data/include/reflex/ruby.h +3 -2
  42. data/include/reflex/view.h +103 -0
  43. data/include/reflex/window.h +43 -18
  44. data/include/reflex.h +2 -1
  45. data/lib/reflex/application.rb +8 -7
  46. data/lib/reflex/autoinit.rb +1 -1
  47. data/lib/reflex/bitmap.rb +13 -0
  48. data/lib/reflex/bounds.rb +2 -122
  49. data/lib/reflex/ext.rb +5 -0
  50. data/lib/reflex/helpers.rb +36 -31
  51. data/lib/reflex/image.rb +13 -0
  52. data/lib/reflex/module.rb +9 -2
  53. data/lib/reflex/painter.rb +13 -0
  54. data/lib/reflex/point.rb +3 -59
  55. data/lib/reflex/reflex.rb +1 -1
  56. data/lib/reflex/texture.rb +13 -0
  57. data/lib/reflex/view.rb +33 -0
  58. data/lib/reflex/visuals/string.rb +53 -0
  59. data/lib/reflex/window.rb +18 -43
  60. data/lib/reflex.rb +3 -3
  61. data/reflex.gemspec +16 -42
  62. data/src/cocoa/application.mm +17 -23
  63. data/src/cocoa/applicationdata.h +3 -9
  64. data/src/cocoa/cocoaapplication.h +6 -4
  65. data/src/cocoa/cocoaapplication.mm +61 -19
  66. data/src/cocoa/cocoawindow.h +7 -5
  67. data/src/cocoa/cocoawindow.mm +109 -50
  68. data/src/cocoa/defs.mm +5 -2
  69. data/src/cocoa/window.mm +71 -41
  70. data/src/cocoa/windowdata.h +14 -9
  71. data/src/defs.cpp +1 -1
  72. data/src/exception.cpp +3 -18
  73. data/src/helpers.h +12 -0
  74. data/src/reflex.cpp +11 -5
  75. data/src/view.cpp +326 -0
  76. data/src/win32/application.cpp +7 -8
  77. data/src/win32/defs.h +1 -1
  78. data/src/win32/window.cpp +137 -41
  79. data/src/window.cpp +38 -1
  80. data/test/helpers.rb +2 -5
  81. data/test/test_application.rb +17 -0
  82. data/test/test_reflex.rb +4 -2
  83. data/test/test_view.rb +74 -0
  84. data/test/test_window.rb +33 -2
  85. metadata +157 -97
  86. data/include/reflex/helpers.h +0 -32
  87. data/test/test_bounds.rb +0 -163
  88. data/test/test_point.rb +0 -81
metadata CHANGED
@@ -1,196 +1,256 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: reflexion
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
4
5
  prerelease:
5
- version: 0.1.3
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - snori
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-09-19 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: xot
12
+ date: 2013-04-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
17
23
  prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: xot
32
+ requirement: !ruby/object:Gem::Requirement
19
33
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
24
38
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: rucy
28
39
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rucy
48
+ requirement: !ruby/object:Gem::Requirement
30
49
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
35
54
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: rays
39
55
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
41
57
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "0"
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rays
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
46
70
  type: :runtime
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: rake
50
71
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
52
81
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0"
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
57
86
  type: :development
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: gemcutter
61
87
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: gemcutter
96
+ requirement: !ruby/object:Gem::Requirement
63
97
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: "0"
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
68
102
  type: :development
69
- version_requirements: *id005
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
70
110
  description: This library helps you to develop interactive graphical user interface.
71
111
  email: snori@xord.org
72
112
  executables: []
73
-
74
- extensions:
113
+ extensions:
75
114
  - Rakefile
76
- extra_rdoc_files:
115
+ extra_rdoc_files:
77
116
  - README
78
117
  - .doc/ext/reflex/application.cpp
118
+ - .doc/ext/reflex/defs.cpp
79
119
  - .doc/ext/reflex/key.cpp
80
120
  - .doc/ext/reflex/native.cpp
81
121
  - .doc/ext/reflex/points.cpp
82
122
  - .doc/ext/reflex/reflex.cpp
123
+ - .doc/ext/reflex/view.cpp
83
124
  - .doc/ext/reflex/window.cpp
84
- files:
85
- - README
125
+ files:
126
+ - .gitignore
86
127
  - ChangeLog
128
+ - README
87
129
  - Rakefile
88
- - reflex.gemspec
89
130
  - VERSION
90
- - ext/reflex/extconf.rb
91
- - ext/reflex/defs.h
131
+ - examples/hello/.gitignore
132
+ - examples/hello/Rakefile
133
+ - examples/hello/main.cpp
134
+ - examples/ruby/app.rb
135
+ - examples/ruby/checker.rb
136
+ - examples/ruby/fps.rb
137
+ - examples/ruby/grid.rb
138
+ - examples/ruby/hello.rb
139
+ - examples/ruby/key.rb
140
+ - examples/ruby/shapes.rb
141
+ - examples/ruby/text.rb
142
+ - examples/ruby/views.rb
143
+ - examples/ruby/visuals.rb
92
144
  - ext/reflex/application.cpp
145
+ - ext/reflex/defs.cpp
146
+ - ext/reflex/defs.h
147
+ - ext/reflex/extconf.rb
93
148
  - ext/reflex/key.cpp
94
149
  - ext/reflex/native.cpp
95
150
  - ext/reflex/points.cpp
96
151
  - ext/reflex/reflex.cpp
152
+ - ext/reflex/view.cpp
97
153
  - ext/reflex/window.cpp
154
+ - include/reflex.h
98
155
  - include/reflex/application.h
99
156
  - include/reflex/defs.h
100
157
  - include/reflex/exception.h
101
- - include/reflex/helpers.h
102
158
  - include/reflex/reflex.h
159
+ - include/reflex/ruby.h
103
160
  - include/reflex/ruby/application.h
104
161
  - include/reflex/ruby/key.h
105
162
  - include/reflex/ruby/points.h
106
163
  - include/reflex/ruby/reflex.h
164
+ - include/reflex/ruby/view.h
107
165
  - include/reflex/ruby/window.h
108
- - include/reflex/ruby.h
166
+ - include/reflex/view.h
109
167
  - include/reflex/window.h
110
- - include/reflex.h
168
+ - lib/reflex.rb
111
169
  - lib/reflex/application.rb
112
170
  - lib/reflex/autoinit.rb
171
+ - lib/reflex/bitmap.rb
113
172
  - lib/reflex/bounds.rb
173
+ - lib/reflex/ext.rb
114
174
  - lib/reflex/helpers.rb
175
+ - lib/reflex/image.rb
115
176
  - lib/reflex/module.rb
177
+ - lib/reflex/painter.rb
116
178
  - lib/reflex/point.rb
117
179
  - lib/reflex/reflex.rb
180
+ - lib/reflex/texture.rb
181
+ - lib/reflex/view.rb
182
+ - lib/reflex/visuals/string.rb
118
183
  - lib/reflex/window.rb
119
- - lib/reflex.rb
184
+ - reflex.gemspec
185
+ - src/cocoa/application.mm
120
186
  - src/cocoa/applicationdata.h
121
187
  - src/cocoa/cocoaapplication.h
188
+ - src/cocoa/cocoaapplication.mm
122
189
  - src/cocoa/cocoawindow.h
190
+ - src/cocoa/cocoawindow.mm
123
191
  - src/cocoa/defs.h
192
+ - src/cocoa/defs.mm
124
193
  - src/cocoa/openglview.h
194
+ - src/cocoa/openglview.mm
195
+ - src/cocoa/reflex.mm
196
+ - src/cocoa/window.mm
125
197
  - src/cocoa/windowdata.h
126
- - src/win32/defs.h
127
- - src/win32/opengl.h
128
198
  - src/defs.cpp
129
199
  - src/exception.cpp
200
+ - src/helpers.h
130
201
  - src/reflex.cpp
202
+ - src/view.cpp
131
203
  - src/win32/application.cpp
132
204
  - src/win32/defs.cpp
205
+ - src/win32/defs.h
133
206
  - src/win32/opengl.cpp
207
+ - src/win32/opengl.h
134
208
  - src/win32/reflex.cpp
135
209
  - src/win32/window.cpp
136
210
  - src/window.cpp
137
- - src/cocoa/application.mm
138
- - src/cocoa/cocoaapplication.mm
139
- - src/cocoa/cocoawindow.mm
140
- - src/cocoa/defs.mm
141
- - src/cocoa/openglview.mm
142
- - src/cocoa/reflex.mm
143
- - src/cocoa/window.mm
144
- - examples/hello/Rakefile
145
- - examples/hello/main.cpp
146
- - examples/ruby/app.rb
147
- - examples/ruby/checker.rb
148
- - examples/ruby/fps.rb
149
- - examples/ruby/hello.rb
150
- - examples/ruby/key.rb
151
- - examples/ruby/shapes.rb
152
- - examples/ruby/text.rb
153
211
  - test/helpers.rb
154
- - test/test_bounds.rb
155
- - test/test_point.rb
212
+ - test/test_application.rb
156
213
  - test/test_reflex.rb
214
+ - test/test_view.rb
157
215
  - test/test_window.rb
158
216
  - .doc/ext/reflex/application.cpp
217
+ - .doc/ext/reflex/defs.cpp
159
218
  - .doc/ext/reflex/key.cpp
160
219
  - .doc/ext/reflex/native.cpp
161
220
  - .doc/ext/reflex/points.cpp
162
221
  - .doc/ext/reflex/reflex.cpp
222
+ - .doc/ext/reflex/view.cpp
163
223
  - .doc/ext/reflex/window.cpp
164
224
  homepage: http://github.com/xord/reflex
165
225
  licenses: []
166
-
167
226
  post_install_message:
168
227
  rdoc_options: []
169
-
170
- require_paths:
228
+ require_paths:
171
229
  - lib
172
- - ext
173
- required_ruby_version: !ruby/object:Gem::Requirement
230
+ required_ruby_version: !ruby/object:Gem::Requirement
174
231
  none: false
175
- requirements:
176
- - - ">="
177
- - !ruby/object:Gem::Version
232
+ requirements:
233
+ - - ! '>='
234
+ - !ruby/object:Gem::Version
178
235
  version: 1.9.0
179
- required_rubygems_version: !ruby/object:Gem::Requirement
236
+ required_rubygems_version: !ruby/object:Gem::Requirement
180
237
  none: false
181
- requirements:
182
- - - ">="
183
- - !ruby/object:Gem::Version
184
- version: "0"
238
+ requirements:
239
+ - - ! '>='
240
+ - !ruby/object:Gem::Version
241
+ version: '0'
242
+ segments:
243
+ - 0
244
+ hash: 3313943226242490739
185
245
  requirements: []
186
-
187
246
  rubyforge_project:
188
- rubygems_version: 1.8.1
247
+ rubygems_version: 1.8.25
189
248
  signing_key:
190
249
  specification_version: 3
191
250
  summary: A Graphical User Interface Tool Kit.
192
- test_files:
193
- - test/test_bounds.rb
194
- - test/test_point.rb
251
+ test_files:
252
+ - test/helpers.rb
253
+ - test/test_application.rb
195
254
  - test/test_reflex.rb
255
+ - test/test_view.rb
196
256
  - test/test_window.rb
@@ -1,32 +0,0 @@
1
- // -*- c++ -*-
2
- #pragma once
3
- #ifndef __REFLEX_HELPERS_H__
4
- #define __REFLEX_HELPERS_H__
5
-
6
-
7
- #include <boost/shared_ptr.hpp>
8
-
9
-
10
- namespace Reflex
11
- {
12
-
13
-
14
- template <typename T>
15
- class Impl : public boost::shared_ptr<T>
16
- {
17
-
18
- typedef boost::shared_ptr<T> Super;
19
-
20
- public:
21
-
22
- Impl () : Super(new T) {}
23
-
24
- Impl (T* p) : Super(p) {}
25
-
26
- };// Impl
27
-
28
-
29
- }// Reflex
30
-
31
-
32
- #endif//EOH
data/test/test_bounds.rb DELETED
@@ -1,163 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- $: << File.dirname(__FILE__)
3
- require 'helpers'
4
-
5
-
6
- class TestBounds < Test::Unit::TestCase
7
-
8
- def bounds (*args)
9
- Reflex::Bounds.new *args
10
- end
11
-
12
- def test_initialize ()
13
- assert_nothing_raised {bounds()}
14
- assert_nothing_raised {bounds(1)}
15
- assert_nothing_raised {bounds(1, 2)}
16
- assert_nothing_raised {bounds(1, 2, 3, 4)}
17
- assert_raise(ArgumentError) {bounds(1, 2, 3)}
18
- assert_raise(ArgumentError) {bounds(1, 2, 3, 4, 5)}
19
- assert_raise(ArgumentError) {bounds(1, 2, 3, 4, 5, 6)}
20
- assert_equal bounds(0, 0, 0, 0), bounds()
21
- assert_equal bounds(0, 0, 1, 1), bounds(1)
22
- assert_equal bounds(0, 0, 1, 2), bounds(1, 2)
23
- assert_equal [1, 2, 3, 4], bounds(1, 2, 3, 4).to_a
24
- end
25
-
26
- def test_xywh ()
27
- o = bounds 1, 2, 3, 4
28
- assert_equal 1, o.x
29
- assert_equal 2, o.y
30
- assert_equal 3, o.width
31
- assert_equal 4, o.height
32
- assert_equal o.width, o.w
33
- assert_equal o.height, o.h
34
- o = bounds
35
- o.x = 1
36
- assert_equal [1, 0, 0, 0], o.to_a
37
- o.y = 2
38
- assert_equal [1, 2, 0, 0], o.to_a
39
- o.width = 3
40
- assert_equal [1, 2, 3, 0], o.to_a
41
- o.height = 4
42
- assert_equal [1, 2, 3, 4], o.to_a
43
- o.w = 5
44
- assert_equal [1, 2, 5, 4], o.to_a
45
- o.h = 6
46
- assert_equal [1, 2, 5, 6], o.to_a
47
- end
48
-
49
- def test_ltrb ()
50
- o = bounds 1, 2, 3, 4
51
- assert_equal 1, o.left
52
- assert_equal 2, o.top
53
- assert_equal 3, o.right
54
- assert_equal 5, o.bottom
55
- assert_equal o.left, o.l
56
- assert_equal o.top, o.t
57
- assert_equal o.right, o.r
58
- assert_equal o.bottom, o.b
59
- o = bounds
60
- o.left = 1
61
- assert_equal [1, 0, 0, 0], o.to_a
62
- o.top = 2
63
- assert_equal [1, 2, 0, 0], o.to_a
64
- o.right = 5
65
- assert_equal [1, 2, 5, 0], o.to_a
66
- o.bottom = 10
67
- assert_equal [1, 2, 5, 9], o.to_a
68
- o.l = 10
69
- assert_equal [10, 2, 5, 9], o.to_a
70
- o.t = 11
71
- assert_equal [10, 11, 5, 9], o.to_a
72
- o.r = 20
73
- assert_equal [10, 11, 11, 9], o.to_a
74
- o.b = 30
75
- assert_equal [10, 11, 11, 20], o.to_a
76
- end
77
-
78
- def test_size ()
79
- o = bounds 1, 2, 3, 5
80
- assert_equal 3, o.width
81
- assert_equal 5, o.height
82
- end
83
-
84
- def test_offset_to ()
85
- o = bounds 1, 2, 3, 4
86
- assert_equal bounds(5, 6, 3, 4), o.offset_to(5, 6)
87
- assert_equal bounds(5, 5, 3, 4), o.offset_to(5)
88
- assert_raise(ArgumentError) {o.offset_to()}
89
- assert_raise(ArgumentError) {o.offset_to(5, 6, 7)}
90
- assert_raise(ArgumentError) {o.offset_to(5, 6, 7, 8)}
91
- x0 = o.dup
92
- x1 = x0.offset_to(5, 6)
93
- assert_equal o, x0
94
- assert_equal bounds(5, 6, 3, 4), x1
95
- x0.offset_to!(7, 8)
96
- assert_equal bounds(7, 8, 3, 4), x0
97
- assert_not_equal o, x0
98
- end
99
-
100
- def test_offset_by ()
101
- o = bounds 1, 2, 3, 4
102
- assert_equal bounds(6, 8, 3, 4), o.offset_by(5, 6)
103
- assert_equal bounds(6, 7, 3, 4), o.offset_by(5)
104
- assert_equal bounds(-4, -3, 3, 4), o.offset_by(-5)
105
- assert_equal bounds(-4, -4, 3, 4), o.offset_by(-5, -6)
106
- assert_raise(ArgumentError) {o.offset_by()}
107
- assert_raise(ArgumentError) {o.offset_by(5, 6, 7)}
108
- assert_raise(ArgumentError) {o.offset_by(5, 6, 7, 8)}
109
- x0 = o.dup
110
- x1 = x0.offset_by(5, 6)
111
- assert_equal o, x0
112
- assert_equal bounds(6, 8, 3, 4), x1
113
- x0.offset_by!(7, 8)
114
- assert_equal bounds(8, 10, 3, 4), x0
115
- assert_not_equal o, x0
116
- end
117
-
118
- def test_inset_by ()
119
- o = bounds 1, 2, 11, 12
120
- assert_equal bounds(3, 5, 7, 6), o.inset_by(2, 3)
121
- assert_equal bounds(3, 4, 7, 8), o.inset_by(2)
122
- assert_raise(ArgumentError) {o.inset_by()}
123
- assert_raise(ArgumentError) {o.inset_by(5, 6, 7)}
124
- assert_raise(ArgumentError) {o.inset_by(5, 6, 7, 8)}
125
- x0 = o.dup
126
- x1 = x0.inset_by(3, 4)
127
- assert_equal o, x0
128
- assert_equal bounds(4, 6, 5, 4), x1
129
- x0.inset_by!(5, 6)
130
- assert_equal bounds(6, 8, 1, 0), x0
131
- assert_not_equal o, x0
132
- assert_equal bounds(8, 10, -3, -4), o.inset_by(7, 8)
133
- end
134
-
135
- def test_to_a ()
136
- assert_equal [1, 2, 3, 4], bounds(1, 2, 3, 4).to_a
137
- end
138
-
139
- def test_index ()
140
- o = bounds 1, 2, 3, 4
141
- assert_equal Reflex::Point.new(1, 2), o[0]
142
- assert_equal Reflex::Point.new(3, 5), o[1]
143
- assert_raise(IndexError) {o[-1]}
144
- assert_raise(IndexError) {o[2]}
145
- end
146
-
147
- def test_compare ()
148
- o = bounds 1, 2, 3, 4
149
- assert o == bounds(1, 2, 3, 4)
150
- assert !(o != bounds(1, 2, 3, 4))
151
- assert o < bounds(2, 2, 3, 4)
152
- assert o < bounds(1, 3, 3, 4)
153
- assert o < bounds(1, 2, 4, 4)
154
- assert o < bounds(1, 2, 3, 5)
155
- assert o < bounds(2, 3, 4, 5)
156
- assert o > bounds(0, 2, 3, 4)
157
- assert o > bounds(1, 1, 3, 4)
158
- assert o > bounds(1, 2, 2, 4)
159
- assert o > bounds(1, 2, 3, 3)
160
- assert o > bounds(0, 1, 2, 3)
161
- end
162
-
163
- end# TestBounds
data/test/test_point.rb DELETED
@@ -1,81 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- $: << File.dirname(__FILE__)
3
- require 'helpers'
4
-
5
-
6
- class TestPoint < Test::Unit::TestCase
7
-
8
- def point (*args)
9
- Reflex::Point.new *args
10
- end
11
-
12
- def test_initialize ()
13
- assert_nothing_raised {point()}
14
- assert_nothing_raised {point(1)}
15
- assert_nothing_raised {point(1, 2)}
16
- assert_raise(ArgumentError) {point(1, 2, 3)}
17
- assert_equal point(0, 0), point()
18
- assert_equal point(1, 1), point(1)
19
- assert_equal [2, 3], point(2, 3).to_a
20
- end
21
-
22
- def test_xy ()
23
- assert_equal 1, point(1).x
24
- assert_equal 1, point(1).y
25
- o = point
26
- o.x = 1
27
- assert_equal [1, 0], [o.x, o.y]
28
- o.y = 2
29
- assert_equal [1, 2], [o.x, o.y]
30
- end
31
-
32
- def test_offset_to ()
33
- assert_equal point(4, 3), point(1, 2).offset_to(4, 3)
34
- assert_equal point(3, 3), point(1, 2).offset_to(3)
35
- assert_raise(ArgumentError) {point(1, 2).offset_to()}
36
- assert_raise(ArgumentError) {point(1, 2).offset_to(3, 4, 5)}
37
- x0 = point(1, 2)
38
- x1 = x0.offset_to(3, 4)
39
- assert_equal point(1, 2), x0
40
- assert_equal point(3, 4), x1
41
- x0.offset_to!(5, 6)
42
- assert_equal point(5, 6), x0
43
- end
44
-
45
- def test_offset_by ()
46
- assert_equal point(4, 6), point(1, 2).offset_by(3, 4)
47
- assert_equal point(6, 7), point(1, 2).offset_by(5)
48
- assert_equal point(-5, -4), point(1, 2).offset_by(-6)
49
- assert_equal point(-6, -6), point(1, 2).offset_by(-7, -8)
50
- assert_raise(ArgumentError) {point(1, 2).offset_by()}
51
- assert_raise(ArgumentError) {point(1, 2).offset_by(3, 4, 5)}
52
- x0 = point(1, 2)
53
- x1 = x0.offset_by(3, 4)
54
- assert_equal point(1, 2), x0
55
- assert_equal point(4, 6), x1
56
- x0.offset_by!(5, 6)
57
- assert_equal point(6, 8), x0
58
- end
59
-
60
- def test_to_a ()
61
- assert_equal [1, 2], point(1, 2).to_a
62
- end
63
-
64
- def test_index ()
65
- assert_equal 1, point(1, 2)[0]
66
- assert_equal 2, point(1, 2)[1]
67
- assert_raise(IndexError) {point[2]}
68
- end
69
-
70
- def test_compare ()
71
- assert point(1, 2) == point(1, 2)
72
- assert !(point(1, 2) != point(1, 2))
73
- assert point(1, 2) < point(2, 2)
74
- assert point(1, 2) < point(1, 3)
75
- assert point(1, 2) < point(2, 3)
76
- assert point(1, 2) > point(0, 2)
77
- assert point(1, 2) > point(1, 1)
78
- assert point(1, 2) > point(0, 1)
79
- end
80
-
81
- end# TestPoint