ruby-oci8 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/ChangeLog +569 -0
  2. data/Makefile +51 -0
  3. data/NEWS +322 -0
  4. data/README +415 -0
  5. data/VERSION +1 -0
  6. data/dist-files +70 -0
  7. data/doc/api.en.html +527 -0
  8. data/doc/api.en.rd +554 -0
  9. data/doc/api.ja.html +525 -0
  10. data/doc/api.ja.rd +557 -0
  11. data/doc/manual.css +35 -0
  12. data/ext/oci8/MANIFEST +22 -0
  13. data/ext/oci8/attr.c +415 -0
  14. data/ext/oci8/bind.c +194 -0
  15. data/ext/oci8/const.c +165 -0
  16. data/ext/oci8/define.c +53 -0
  17. data/ext/oci8/describe.c +81 -0
  18. data/ext/oci8/descriptor.c +39 -0
  19. data/ext/oci8/env.c +276 -0
  20. data/ext/oci8/error.c +234 -0
  21. data/ext/oci8/extconf.rb +118 -0
  22. data/ext/oci8/handle.c +262 -0
  23. data/ext/oci8/lob.c +386 -0
  24. data/ext/oci8/oci8.c +137 -0
  25. data/ext/oci8/oci8.h +345 -0
  26. data/ext/oci8/ocinumber.c +117 -0
  27. data/ext/oci8/oraconf.rb +1026 -0
  28. data/ext/oci8/oradate.c +426 -0
  29. data/ext/oci8/oranumber.c +445 -0
  30. data/ext/oci8/param.c +37 -0
  31. data/ext/oci8/post-config.rb +5 -0
  32. data/ext/oci8/server.c +182 -0
  33. data/ext/oci8/session.c +99 -0
  34. data/ext/oci8/stmt.c +624 -0
  35. data/ext/oci8/svcctx.c +229 -0
  36. data/lib/DBD/OCI8/OCI8.rb +549 -0
  37. data/lib/oci8.rb.in +1605 -0
  38. data/metaconfig +142 -0
  39. data/pre-distclean.rb +7 -0
  40. data/ruby-oci8.gemspec +54 -0
  41. data/ruby-oci8.spec +62 -0
  42. data/setup.rb +1331 -0
  43. data/support/README +4 -0
  44. data/support/runit/assert.rb +281 -0
  45. data/support/runit/cui/testrunner.rb +101 -0
  46. data/support/runit/error.rb +4 -0
  47. data/support/runit/method_mappable.rb +20 -0
  48. data/support/runit/robserver.rb +25 -0
  49. data/support/runit/setuppable.rb +15 -0
  50. data/support/runit/teardownable.rb +16 -0
  51. data/support/runit/testcase.rb +113 -0
  52. data/support/runit/testfailure.rb +25 -0
  53. data/support/runit/testresult.rb +121 -0
  54. data/support/runit/testsuite.rb +43 -0
  55. data/support/runit/version.rb +3 -0
  56. data/test/README +4 -0
  57. data/test/config.rb +129 -0
  58. data/test/test_all.rb +43 -0
  59. data/test/test_bind_raw.rb +53 -0
  60. data/test/test_bind_time.rb +191 -0
  61. data/test/test_break.rb +81 -0
  62. data/test/test_clob.rb +101 -0
  63. data/test/test_connstr.rb +80 -0
  64. data/test/test_dbi.rb +317 -0
  65. data/test/test_dbi_clob.rb +56 -0
  66. data/test/test_describe.rb +137 -0
  67. data/test/test_metadata.rb +243 -0
  68. data/test/test_oci8.rb +273 -0
  69. data/test/test_oradate.rb +263 -0
  70. data/test/test_oranumber.rb +149 -0
  71. metadata +118 -0
