rays 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/rays/bitmap.cpp +76 -53
  2. data/.doc/ext/rays/font.cpp +31 -27
  3. data/.doc/ext/rays/image.cpp +44 -37
  4. data/.doc/ext/rays/native.cpp +6 -0
  5. data/.doc/ext/rays/painter.cpp +276 -160
  6. data/.doc/ext/rays/rays.cpp +8 -9
  7. data/.doc/ext/rays/texture.cpp +50 -28
  8. data/.gitignore +14 -0
  9. data/Rakefile +5 -30
  10. data/VERSION +1 -1
  11. data/ext/rays/bitmap.cpp +77 -53
  12. data/ext/rays/bounds.cpp +426 -0
  13. data/ext/rays/color.cpp +199 -0
  14. data/ext/rays/defs.h +1 -18
  15. data/ext/rays/extconf.rb +10 -8
  16. data/ext/rays/font.cpp +31 -27
  17. data/ext/rays/image.cpp +44 -37
  18. data/ext/rays/matrix.cpp +154 -0
  19. data/ext/rays/native.cpp +6 -0
  20. data/ext/rays/painter.cpp +288 -163
  21. data/ext/rays/point.cpp +175 -0
  22. data/ext/rays/rays.cpp +8 -9
  23. data/ext/rays/texture.cpp +52 -28
  24. data/include/rays.h +1 -2
  25. data/include/rays/bitmap.h +5 -3
  26. data/include/rays/bounds.h +94 -0
  27. data/include/rays/color.h +53 -0
  28. data/include/rays/colorspace.h +2 -2
  29. data/include/rays/exception.h +1 -1
  30. data/include/rays/font.h +7 -3
  31. data/include/rays/image.h +6 -2
  32. data/include/rays/matrix.h +63 -0
  33. data/include/rays/opengl.h +1 -1
  34. data/include/rays/painter.h +138 -39
  35. data/include/rays/point.h +39 -0
  36. data/include/rays/ruby.h +3 -0
  37. data/include/rays/ruby/bitmap.h +5 -3
  38. data/include/rays/ruby/bounds.h +41 -0
  39. data/include/rays/ruby/color.h +41 -0
  40. data/include/rays/ruby/font.h +5 -3
  41. data/include/rays/ruby/image.h +5 -3
  42. data/include/rays/ruby/matrix.h +41 -0
  43. data/include/rays/ruby/painter.h +5 -3
  44. data/include/rays/ruby/point.h +41 -0
  45. data/include/rays/ruby/texture.h +5 -3
  46. data/include/rays/texture.h +6 -2
  47. data/lib/rays.rb +3 -0
  48. data/lib/rays/autoinit.rb +1 -1
  49. data/lib/rays/bitmap.rb +15 -1
  50. data/lib/rays/bounds.rb +138 -0
  51. data/lib/rays/color.rb +52 -0
  52. data/lib/rays/ext.rb +4 -0
  53. data/lib/rays/image.rb +1 -1
  54. data/lib/rays/module.rb +9 -2
  55. data/lib/rays/painter.rb +40 -41
  56. data/lib/rays/point.rb +82 -0
  57. data/lib/rays/texture.rb +1 -1
  58. data/rays.gemspec +16 -37
  59. data/src/bounds.cpp +234 -0
  60. data/src/cocoa/bitmap.mm +4 -4
  61. data/src/cocoa/font.mm +35 -30
  62. data/src/cocoa/rays.mm +2 -0
  63. data/src/color.cpp +77 -0
  64. data/src/colorspace.cpp +3 -3
  65. data/src/exception.cpp +3 -18
  66. data/src/image.cpp +9 -2
  67. data/src/matrix.cpp +103 -0
  68. data/src/painter.cpp +475 -224
  69. data/src/point.cpp +52 -0
  70. data/src/texture.cpp +14 -2
  71. data/src/win32/bitmap.cpp +2 -2
  72. data/src/win32/gdi.cpp +22 -13
  73. data/src/win32/gdi.h +7 -7
  74. data/test/helpers.rb +1 -5
  75. data/test/test_bitmap.rb +9 -0
  76. data/test/test_bounds.rb +246 -0
  77. data/test/test_color.rb +88 -0
  78. data/test/test_font.rb +28 -0
  79. data/test/test_image.rb +9 -0
  80. data/test/test_painter.rb +1 -3
  81. data/test/test_point.rb +121 -0
  82. data/test/test_rays.rb +2 -3
  83. data/test/test_texture.rb +1 -3
  84. metadata +146 -75
  85. data/include/rays/helpers.h +0 -37
  86. data/include/rays/transform.h +0 -35
  87. data/src/helpers.cpp +0 -22
  88. data/src/transform.cpp +0 -88
