reflexion 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.doc/ext/reflex/application.cpp +35 -76
- data/.doc/ext/reflex/defs.cpp +8 -0
- data/.doc/ext/reflex/key.cpp +38 -43
- data/.doc/ext/reflex/native.cpp +6 -4
- data/.doc/ext/reflex/points.cpp +47 -52
- data/.doc/ext/reflex/reflex.cpp +12 -13
- data/.doc/ext/reflex/view.cpp +242 -0
- data/.doc/ext/reflex/window.cpp +87 -178
- data/.gitignore +14 -0
- data/Rakefile +6 -31
- data/VERSION +1 -1
- data/examples/hello/.gitignore +2 -0
- data/examples/ruby/app.rb +2 -2
- data/examples/ruby/checker.rb +3 -3
- data/examples/ruby/fps.rb +14 -14
- data/examples/ruby/grid.rb +65 -0
- data/examples/ruby/hello.rb +19 -7
- data/examples/ruby/key.rb +4 -4
- data/examples/ruby/shapes.rb +6 -6
- data/examples/ruby/text.rb +20 -17
- data/examples/ruby/views.rb +88 -0
- data/examples/ruby/visuals.rb +27 -0
- data/ext/reflex/application.cpp +36 -76
- data/ext/reflex/defs.cpp +8 -0
- data/ext/reflex/defs.h +1 -18
- data/ext/reflex/extconf.rb +16 -8
- data/ext/reflex/key.cpp +39 -43
- data/ext/reflex/native.cpp +6 -4
- data/ext/reflex/points.cpp +48 -52
- data/ext/reflex/reflex.cpp +12 -13
- data/ext/reflex/view.cpp +260 -0
- data/ext/reflex/window.cpp +89 -178
- data/include/reflex/application.h +14 -7
- data/include/reflex/defs.h +8 -6
- data/include/reflex/exception.h +1 -1
- data/include/reflex/ruby/application.h +31 -10
- data/include/reflex/ruby/key.h +3 -3
- data/include/reflex/ruby/points.h +3 -3
- data/include/reflex/ruby/view.h +106 -0
- data/include/reflex/ruby/window.h +83 -12
- data/include/reflex/ruby.h +3 -2
- data/include/reflex/view.h +103 -0
- data/include/reflex/window.h +43 -18
- data/include/reflex.h +2 -1
- data/lib/reflex/application.rb +8 -7
- data/lib/reflex/autoinit.rb +1 -1
- data/lib/reflex/bitmap.rb +13 -0
- data/lib/reflex/bounds.rb +2 -122
- data/lib/reflex/ext.rb +5 -0
- data/lib/reflex/helpers.rb +36 -31
- data/lib/reflex/image.rb +13 -0
- data/lib/reflex/module.rb +9 -2
- data/lib/reflex/painter.rb +13 -0
- data/lib/reflex/point.rb +3 -59
- data/lib/reflex/reflex.rb +1 -1
- data/lib/reflex/texture.rb +13 -0
- data/lib/reflex/view.rb +33 -0
- data/lib/reflex/visuals/string.rb +53 -0
- data/lib/reflex/window.rb +18 -43
- data/lib/reflex.rb +3 -3
- data/reflex.gemspec +16 -42
- data/src/cocoa/application.mm +17 -23
- data/src/cocoa/applicationdata.h +3 -9
- data/src/cocoa/cocoaapplication.h +6 -4
- data/src/cocoa/cocoaapplication.mm +61 -19
- data/src/cocoa/cocoawindow.h +7 -5
- data/src/cocoa/cocoawindow.mm +109 -50
- data/src/cocoa/defs.mm +5 -2
- data/src/cocoa/window.mm +71 -41
- data/src/cocoa/windowdata.h +14 -9
- data/src/defs.cpp +1 -1
- data/src/exception.cpp +3 -18
- data/src/helpers.h +12 -0
- data/src/reflex.cpp +11 -5
- data/src/view.cpp +326 -0
- data/src/win32/application.cpp +7 -8
- data/src/win32/defs.h +1 -1
- data/src/win32/window.cpp +137 -41
- data/src/window.cpp +38 -1
- data/test/helpers.rb +2 -5
- data/test/test_application.rb +17 -0
- data/test/test_reflex.rb +4 -2
- data/test/test_view.rb +74 -0
- data/test/test_window.rb +33 -2
- metadata +157 -97
- data/include/reflex/helpers.h +0 -32
- data/test/test_bounds.rb +0 -163
- 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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
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:
|
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
|
-
|
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:
|
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
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
57
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version:
|
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
|
-
|
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:
|
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
|
-
|
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:
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
68
102
|
type: :development
|
69
|
-
|
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
|
-
-
|
125
|
+
files:
|
126
|
+
- .gitignore
|
86
127
|
- ChangeLog
|
128
|
+
- README
|
87
129
|
- Rakefile
|
88
|
-
- reflex.gemspec
|
89
130
|
- VERSION
|
90
|
-
-
|
91
|
-
-
|
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/
|
166
|
+
- include/reflex/view.h
|
109
167
|
- include/reflex/window.h
|
110
|
-
-
|
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
|
-
-
|
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/
|
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
|
-
|
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:
|
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.
|
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/
|
194
|
-
- test/
|
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
|
data/include/reflex/helpers.h
DELETED
@@ -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
|