@@ -0,0 +1,4 @@
1
+ This directory includes support files to run unit test.
2
+
3
+ runit : minimum files which are copyed from RubyUnit 0.5.2.
4
+ http://homepage1.nifty.com/markey/ruby/rubyunit/index_e.html
@@ -0,0 +1,281 @@
1
+ require 'runit/version'
2
+ require 'runit/error'
3
+
4
+ module RUNIT
5
+ module Assert
6
+ @@run_asserts = 0
7
+ @@skip_failure = false
8
+
9
+ def Assert.skip_failure=(arg)
10
+ @@skip_failure = arg
11
+ end
12
+
13
+ def Assert.skip_failure?
14
+ @@skip_failure
15
+ end
16
+
17
+ def Assert.run_asserts
18
+ @@run_asserts
19
+ end
20
+
21
+ def edit_message(msg)
22
+ (msg != "")? msg + " " : msg
23
+ end
24
+ private :edit_message
25
+
26
+ def build_message(msg, *args, &proc)
27
+ str_args = args.collect {|arg|
28
+ to_string(arg)
29
+ }
30
+ if block_given?
31
+ edit_message(msg).concat proc.call(*str_args)
32
+ else
33
+ msg
34
+ end
35
+ end
36
+ private :build_message
37
+
38
+ def to_string(obj)
39
+ case obj
40
+ when Symbol
41
+ obj.id2name
42
+ when String
43
+ obj
44
+ else
45
+ obj.inspect
46
+ end
47
+ end
48
+ private :to_string
49
+
50
+ def float_to_str(f, e)
51
+ return f.to_s if e == 0
52
+ i = 0
53
+ while 1 > e
54
+ i += 1
55
+ e *= 10
56
+ end
57
+ i += 1
58
+ sprintf("%.#{i}f", f)
59
+ end
60
+ private :float_to_str
61
+
62
+ def raise_assertion_error(message)
63
+ if Assert.skip_failure?
64
+ changed
65
+ err = AssertionFailedError.new(message)
66
+ err.set_backtrace(caller)
67
+ notify_observers(RObserver::ADD_FAILURE, caller, err, type)
68
+ else
69
+ raise AssertionFailedError, message
70
+ end
71
+ end
72
+ private :raise_assertion_error
73
+
74
+ def setup_assert
75
+ @@run_asserts += 1
76
+ end
77
+
78
+ def assert(condition, message="")
79
+ setup_assert
80
+ if !condition.instance_of?(TrueClass) && !condition.instance_of?(FalseClass)
81
+ raise TypeError, "1st argument <#{condition}> type should be TrueClass or FalseClass."
82
+ end
83
+ if !condition
84
+ msg = build_message(message, condition) {|arg|
85
+ "The condition is <#{arg}:#{condition.type.inspect}>"
86
+ }
87
+ raise_assertion_error(msg)
88
+ end
89
+ end
90
+
91
+ def assert_equal(expected, actual, message="")
92
+ setup_assert
93
+ if expected != actual
94
+ msg = build_message(message, expected, actual) {|arg1, arg2|
95
+ "expected:<#{arg1}> but was:<#{arg2}>"
96
+ }
97
+ raise_assertion_error(msg)
98
+ end
99
+ end
100
+ alias assert_equals assert_equal
101
+
102
+ def assert_operator(obj1, op, obj2, message="")
103
+ setup_assert
104
+ if !obj1.send(op, obj2)
105
+ msg = build_message(message, obj1, obj2) {|arg1, arg2|
106
+ "The condition is not satisfied: #{arg1} #{op.to_s} #{arg2}"
107
+ }
108
+ raise_assertion_error(msg)
109
+ end
110
+ end
111
+
112
+ def assert_equal_float(expected, actual, e, message="")
113
+ setup_assert
114
+ if e < 0.0
115
+ raise ArgumentError, "#{e}: 3rd argument should be 0 or greater than 0."
116
+ end
117
+ if (expected - actual).abs > e
118
+ msg = build_message(message) {
119
+ "expected:<#{float_to_str(expected, e)}> but was:<#{float_to_str(actual, e)}>"
120
+ }
121
+ raise_assertion_error(msg)
122
+ end
123
+ end
124
+
125
+ def assert_same(expected, actual, message="")
126
+ setup_assert
127
+ if !actual.equal?(expected)
128
+ msg = build_message(message, actual, expected) {|arg1, arg2|
129
+ "<#{arg1}:#{actual.type.inspect}> is not same object: <#{arg2}:#{expected.type.inspect}>"
130
+ }
131
+ raise_assertion_error(msg)
132
+ end
133
+ end
134
+
135
+ def assert_send(obj, method, *args)
136
+ setup_assert
137
+ if !obj.send(method, *args)
138
+ msg = "Assertion failed: #{obj.type.inspect}(#{obj.inspect})##{to_string(method)}"
139
+ if args.size > 0
140
+ strargs = args.collect {|arg|
141
+ "<#{to_string(arg).inspect}:#{arg.type.inspect}>"
142
+ }.join(", ")
143
+ msg.concat "(#{strargs})"
144
+ end
145
+ raise_assertion_error(msg)
146
+ end
147
+ end
148
+
149
+ def assert_nil(obj, message="")
150
+ setup_assert
151
+ if !obj.nil?
152
+ msg = build_message(message, obj) {|arg|
153
+ "<#{arg}:#{obj.type.inspect}> is not nil"
154
+ }
155
+ raise_assertion_error(msg)
156
+ end
157
+ end
158
+
159
+ def assert_not_nil(obj, message="")
160
+ setup_assert
161
+ if obj.nil?
162
+ msg = build_message(message) {
163
+ "object is nil"
164
+ }
165
+ raise_assertion_error(msg)
166
+ end
167
+ end
168
+
169
+ def assert_respond_to(method, obj, message="")
170
+ setup_assert
171
+ if !obj.respond_to?(method)
172
+ msg = build_message(message, obj, method) {|arg1, arg2|
173
+ "<#{arg1}:#{obj.type.inspect}> does not respond to <#{arg2}>"
174
+ }
175
+ raise_assertion_error(msg)
176
+ end
177
+ end
178
+
179
+ def assert_kind_of(c, obj, message="")
180
+ setup_assert
181
+ if !obj.kind_of?(c)
182
+ msg = build_message(message, obj, c) {|arg1, arg2|
183
+ "<#{arg1}:#{obj.type.inspect}> is not kind of <#{arg2}>"
184
+ }
185
+ raise_assertion_error(msg)
186
+ end
187
+ end
188
+
189
+ def assert_instance_of(c, obj, message="")
190
+ setup_assert
191
+ if !obj.instance_of?(c)
192
+ msg = build_message(message, obj, c) {|arg1, arg2|
193
+ "<#{arg1}:#{obj.type.inspect}> is not instance of <#{arg2}>"
194
+ }
195
+ raise_assertion_error(msg)
196
+ end
197
+ end
198
+
199
+ def assert_match(str, re, message="")
200
+ setup_assert
201
+ if re !~ str
202
+ msg = build_message(message, re, str) {|arg1, arg2|
203
+ "<#{arg1}> not match <#{arg2}>"
204
+ }
205
+ raise_assertion_error(msg)
206
+ end
207
+ return Regexp.last_match
208
+ end
209
+ alias assert_matches assert_match
210
+
211
+ def assert_not_match(str, re, message="")
212
+ setup_assert
213
+ if re =~ str
214
+ match = Regexp.last_match
215
+ msg = build_message(message, re, str) {|arg1, arg2|
216
+ "<#{arg1}> matches '#{match[0]}' of <#{arg2}>"
217
+ }
218
+ raise_assertion_error(msg)
219
+ end
220
+ end
221
+
222
+ def assert_exception(exception, message="")
223
+ setup_assert
224
+ exception_raised = true
225
+ err = ""
226
+ ret = nil
227
+ begin
228
+ yield
229
+ exception_raised = false
230
+ err = 'NO EXCEPTION RAISED'
231
+ rescue Exception
232
+ if $!.instance_of?(exception)
233
+ exception_raised = true
234
+ ret = $!
235
+ else
236
+ exception_raised = false
237
+ err = $!.type
238
+ end
239
+ end
240
+ if !exception_raised
241
+ msg = build_message(message, exception, err) {|arg1, arg2|
242
+ "expected:<#{arg1}> but was:<#{arg2}>"
243
+ }
244
+ raise_assertion_error(msg)
245
+ end
246
+ ret
247
+ end
248
+
249
+ def assert_no_exception(*arg)
250
+ setup_assert
251
+ message = ""
252
+ if arg[arg.size-1].instance_of?(String)
253
+ message = arg.pop
254
+ end
255
+ err = nil
256
+ exception_raised = false
257
+ begin
258
+ yield
259
+ rescue Exception
260
+ if arg.include?($!.type) || arg.size == 0
261
+ exception_raised = true
262
+ err = $!
263
+ else
264
+ raise $!.type, $!.message, $!.backtrace
265
+ end
266
+ end
267
+ if exception_raised
268
+ msg = build_message(message, err) {|arg|
269
+ "Exception raised:#{arg}"
270
+ }
271
+ raise_assertion_error(msg)
272
+ end
273
+ end
274
+
275
+ def assert_fail(message)
276
+ setup_assert
277
+ raise_assertion_error message
278
+ end
279
+
280
+ end
281
+ end
@@ -0,0 +1,101 @@
1
+ require 'runit/testresult'
2
+ require 'runit/robserver'
3
+
4
+ module RUNIT
5
+ module CUI
6
+ class TestRunner
7
+ include RObserver
8
+ @@quiet_mode = false
9
+ def initialize(io=STDERR, wait=false)
10
+ @io = io
11
+ @wait = wait
12
+ end
13
+
14
+ def TestRunner.quiet_mode=(flag)
15
+ @@quiet_mode = flag
16
+ end
17
+
18
+ def TestRunner.run(test, io=STDERR, wait = false)
19
+ r = TestRunner.new(io, wait)
20
+ r.run(test)
21
+ end
22
+
23
+ def run(test)
24
+ result = RUNIT::TestResult.new
25
+ result.add_observer(self)
26
+ test.run(result)
27
+ print_running_time(result.running_time)
28
+ print_result(result, test.count_test_cases)
29
+ print_waiting_message
30
+ result
31
+ end
32
+
33
+ def print_waiting_message
34
+ if @wait
35
+ STDERR.print "<RETURN> to Continue "
36
+ STDIN.gets
37
+ end
38
+ end
39
+
40
+ def print_running_time(rtm)
41
+ @io.print "\nTime: #{rtm}\n"
42
+ end
43
+
44
+ def start_test(t)
45
+ @io.print "\n", t.name , " " if !@@quiet_mode
46
+ end
47
+
48
+ def add_failure(at, err)
49
+ @io.print("F")
50
+ end
51
+
52
+ def add_error(at, err)
53
+ @io.print("E")
54
+ end
55
+
56
+ def end_test(t)
57
+ @io.print(".")
58
+ end
59
+
60
+ def print_result(result, count)
61
+ print_header(result, count)
62
+ print_failures(result)
63
+ print_errors(result)
64
+ end
65
+
66
+ def print_header(result, count)
67
+ if result.succeed?
68
+ @io.puts "OK (#{result.run_tests}/#{count} tests #{result.run_asserts} asserts)"
69
+ else
70
+ @io.puts "FAILURES!!!"
71
+ @io.puts "Test Results:"
72
+ @io.print " Run: #{result.run_tests}/#{count}(#{result.run_asserts} asserts)"
73
+ @io.print " Failures: #{result.failure_size}"
74
+ @io.puts " Errors: #{result.error_size}"
75
+ end
76
+ end
77
+
78
+ def print_failures(result)
79
+ @io.puts "Failures: #{result.failure_size}" if result.failure_size > 0
80
+ result.failures.each do |f|
81
+ @io.print f.at[0], ": ", f.err, " (", f.err.class, ")\n"
82
+ for at in f.at[1..-1]
83
+ @io.print "\tfrom ", at, "\n"
84
+ end
85
+ end
86
+ end
87
+
88
+ def print_errors(result)
89
+ @io.puts "Errors: #{result.error_size}" if result.error_size > 0
90
+ result.errors.each do |e|
91
+ @io.print e.at[0], ": ", e.err, " (", e.err.class, ")\n"
92
+ for at in e.at[1..-1]
93
+ @io.print "\tfrom ", at, "\n"
94
+ end
95
+ end
96
+ end
97
+
98
+ end
99
+ end
100
+ end
101
+
@@ -0,0 +1,4 @@
1
+ module RUNIT
2
+ class AssertionFailedError < StandardError
3
+ end
4
+ end
@@ -0,0 +1,20 @@
1
+ module RUNIT
2
+ module MethodMappable
3
+ def attach_method(hash, method, *methods)
4
+ methods.each do |m|
5
+ hash[self.to_s + m.to_s] = method
6
+ end
7
+ end
8
+ private :attach_method
9
+
10
+ def invoke_method(hash, m)
11
+ if hash[self.to_s + m.to_s]
12
+ send hash[self.to_s + m.to_s]
13
+ elsif hash[self.class.to_s + m.to_s]
14
+ send hash[self.class.to_s + m.to_s]
15
+ end
16
+ end
17
+ private :invoke_method
18
+ end
19
+ end
20
+
@@ -0,0 +1,25 @@
1
+ module RUNIT
2
+ module RObserver
3
+ ADD_ERROR = :add_error
4
+ ADD_FAILURE = :add_failure
5
+ START_TEST = :start_test
6
+ END_TEST = :end_test
7
+
8
+ def add_error(*arg)
9
+ end
10
+
11
+ def add_failure(*arg)
12
+ end
13
+
14
+ def start_test(*arg)
15
+ end
16
+
17
+ def end_test(*arg)
18
+ end
19
+
20
+ def update(ev, *arg)
21
+ send(ev, *arg)
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ require 'runit/method_mappable'
2
+ module RUNIT
3
+ module Setuppable
4
+ include MethodMappable
5
+ @@setups = {}
6
+ def attach_setup(setup_method, *methods)
7
+ attach_method(@@setups, setup_method, *methods)
8
+ end
9
+ private :attach_setup
10
+ def invoke_setup(m)
11
+ invoke_method(@@setups, m)
12
+ end
13
+ private :invoke_setup
14
+ end
15
+ end