data/src/point.cpp ADDED
@@ -0,0 +1,52 @@
1
+ #include "rays/point.h"
2
+
3
+
4
+ namespace Rays
5
+ {
6
+
7
+
8
+ Point::Point (coord value)
9
+ {
10
+ set(value);
11
+ }
12
+
13
+ Point::Point (coord x, coord y, coord z)
14
+ {
15
+ set(x, y, z);
16
+ }
17
+
18
+ Point
19
+ Point::dup () const
20
+ {
21
+ return *this;
22
+ }
23
+
24
+ Point&
25
+ Point::set (coord value)
26
+ {
27
+ return set(value, value, 0);
28
+ }
29
+
30
+ Point&
31
+ Point::set (coord x, coord y, coord z)
32
+ {
33
+ this->x = x;
34
+ this->y = y;
35
+ this->z = z;
36
+ return *this;
37
+ }
38
+
39
+ coord*
40
+ Point::array ()
41
+ {
42
+ return (coord*) this;
43
+ }
44
+
45
+ const coord*
46
+ Point::array () const
47
+ {
48
+ return const_cast<Point*>(this)->array();
49
+ }
50
+
51
+
52
+ }// Rays
data/src/texture.cpp CHANGED
@@ -329,16 +329,28 @@ namespace Rays
329
329
  return self->height;
330
330
  }
331
331
 
332
+ float
333
+ Texture::s (float x) const
334
+ {
335
+ return x / (float) self->bitmap.width();
336
+ }
337
+
338
+ float
339
+ Texture::t (float y) const
340
+ {
341
+ return y / (float) self->bitmap.height();
342
+ }
343
+
332
344
  float
333
345
  Texture::s_max () const
334
346
  {
335
- return (float) self->width / (float) self->bitmap.width();
347
+ return s(self->width);
336
348
  }
337
349
 
338
350
  float
339
351
  Texture::t_max () const
340
352
  {
341
- return (float) self->height / (float) self->bitmap.height();
353
+ return t(self->height);
342
354
  }
343
355
 
344
356
  const Bitmap&
data/src/win32/bitmap.cpp CHANGED
@@ -77,7 +77,7 @@ namespace Rays
77
77
  BITMAPINFOHEADER& header = bmpinfo.bmiHeader;
78
78
  header.biSize = sizeof(BITMAPINFOHEADER);
79
79
  header.biWidth = self->width;
80
- header.biHeight = self->height;
80
+ header.biHeight = -self->height;
81
81
  header.biPlanes = 1;
82
82
  header.biBitCount = self->colorspace.bpp();
83
83
  header.biCompression = BI_RGB;
@@ -159,7 +159,7 @@ namespace Rays
159
159
  const void*
160
160
  Bitmap::data () const
161
161
  {
162
- return const_cast<Bitmap*>(this)->data();
162
+ return const_cast<This*>(this)->data();
163
163
  }
164
164
 
165
165
  Bitmap::operator bool () const
data/src/win32/gdi.cpp CHANGED
@@ -266,18 +266,19 @@ namespace Rays
266
266
  calc_size (
267
267
  coord* width, coord* height, HDC hdc, const char* str)
268
268
  {
269
- if ((!width && !height) || !hdc || !str) return false;
269
+ if (!width || !height || !hdc || !str) return false;
270
+
271
+ bool empty = *str == '\0';
272
+ if (empty) str = " ";
270
273
 
271
274
  RECT rect = {0, 0, 0, 0};
272
- BOOL ret = DrawTextA(
273
- hdc, str, (int) strlen(str), &rect,
275
+ int ret = DrawTextA(
276
+ hdc, str, -1, &rect,
274
277
  DT_EXPANDTABS | DT_NOPREFIX | DT_CALCRECT);
275
-
276
278
  if (!ret) return false;
277
279
 
278
- if (width) *width = rect.right - rect.left;
279
- if (height) *height = rect.bottom - rect.top;
280
-
280
+ *width = empty ? 0 : rect.right - rect.left;
281
+ *height = rect.bottom - rect.top;
281
282
  return true;
282
283
  }
283
284
 
@@ -285,17 +286,25 @@ namespace Rays
285
286
  Font::get_extent (
286
287
  coord* width, coord* height, const char* str, HDC hdc)
287
288
  {
288
- if (!*this || (!width && !height) || !str)
289
+ if (!*this || (!width && !height))
289
290
  return false;
290
291
 
292
+ if (width) *width = 0;
293
+ if (height) *height = 0;
294
+
291
295
  DC dc = hdc ? DC(hdc) : screen_dc();
292
296
  if (!dc) return false;
293
297
 
298
+ coord w = 0, h = 0;
299
+
294
300
  Font old = dc.font();
295
301
  dc.set_font(*this);
296
- bool ret = calc_size(width, height, dc.handle(), str);
302
+ bool ret = calc_size(&w, &h, dc.handle(), str);
297
303
  dc.set_font(old);
298
304
 
305
+ if (width) *width = w;
306
+ if (height) *height = h;
307
+
299
308
  return ret;
300
309
  }
301
310
 
@@ -427,19 +436,19 @@ namespace Rays
427
436
 
428
437
  HPEN hpen;
429
438
 
430
- Pen pen;
439
+ Pen pen;
431
440
 
432
441
  HBRUSH hbrush;
433
442
 
434
- Brush brush;
443
+ Brush brush;
435
444
 
436
445
  HFONT hfont;
437
446
 
438
- Font font;
447
+ Font font;
439
448
 
440
449
  HBITMAP hbitmap;
441
450
 
442
- Bitmap bitmap;
451
+ Bitmap bitmap;
443
452
 
444
453
  COLORREF textcolor, backcolor;
445
454
 
data/src/win32/gdi.h CHANGED
@@ -5,8 +5,8 @@
5
5
 
6
6
 
7
7
  #include <windows.h>
8
+ #include <xot/pimpl.h>
8
9
  #include <rays/defs.h>
9
- #include <rays/helpers.h>
10
10
 
11
11
 
12
12
  namespace Rays
@@ -38,7 +38,7 @@ namespace Rays
38
38
 
39
39
  struct Data;
40
40
 
41
- Impl<Data> self;
41
+ Xot::PImpl<Data, true> self;
42
42
 
43
43
  };// Pen
44
44
 
@@ -64,7 +64,7 @@ namespace Rays
64
64
 
65
65
  struct Data;
66
66
 
67
- Impl<Data> self;
67
+ Xot::PImpl<Data, true> self;
68
68
 
69
69
  };// Brush
70
70
 
@@ -95,7 +95,7 @@ namespace Rays
95
95
 
96
96
  struct Data;
97
97
 
98
- Impl<Data> self;
98
+ Xot::PImpl<Data, true> self;
99
99
 
100
100
  };// Font
101
101
 
@@ -123,7 +123,7 @@ namespace Rays
123
123
 
124
124
  struct Data;
125
125
 
126
- Impl<Data> self;
126
+ Xot::PImpl<Data, true> self;
127
127
 
128
128
  };// Bitmap
129
129
 
@@ -181,7 +181,7 @@ namespace Rays
181
181
 
182
182
  struct Data;
183
183
 
184
- Impl<Data> self;
184
+ Xot::PImpl<Data, true> self;
185
185
 
186
186
  };// DC
187
187
 
@@ -209,7 +209,7 @@ namespace Rays
209
209
 
210
210
  struct Data;
211
211
 
212
- Impl<Data> self;
212
+ Xot::PImpl<Data, true> self;
213
213
 
214
214
  };// MemoryDC
215
215
 
data/test/helpers.rb CHANGED
@@ -1,11 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
 
4
- %w[ext lib].each do |dir|
5
- paths = ["..", dir]
6
- $: << File.expand_path(File.join File.dirname(__FILE__), *paths)
7
- end
8
-
4
+ require 'bundler/setup'
9
5
  require 'test/unit'
10
6
  require 'rays'
11
7
 
@@ -0,0 +1,9 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ require_relative 'helpers'
5
+
6
+
7
+ class TestBitmap < Test::Unit::TestCase
8
+
9
+ end# TestBitmap
@@ -0,0 +1,246 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ require_relative 'helpers'
5
+
6
+
7
+ class TestBounds < Test::Unit::TestCase
8
+
9
+ def bounds (*args)
10
+ Rays::Bounds.new *args
11
+ end
12
+
13
+ def point (*args)
14
+ Rays::Point.new *args
15
+ end
16
+
17
+ def test_initialize ()
18
+ assert_equal bounds(0, 0, 0, 0, 0, 0), bounds()
19
+ assert_equal bounds(0, 0, 0, 1, 1, 0), bounds(1)
20
+ assert_equal bounds(0, 0, 0, 1, 2, 0), bounds(1, 2)
21
+ assert_equal bounds(0, 0, 0, 1, 2, 3), bounds(1, 2, 3)
22
+ assert_equal bounds(1, 2, 0, 3, 4, 0), bounds(1, 2, 3, 4)
23
+ assert_equal bounds(1, 2, 3, 4, 5, 6), bounds(1, 2, 3, 4, 5, 6)
24
+ assert_raise(ArgumentError) {bounds(1, 2, 3, 4, 5)}
25
+ assert_raise(ArgumentError) {bounds(1, 2, 3, 4, 5, 6, 7)}
26
+ end
27
+
28
+ def test_get_xyzwhd ()
29
+ o = bounds 1, 2, 3, 4, 5, 6
30
+ assert_equal 1, o.x
31
+ assert_equal 2, o.y
32
+ assert_equal 3, o.z
33
+ assert_equal 4, o.w
34
+ assert_equal 5, o.h
35
+ assert_equal 6, o.d
36
+ assert_equal 4, o.width
37
+ assert_equal 5, o.height
38
+ assert_equal 6, o.depth
39
+ end
40
+
41
+ def test_set_xyzwhd ()
42
+ o = bounds
43
+ o.x = 1
44
+ assert_equal [1, 0, 0, 0, 0, 0], o.to_a(3)
45
+ o.y = 2
46
+ assert_equal [1, 2, 0, 0, 0, 0], o.to_a(3)
47
+ o.z = 3
48
+ assert_equal [1, 2, 3, 0, 0, 0], o.to_a(3)
49
+ o.w = 4
50
+ assert_equal [1, 2, 3, 4, 0, 0], o.to_a(3)
51
+ o.h = 5
52
+ assert_equal [1, 2, 3, 4, 5, 0], o.to_a(3)
53
+ o.d = 6
54
+ assert_equal [1, 2, 3, 4, 5, 6], o.to_a(3)
55
+ o.width = 7
56
+ assert_equal [1, 2, 3, 7, 5, 6], o.to_a(3)
57
+ o.height = 8
58
+ assert_equal [1, 2, 3, 7, 8, 6], o.to_a(3)
59
+ o.depth = 9
60
+ assert_equal [1, 2, 3, 7, 8, 9], o.to_a(3)
61
+ end
62
+
63
+ def test_get_ltbrbf ()
64
+ o = bounds 1, 2, 3, 4, 5, 6
65
+ assert_equal 1, o.left
66
+ assert_equal 2, o.top
67
+ assert_equal 3, o.back
68
+ assert_equal 4, o.right
69
+ assert_equal 6, o.bottom
70
+ assert_equal 8, o.front
71
+ end
72
+
73
+ def test_set_ltbrbf ()
74
+ o = bounds
75
+ o.left = -1
76
+ assert_equal [-1, 0, 0, 1, 0, 0], o.to_a(3)
77
+ o.top = -2
78
+ assert_equal [-1, -2, 0, 1, 2, 0], o.to_a(3)
79
+ o.back = -3
80
+ assert_equal [-1, -2, -3, 1, 2, 3], o.to_a(3)
81
+ o.right = 11
82
+ assert_equal [-1, -2, -3, 13, 2, 3], o.to_a(3)
83
+ o.bottom = 22
84
+ assert_equal [-1, -2, -3, 13, 25, 3], o.to_a(3)
85
+ o.front = 33
86
+ assert_equal [-1, -2, -3, 13, 25, 37], o.to_a(3)
87
+ end
88
+
89
+ def test_position ()
90
+ o = bounds 1, 2, 3, 4, 5, 6
91
+ assert_equal [ 1, 2, 3], o.position.to_a(3)
92
+ o.position = point 7, 8, 9
93
+ assert_equal [ 7, 8, 9], o.position.to_a(3)
94
+ o.pos = point 10, 11, 12
95
+ assert_equal [10, 11, 12], o.position.to_a(3)
96
+ assert_equal [10, 11, 12], o.pos.to_a(3)
97
+ end
98
+
99
+ def test_size ()
100
+ o = bounds 1, 2, 3, 4, 5, 6
101
+ assert_equal point(4, 5, 6), o.size
102
+ o.size = point 7, 8, 9
103
+ assert_equal point(7, 8, 9), o.size
104
+ end
105
+
106
+ def test_move_to ()
107
+ o = bounds 1, 2, 3, 4, 5, 6
108
+ assert_equal bounds(7, 7, 3, 4, 5, 6), o.move_to(7)
109
+ assert_equal bounds(7, 8, 3, 4, 5, 6), o.move_to(7, 8)
110
+ assert_equal bounds(7, 8, 9, 4, 5, 6), o.move_to(7, 8, 9)
111
+ assert_raise(ArgumentError) {o.move_to()}
112
+ assert_raise(ArgumentError) {o.move_to(7, 8, 9, 10)}
113
+
114
+ o0 = o.dup
115
+ o1 = o0.move_to 7, 8, 9
116
+ assert_equal bounds(1, 2, 3, 4, 5, 6), o0
117
+ assert_equal bounds(7, 8, 9, 4, 5, 6), o1
118
+ o0.move_to! 10, 11, 12
119
+ assert_equal bounds(10, 11, 12, 4, 5, 6), o0
120
+ assert_equal bounds( 7, 8, 9, 4, 5, 6), o1
121
+ end
122
+
123
+ def test_move_by ()
124
+ o = bounds 1, 2, 3, 4, 5, 6
125
+ assert_equal bounds( 8, 9, 3, 4, 5, 6), o.move_by(7)
126
+ assert_equal bounds( 8, 10, 3, 4, 5, 6), o.move_by(7, 8)
127
+ assert_equal bounds( 8, 10, 12, 4, 5, 6), o.move_by(7, 8, 9)
128
+ assert_equal bounds(-6, -5, 3, 4, 5, 6), o.move_by(-7)
129
+ assert_equal bounds(-6, -6, 3, 4, 5, 6), o.move_by(-7, -8)
130
+ assert_equal bounds(-6, -6, -6, 4, 5, 6), o.move_by(-7, -8, -9)
131
+ assert_raise(ArgumentError) {o.move_by()}
132
+ assert_raise(ArgumentError) {o.move_by(7, 8, 9, 10)}
133
+
134
+ o0 = o.dup
135
+ o1 = o0.move_by 7, 8, 9
136
+ assert_equal bounds(1, 2, 3, 4, 5, 6), o0
137
+ assert_equal bounds(8, 10, 12, 4, 5, 6), o1
138
+ o0.move_by! 10, 11, 12
139
+ assert_equal bounds(11, 13, 15, 4, 5, 6), o0
140
+ assert_equal bounds( 8, 10, 12, 4, 5, 6), o1
141
+ end
142
+
143
+ def test_resize_to ()
144
+ o = bounds 1, 2, 3, 4, 5, 6
145
+ assert_equal bounds(1, 2, 3, 7, 7, 6), o.resize_to(7)
146
+ assert_equal bounds(1, 2, 3, 7, 8, 6), o.resize_to(7, 8)
147
+ assert_equal bounds(1, 2, 3, 7, 8, 9), o.resize_to(7, 8, 9)
148
+ assert_raise(ArgumentError) {o.resize_to()}
149
+ assert_raise(ArgumentError) {o.resize_to(7, 8, 9, 10)}
150
+
151
+ o0 = o.dup
152
+ o1 = o0.resize_to 7, 8, 9
153
+ assert_equal bounds(1, 2, 3, 4, 5, 6), o0
154
+ assert_equal bounds(1, 2, 3, 7, 8, 9), o1
155
+ o0.resize_to! 10, 11, 12
156
+ assert_equal bounds(1, 2, 3, 10, 11, 12), o0
157
+ assert_equal bounds(1, 2, 3, 7, 8, 9), o1
158
+ end
159
+
160
+ def test_resize_by ()
161
+ o = bounds 1, 2, 3, 4, 5, 6
162
+ assert_equal bounds(1, 2, 3, 11, 12, 6), o.resize_by(7)
163
+ assert_equal bounds(1, 2, 3, 11, 13, 6), o.resize_by(7, 8)
164
+ assert_equal bounds(1, 2, 3, 11, 13, 15), o.resize_by(7, 8, 9)
165
+ assert_equal bounds(1, 2, 3, -3, -2, 6), o.resize_by(-7)
166
+ assert_equal bounds(1, 2, 3, -3, -3, 6), o.resize_by(-7, -8)
167
+ assert_equal bounds(1, 2, 3, -3, -3, -3), o.resize_by(-7, -8, -9)
168
+ assert_raise(ArgumentError) {o.resize_by()}
169
+ assert_raise(ArgumentError) {o.resize_by(7, 8, 9, 10)}
170
+
171
+ o0 = o.dup
172
+ o1 = o0.resize_by 7, 8, 9
173
+ assert_equal bounds(1, 2, 3, 4, 5, 6), o0
174
+ assert_equal bounds(1, 2, 3, 11, 13, 15), o1
175
+ o0.resize_by! 10, 11, 12
176
+ assert_equal bounds(1, 2, 3, 14, 16, 18), o0
177
+ assert_equal bounds(1, 2, 3, 11, 13, 15), o1
178
+ end
179
+
180
+ def test_inset_by ()
181
+ o = bounds 1, 2, 3, 20, 30, 40
182
+ assert_equal bounds(8, 9, 3, 6, 16, 40), o.inset_by(7)
183
+ assert_equal bounds(8, 10, 3, 6, 14, 40), o.inset_by(7, 8)
184
+ assert_equal bounds(8, 10, 12, 6, 14, 22), o.inset_by(7, 8, 9)
185
+ assert_raise(ArgumentError) {o.inset_by()}
186
+ assert_raise(ArgumentError) {o.inset_by(7, 8, 9, 10)}
187
+
188
+ o0 = o.dup
189
+ o1 = o0.inset_by 7, 8, 9
190
+ assert_equal bounds(1, 2, 3, 20, 30, 40), o0
191
+ assert_equal bounds(8, 10, 12, 6, 14, 22), o1
192
+ o0.inset_by! 10, 11, 12
193
+ assert_equal bounds(11, 13, 15, 0, 8, 16), o0
194
+ assert_equal bounds( 8, 10, 12, 6, 14, 22), o1
195
+ end
196
+
197
+ def test_to_a ()
198
+ o = bounds 1, 2, 3, 4, 5, 6
199
+ assert_equal [1, 2, 4, 5], o.to_a
200
+ assert_equal [1, 4], o.to_a(1)
201
+ assert_equal [1, 2, 4, 5], o.to_a(2)
202
+ assert_equal [1, 2, 3, 4, 5, 6], o.to_a(3)
203
+ assert_raise(ArgumentError) {o.to_a(-1)}
204
+ assert_raise(ArgumentError) {o.to_a(0)}
205
+ assert_raise(ArgumentError) {o.to_a(4)}
206
+ end
207
+
208
+ def test_index ()
209
+ o = bounds 1, 2, 3, 4, 5, 6
210
+ assert_equal point(1, 2, 3), o[0]
211
+ assert_equal point(4, 6, 8), o[1]
212
+ assert_raise(IndexError) {o[-1]}
213
+ assert_raise(IndexError) {o[2]}
214
+ end
215
+
216
+ def test_index_assign ()
217
+ o = bounds 1, 2, 3, 4, 5, 6
218
+ o[0] = point 7, 8, 9
219
+ assert_equal bounds(7, 8, 9, -2, -1, 0), o
220
+ o[1] = point 10, 11, 12
221
+ assert_equal bounds(7, 8, 9, 4, 4, 4), o
222
+ assert_raise(IndexError) {o[-1]}
223
+ assert_raise(IndexError) {o[2]}
224
+ end
225
+
226
+ def test_compare ()
227
+ o = bounds 1, 2, 3, 4, 5, 6
228
+ assert o == bounds(1, 2, 3, 4, 5, 6)
229
+ assert !(o != bounds(1, 2, 3, 4, 5, 6))
230
+
231
+ assert o < bounds(2, 2, 3, 4, 5, 6)
232
+ assert o < bounds(1, 3, 3, 4, 5, 6)
233
+ assert o < bounds(1, 2, 4, 4, 5, 6)
234
+ assert o < bounds(1, 2, 3, 5, 5, 6)
235
+ assert o < bounds(1, 2, 3, 4, 6, 6)
236
+ assert o < bounds(1, 2, 3, 4, 5, 7)
237
+
238
+ assert o > bounds(0, 2, 3, 4, 5, 6)
239
+ assert o > bounds(1, 1, 3, 4, 5, 6)
240
+ assert o > bounds(1, 2, 2, 4, 5, 6)
241
+ assert o > bounds(1, 2, 3, 3, 5, 6)
242
+ assert o > bounds(1, 2, 3, 4, 4, 6)
243
+ assert o > bounds(1, 2, 3, 4, 5, 5)
244
+ end
245
+
246
+ end# TestBounds