glib2 0.90.7-x86-mingw32 → 0.90.8-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +68 -0
- data/ext/glib2/rbglib.c +51 -15
- data/ext/glib2/rbglib.h +10 -2
- data/ext/glib2/rbglib_bookmarkfile.c +37 -74
- data/ext/glib2/rbglib_completion.c +8 -16
- data/ext/glib2/rbglib_convert.c +8 -18
- data/ext/glib2/rbglib_error.c +2 -8
- data/ext/glib2/rbglib_i18n.c +1 -2
- data/ext/glib2/rbglib_iochannel.c +81 -127
- data/ext/glib2/rbglib_keyfile.c +38 -86
- data/ext/glib2/rbglib_maincontext.c +29 -64
- data/ext/glib2/rbglib_mainloop.c +4 -8
- data/ext/glib2/rbglib_messages.c +7 -17
- data/ext/glib2/rbglib_pollfd.c +7 -14
- data/ext/glib2/rbglib_shell.c +3 -6
- data/ext/glib2/rbglib_source.c +14 -28
- data/ext/glib2/rbglib_spawn.c +7 -14
- data/ext/glib2/rbglib_threads.c +2 -4
- data/ext/glib2/rbglib_timer.c +7 -14
- data/ext/glib2/rbglib_unicode.c +45 -16
- data/ext/glib2/rbglib_utils.c +25 -50
- data/ext/glib2/rbglib_win32.c +10 -17
- data/ext/glib2/rbgobj_boxed.c +9 -21
- data/ext/glib2/rbgobj_closure.c +5 -11
- data/ext/glib2/rbgobj_enums.c +1 -2
- data/ext/glib2/rbgobj_object.c +23 -59
- data/ext/glib2/rbgobj_param.c +7 -15
- data/ext/glib2/rbgobj_signal.c +25 -65
- data/ext/glib2/rbgobj_type.c +36 -81
- data/ext/glib2/rbgobj_typeinstance.c +3 -6
- data/ext/glib2/rbgobj_typeinterface.c +3 -6
- data/ext/glib2/rbgobj_typemodule.c +4 -8
- data/ext/glib2/rbgobj_typeplugin.c +2 -4
- data/ext/glib2/rbgobj_valuetypes.c +7 -15
- data/ext/glib2/rbgobject.c +8 -18
- data/ext/glib2/rbgobject.h +3 -0
- data/ext/glib2/rbgprivate.h +0 -1
- data/ext/glib2/rbgutil.c +3 -6
- data/lib/1.8/glib2.so +0 -0
- data/lib/1.9/glib2.so +0 -0
- data/lib/gnome2-raketask.rb +1 -0
- data/lib/mkmf-gnome2.rb +12 -9
- data/test-unit/History.txt +43 -1
- data/test-unit/Manifest.txt +1 -1
- data/test-unit/html/index.html +62 -24
- data/test-unit/html/index.html.ja +54 -25
- data/test-unit/html/test-unit.css +3 -3
- data/test-unit/lib/test/unit/assertions.rb +489 -36
- data/test-unit/lib/test/unit/autorunner.rb +40 -0
- data/test-unit/lib/test/unit/collector.rb +6 -4
- data/test-unit/lib/test/unit/collector/load.rb +48 -5
- data/test-unit/lib/test/unit/collector/xml.rb +250 -0
- data/test-unit/lib/test/unit/error.rb +4 -3
- data/test-unit/lib/test/unit/fixture.rb +12 -3
- data/test-unit/lib/test/unit/runner/xml.rb +15 -0
- data/test-unit/lib/test/unit/testcase.rb +48 -16
- data/test-unit/lib/test/unit/testresult.rb +6 -2
- data/test-unit/lib/test/unit/testsuite.rb +24 -2
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +65 -28
- data/test-unit/lib/test/unit/ui/testrunnermediator.rb +11 -2
- data/test-unit/lib/test/unit/ui/xml/testrunner.rb +224 -0
- data/test-unit/lib/test/unit/version.rb +1 -1
- data/test-unit/test/run-test.rb +7 -0
- data/test-unit/test/{test_assertions.rb → test-assertions.rb} +708 -77
- data/test-unit/test/test-fixture.rb +37 -0
- data/test-unit/test/test-testcase.rb +24 -7
- data/test-unit/test/test_testsuite.rb +19 -11
- data/test/test_iochannel.rb +9 -9
- data/test/test_unicode.rb +44 -31
- metadata +8 -5
@@ -33,9 +33,15 @@ module Test
|
|
33
33
|
Unit.run = true
|
34
34
|
|
35
35
|
result = create_result
|
36
|
-
|
36
|
+
finished_listener = result.add_listener(TestResult::FINISHED) do |*args|
|
37
|
+
notify_listeners(TestResult::FINISHED, *args)
|
38
|
+
end
|
39
|
+
changed_listener = result.add_listener(TestResult::CHANGED) do |*args|
|
37
40
|
notify_listeners(TestResult::CHANGED, *args)
|
38
41
|
end
|
42
|
+
pass_assertion_listener = result.add_listener(TestResult::PASS_ASSERTION) do |*args|
|
43
|
+
notify_listeners(TestResult::PASS_ASSERTION, *args)
|
44
|
+
end
|
39
45
|
fault_listener = result.add_listener(TestResult::FAULT) do |*args|
|
40
46
|
notify_listeners(TestResult::FAULT, *args)
|
41
47
|
end
|
@@ -51,7 +57,10 @@ module Test
|
|
51
57
|
ensure
|
52
58
|
elapsed_time = Time.now - start_time
|
53
59
|
result.remove_listener(TestResult::FAULT, fault_listener)
|
54
|
-
result.remove_listener(TestResult::CHANGED,
|
60
|
+
result.remove_listener(TestResult::CHANGED, changed_listener)
|
61
|
+
result.remove_listener(TestResult::FINISHED, finished_listener)
|
62
|
+
result.remove_listener(TestResult::PASS_ASSERTION,
|
63
|
+
pass_assertion_listener)
|
55
64
|
notify_listeners(FINISHED, elapsed_time)
|
56
65
|
end
|
57
66
|
|
@@ -0,0 +1,224 @@
|
|
1
|
+
#--
|
2
|
+
#
|
3
|
+
# Author:: Kouhei Sutou
|
4
|
+
# Copyright::
|
5
|
+
# * Copyright (c) 2011 Kouhei Sutou <kou@clear-code.com>
|
6
|
+
# License:: Ruby license.
|
7
|
+
|
8
|
+
require 'erb'
|
9
|
+
require 'time'
|
10
|
+
require 'test/unit/ui/testrunner'
|
11
|
+
require 'test/unit/ui/testrunnermediator'
|
12
|
+
|
13
|
+
module Test
|
14
|
+
module Unit
|
15
|
+
module UI
|
16
|
+
module XML
|
17
|
+
|
18
|
+
# Runs a Test::Unit::TestSuite and outputs XML.
|
19
|
+
class TestRunner < UI::TestRunner
|
20
|
+
include ERB::Util
|
21
|
+
|
22
|
+
# Creates a new TestRunner for running the passed
|
23
|
+
# suite. :output option specifies where runner
|
24
|
+
# output should go to; defaults to STDOUT.
|
25
|
+
def initialize(suite, options={})
|
26
|
+
super
|
27
|
+
@output = @options[:output] || STDOUT
|
28
|
+
if @options[:output_file_descriptor]
|
29
|
+
@output = IO.new(@options[:output_file_descriptor], "w")
|
30
|
+
end
|
31
|
+
@already_outputted = false
|
32
|
+
@indent = 0
|
33
|
+
@top_level = true
|
34
|
+
@current_test = nil
|
35
|
+
@current_test_suite = nil
|
36
|
+
@already_outputted = false
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def attach_to_mediator
|
41
|
+
@mediator.add_listener(TestResult::PASS_ASSERTION,
|
42
|
+
&method(:result_pass_assertion))
|
43
|
+
@mediator.add_listener(TestResult::FAULT,
|
44
|
+
&method(:result_fault))
|
45
|
+
@mediator.add_listener(TestRunnerMediator::STARTED,
|
46
|
+
&method(:started))
|
47
|
+
@mediator.add_listener(TestRunnerMediator::FINISHED,
|
48
|
+
&method(:finished))
|
49
|
+
@mediator.add_listener(TestCase::STARTED_OBJECT,
|
50
|
+
&method(:test_started))
|
51
|
+
@mediator.add_listener(TestCase::FINISHED_OBJECT,
|
52
|
+
&method(:test_finished))
|
53
|
+
@mediator.add_listener(TestSuite::STARTED_OBJECT,
|
54
|
+
&method(:test_suite_started))
|
55
|
+
@mediator.add_listener(TestSuite::FINISHED_OBJECT,
|
56
|
+
&method(:test_suite_finished))
|
57
|
+
end
|
58
|
+
|
59
|
+
def result_pass_assertion(result)
|
60
|
+
open_tag("pass-assertion") do
|
61
|
+
output_test(@current_test)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def result_fault(fault)
|
66
|
+
open_tag("test-result") do
|
67
|
+
open_tag("result") do
|
68
|
+
output_test_suite(@current_test_suite)
|
69
|
+
output_test(@current_test)
|
70
|
+
open_tag("backtrace") do
|
71
|
+
fault.location.each do |entry|
|
72
|
+
file, line, info = entry.split(/:/, 3)
|
73
|
+
open_tag("entry") do
|
74
|
+
add_content("file", file)
|
75
|
+
add_content("line", line)
|
76
|
+
add_content("info", info)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
if fault.respond_to?(:expected)
|
81
|
+
add_content("expected", fault.expected)
|
82
|
+
end
|
83
|
+
if fault.respond_to?(:actual)
|
84
|
+
add_content("actual", fault.actual)
|
85
|
+
end
|
86
|
+
add_content("detail", fault.message)
|
87
|
+
add_content("status", fault.label.downcase)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
@already_outputted = true if fault.critical?
|
91
|
+
end
|
92
|
+
|
93
|
+
def started(result)
|
94
|
+
@result = result
|
95
|
+
output_started
|
96
|
+
end
|
97
|
+
|
98
|
+
def output_started
|
99
|
+
open_tag("stream")
|
100
|
+
end
|
101
|
+
|
102
|
+
def finished(elapsed_time)
|
103
|
+
add_content("success", @result.passed?)
|
104
|
+
close_tag("stream")
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_started(test)
|
108
|
+
@already_outputted = false
|
109
|
+
@current_test = test
|
110
|
+
open_tag("start-test") do
|
111
|
+
output_test(test)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_finished(test)
|
116
|
+
unless @already_outputted
|
117
|
+
open_tag("test-result") do
|
118
|
+
output_test(test)
|
119
|
+
open_tag("result") do
|
120
|
+
output_test_suite(@current_test_suite)
|
121
|
+
output_test(test)
|
122
|
+
add_content("status", "success")
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
open_tag("complete-test") do
|
128
|
+
output_test(test)
|
129
|
+
add_content("success", test.passed?)
|
130
|
+
end
|
131
|
+
@current_test = nil
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_suite_started(suite)
|
135
|
+
@current_test_suite = suite
|
136
|
+
if suite.test_case.nil?
|
137
|
+
open_tag("ready-test-suite") do
|
138
|
+
add_content("n-tests", suite.size)
|
139
|
+
end
|
140
|
+
open_tag("start-test-suite") do
|
141
|
+
output_test_suite(suite)
|
142
|
+
end
|
143
|
+
else
|
144
|
+
open_tag("ready-test-case") do
|
145
|
+
output_test_suite(suite)
|
146
|
+
add_content("n-tests", suite.size)
|
147
|
+
end
|
148
|
+
open_tag("start-test-case") do
|
149
|
+
output_test_suite(suite)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_suite_finished(suite)
|
155
|
+
if suite.test_case.nil?
|
156
|
+
open_tag("complete-test-suite") do
|
157
|
+
output_test_suite(suite)
|
158
|
+
add_content("success", suite.passed?)
|
159
|
+
end
|
160
|
+
else
|
161
|
+
open_tag("complete-test-case") do
|
162
|
+
output_test_suite(suite)
|
163
|
+
add_content("success", suite.passed?)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
@current_test_suite = nil
|
167
|
+
end
|
168
|
+
|
169
|
+
def indent
|
170
|
+
" " * @indent
|
171
|
+
end
|
172
|
+
|
173
|
+
def open_tag(name)
|
174
|
+
@output.puts("#{indent}<#{name}>")
|
175
|
+
@indent += 2
|
176
|
+
if block_given?
|
177
|
+
yield
|
178
|
+
close_tag(name)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def add_content(name, content)
|
183
|
+
return if content.nil?
|
184
|
+
case content
|
185
|
+
when Time
|
186
|
+
content = content.iso8601
|
187
|
+
end
|
188
|
+
@output.puts("#{indent}<#{name}>#{h(content)}</#{name}>")
|
189
|
+
end
|
190
|
+
|
191
|
+
def close_tag(name)
|
192
|
+
@indent -= 2
|
193
|
+
@output.puts("#{indent}</#{name}>")
|
194
|
+
end
|
195
|
+
|
196
|
+
def output_test(test)
|
197
|
+
open_tag("test") do
|
198
|
+
add_content("name", test.method_name)
|
199
|
+
add_content("start-time", test.start_time)
|
200
|
+
add_content("elapsed", test.elapsed_time)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def output_test_suite(test_suite)
|
205
|
+
test_case = test_suite.test_case
|
206
|
+
if test_case.nil?
|
207
|
+
open_tag("test-suite") do
|
208
|
+
add_content("name", test_suite.name)
|
209
|
+
add_content("start-time", test_suite.start_time)
|
210
|
+
add_content("elapsed", test_suite.elapsed_time)
|
211
|
+
end
|
212
|
+
else
|
213
|
+
open_tag("test-case") do
|
214
|
+
add_content("name", test_suite.name)
|
215
|
+
add_content("start-time", test_suite.start_time)
|
216
|
+
add_content("elapsed", test_suite.elapsed_time)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
data/test-unit/test/run-test.rb
CHANGED
@@ -12,4 +12,11 @@ $LOAD_PATH.unshift(lib_dir)
|
|
12
12
|
|
13
13
|
require 'test/unit'
|
14
14
|
|
15
|
+
test_unit_notify_base_dir = File.join(base_dir, "..", "test-unit-notify")
|
16
|
+
test_unit_notify_base_dir = File.expand_path(test_unit_notify_base_dir)
|
17
|
+
if File.exist?(test_unit_notify_base_dir)
|
18
|
+
$LOAD_PATH.unshift(File.join(test_unit_notify_base_dir, "lib"))
|
19
|
+
require 'test/unit/notify'
|
20
|
+
end
|
21
|
+
|
15
22
|
exit Test::Unit::AutoRunner.run(true, test_dir)
|
@@ -9,11 +9,12 @@ require 'test/unit'
|
|
9
9
|
|
10
10
|
module Test
|
11
11
|
module Unit
|
12
|
-
|
12
|
+
module AssertionCheckable
|
13
13
|
backtrace_pre = "---Backtrace---"
|
14
14
|
backtrace_post = "---------------"
|
15
15
|
BACKTRACE_RE = /#{backtrace_pre}\n.+\n#{backtrace_post}/m
|
16
16
|
|
17
|
+
private
|
17
18
|
def check(value, message="")
|
18
19
|
add_assertion
|
19
20
|
raise AssertionFailedError.new(message) unless value
|
@@ -92,6 +93,24 @@ module Test
|
|
92
93
|
end
|
93
94
|
end
|
94
95
|
|
96
|
+
def add_failure(message, location=caller, options=nil)
|
97
|
+
unless @catch_assertions
|
98
|
+
super
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def add_assertion
|
103
|
+
if @catch_assertions
|
104
|
+
@actual_assertion_count += 1
|
105
|
+
else
|
106
|
+
super
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
class TestAssertions < TestCase
|
112
|
+
include AssertionCheckable
|
113
|
+
|
95
114
|
def test_assert_block
|
96
115
|
check_nothing_fails {
|
97
116
|
assert_block {true}
|
@@ -109,16 +128,7 @@ module Test
|
|
109
128
|
assert_block("failed assert_block") {false}
|
110
129
|
}
|
111
130
|
end
|
112
|
-
|
113
|
-
def test_assert
|
114
|
-
check_nothing_fails{assert("a")}
|
115
|
-
check_nothing_fails{assert(true)}
|
116
|
-
check_nothing_fails{assert(true, "successful assert")}
|
117
|
-
check_fails("<nil> is not true."){assert(nil)}
|
118
|
-
check_fails("<false> is not true."){assert(false)}
|
119
|
-
check_fails("failed assert.\n<false> is not true."){assert(false, "failed assert")}
|
120
|
-
end
|
121
|
-
|
131
|
+
|
122
132
|
def test_assert_equal
|
123
133
|
check_nothing_fails {
|
124
134
|
assert_equal("string1", "string1")
|
@@ -328,6 +338,24 @@ EOM
|
|
328
338
|
end
|
329
339
|
end
|
330
340
|
|
341
|
+
def test_assert_equal_with_different_hash
|
342
|
+
designers = {
|
343
|
+
"Ruby" => "Matz",
|
344
|
+
"Lisp" => "John McCarthy",
|
345
|
+
}
|
346
|
+
categories = {
|
347
|
+
"LL" => ["Ruby", "Python"],
|
348
|
+
"Heavy" => ["C", "C++"],
|
349
|
+
}
|
350
|
+
message = <<-EOM.chomp
|
351
|
+
<{"Lisp"=>"John McCarthy", "Ruby"=>"Matz"}> expected but was
|
352
|
+
<{"Heavy"=>["C", "C++"], "LL"=>["Ruby", "Python"]}>.
|
353
|
+
EOM
|
354
|
+
check_fails(message) do
|
355
|
+
assert_equal(designers, categories)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
331
359
|
def test_assert_raise_success
|
332
360
|
return_value = nil
|
333
361
|
check_nothing_fails(true) do
|
@@ -729,7 +757,44 @@ EOM
|
|
729
757
|
assert_not_equal("string", "string", "message")
|
730
758
|
}
|
731
759
|
end
|
732
|
-
|
760
|
+
|
761
|
+
def test_assert_not_match_pass
|
762
|
+
check_nothing_fails do
|
763
|
+
assert_not_match(/sling/, "string")
|
764
|
+
end
|
765
|
+
end
|
766
|
+
|
767
|
+
def test_assert_not_match_pass_with_message
|
768
|
+
check_nothing_fails do
|
769
|
+
assert_not_match(/sling/, "string", "message")
|
770
|
+
end
|
771
|
+
end
|
772
|
+
|
773
|
+
def test_assert_not_match_fail_not_regexp
|
774
|
+
check_fails("<REGEXP> in assert_not_match(<REGEXP>, ...) " +
|
775
|
+
"should be a Regexp.\n" +
|
776
|
+
"<\"asdf\"> expected to be an instance of\n" +
|
777
|
+
"<Regexp> but was\n" +
|
778
|
+
"<String>.") do
|
779
|
+
assert_not_match("asdf", "asdf")
|
780
|
+
end
|
781
|
+
end
|
782
|
+
|
783
|
+
def test_assert_not_match_fail_match
|
784
|
+
check_fails("</string/> expected to not match\n" +
|
785
|
+
"<\"string\">.") do
|
786
|
+
assert_not_match(/string/, "string")
|
787
|
+
end
|
788
|
+
end
|
789
|
+
|
790
|
+
def test_assert_not_match_fail_match_with_message
|
791
|
+
check_fails("message.\n" +
|
792
|
+
"</string/> expected to not match\n" +
|
793
|
+
"<\"string\">.") do
|
794
|
+
assert_not_match(/string/, "string", "message")
|
795
|
+
end
|
796
|
+
end
|
797
|
+
|
733
798
|
def test_assert_no_match
|
734
799
|
check_nothing_fails{assert_no_match(/sling/, "string")}
|
735
800
|
check_nothing_fails{assert_no_match(/sling/, "string", "message")}
|
@@ -743,7 +808,7 @@ EOM
|
|
743
808
|
assert_no_match(/string/, "string", "message")
|
744
809
|
end
|
745
810
|
end
|
746
|
-
|
811
|
+
|
747
812
|
def test_assert_throw
|
748
813
|
check_nothing_fails do
|
749
814
|
assert_throw(:thing, "message") do
|
@@ -795,7 +860,7 @@ EOM
|
|
795
860
|
assert_operator("thing1", :==, "thing2", "message")
|
796
861
|
}
|
797
862
|
end
|
798
|
-
|
863
|
+
|
799
864
|
def test_assert_respond_to
|
800
865
|
check_nothing_fails {
|
801
866
|
assert_respond_to("thing", :to_s, "message")
|
@@ -808,67 +873,37 @@ EOM
|
|
808
873
|
assert_respond_to("thing", 0.15)
|
809
874
|
}
|
810
875
|
check_fails("message.\n" +
|
811
|
-
"<:symbol>.respond_to?(:
|
876
|
+
"<:symbol>.respond_to?(:nonexistence) expected\n" +
|
812
877
|
"(Class: <Symbol>)") {
|
813
|
-
assert_respond_to(:symbol, :
|
814
|
-
}
|
815
|
-
end
|
816
|
-
|
817
|
-
def test_assert_in_delta_pass
|
818
|
-
check_nothing_fails {
|
819
|
-
assert_in_delta(1.4, 1.4, 0)
|
820
|
-
}
|
821
|
-
end
|
822
|
-
|
823
|
-
def test_assert_in_delta_pass_with_message
|
824
|
-
check_nothing_fails {
|
825
|
-
assert_in_delta(0.5, 0.4, 0.1, "message")
|
826
|
-
}
|
827
|
-
end
|
828
|
-
|
829
|
-
def test_assert_in_delta_pass_float_like_object
|
830
|
-
check_nothing_fails {
|
831
|
-
float_thing = Object.new
|
832
|
-
def float_thing.to_f
|
833
|
-
0.2
|
834
|
-
end
|
835
|
-
assert_in_delta(0.1, float_thing, 0.1)
|
878
|
+
assert_respond_to(:symbol, :nonexistence, "message")
|
836
879
|
}
|
837
880
|
end
|
838
881
|
|
839
|
-
def
|
882
|
+
def test_assert_not_respond_to_pass_symbol
|
840
883
|
check_nothing_fails do
|
841
|
-
|
884
|
+
assert_not_respond_to("thing", :nonexistent, "message")
|
842
885
|
end
|
843
886
|
end
|
844
887
|
|
845
|
-
def
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
"\n" +
|
850
|
-
"Relation:\n" +
|
851
|
-
"<<0.4> < <0.5>-<0.05>(0.45) <= <0.5>+<0.05>(0.55)>") {
|
852
|
-
assert_in_delta(0.5, 0.4, 0.05, "message")
|
853
|
-
}
|
888
|
+
def test_assert_not_respond_to_pass_string
|
889
|
+
check_nothing_fails do
|
890
|
+
assert_not_respond_to("thing", :nonexistent, "message")
|
891
|
+
end
|
854
892
|
end
|
855
893
|
|
856
|
-
def
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
"<#{inspected_object}>.respond_to?(:to_f) expected\n" +
|
862
|
-
"(Class: <Object>)") {
|
863
|
-
assert_in_delta(object, 0.4, 0.1)
|
864
|
-
}
|
894
|
+
def test_assert_not_respond_to_fail_number
|
895
|
+
check_fails("<0.15>.kind_of?(Symbol) or\n" +
|
896
|
+
"<0.15>.respond_to?(:to_str) expected") do
|
897
|
+
assert_respond_to("thing", 0.15)
|
898
|
+
end
|
865
899
|
end
|
866
900
|
|
867
|
-
def
|
868
|
-
check_fails("
|
869
|
-
"
|
870
|
-
|
871
|
-
|
901
|
+
def tset_assert_not_respond_to_fail_existence
|
902
|
+
check_fails("message.\n" +
|
903
|
+
"!<:symbol>.respond_to?(:to_s) expected\n" +
|
904
|
+
"(Class: <Symbol>)") do
|
905
|
+
assert_respond_to(:symbol, :to_s, "message")
|
906
|
+
end
|
872
907
|
end
|
873
908
|
|
874
909
|
def test_assert_send
|
@@ -879,14 +914,22 @@ EOM
|
|
879
914
|
return argument
|
880
915
|
end
|
881
916
|
end
|
882
|
-
check_nothing_fails
|
917
|
+
check_nothing_fails do
|
883
918
|
assert_send([object, :return_argument, true, "bogus"], "message")
|
884
|
-
|
885
|
-
|
919
|
+
end
|
920
|
+
|
921
|
+
inspected_object = AssertionMessage.convert(object)
|
922
|
+
expected_message = <<-EOM
|
923
|
+
message.
|
924
|
+
<#{inspected_object}> expected to respond to
|
925
|
+
<return_argument(*[false, "bogus"])> with a true value but was
|
926
|
+
<false>.
|
927
|
+
EOM
|
928
|
+
check_fails(expected_message.chomp) do
|
886
929
|
assert_send([object, :return_argument, false, "bogus"], "message")
|
887
|
-
|
930
|
+
end
|
888
931
|
end
|
889
|
-
|
932
|
+
|
890
933
|
def test_condition_invariant
|
891
934
|
object = Object.new
|
892
935
|
def object.inspect
|
@@ -1198,19 +1241,607 @@ EOM
|
|
1198
1241
|
assert_path_not_exist(__FILE__)
|
1199
1242
|
end
|
1200
1243
|
end
|
1244
|
+
end
|
1201
1245
|
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1246
|
+
class TestAssert < TestCase
|
1247
|
+
include AssertionCheckable
|
1248
|
+
|
1249
|
+
def test_pass
|
1250
|
+
check_nothing_fails do
|
1251
|
+
assert(true)
|
1206
1252
|
end
|
1207
1253
|
end
|
1208
1254
|
|
1209
|
-
def
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1255
|
+
def test_pass_neither_false_or_nil
|
1256
|
+
check_nothing_fails do
|
1257
|
+
assert("a")
|
1258
|
+
end
|
1259
|
+
end
|
1260
|
+
|
1261
|
+
def test_pass_with_message
|
1262
|
+
check_nothing_fails do
|
1263
|
+
assert(true, "successful assert")
|
1264
|
+
end
|
1265
|
+
end
|
1266
|
+
|
1267
|
+
def test_fail_nil
|
1268
|
+
check_fails("<nil> is not true.") do
|
1269
|
+
assert(nil)
|
1270
|
+
end
|
1271
|
+
end
|
1272
|
+
|
1273
|
+
def test_fail_false
|
1274
|
+
check_fails("<false> is not true.") do
|
1275
|
+
assert(false)
|
1276
|
+
end
|
1277
|
+
end
|
1278
|
+
|
1279
|
+
def test_fail_false_with_message
|
1280
|
+
check_fails("failed assert.\n" +
|
1281
|
+
"<false> is not true.") do
|
1282
|
+
assert(false, "failed assert")
|
1283
|
+
end
|
1284
|
+
end
|
1285
|
+
|
1286
|
+
def test_error_invalid_message
|
1287
|
+
check_fails("assertion message must be String or Proc: " +
|
1288
|
+
"<true>(<TrueClass>)") do
|
1289
|
+
begin
|
1290
|
+
assert(true, true)
|
1291
|
+
rescue ArgumentError
|
1292
|
+
raise AssertionFailedError, $!.message
|
1293
|
+
end
|
1294
|
+
end
|
1295
|
+
end
|
1296
|
+
end
|
1297
|
+
|
1298
|
+
class TestAssertInDelta < TestCase
|
1299
|
+
include AssertionCheckable
|
1300
|
+
|
1301
|
+
def test_pass
|
1302
|
+
check_nothing_fails do
|
1303
|
+
assert_in_delta(1.4, 1.4, 0)
|
1304
|
+
end
|
1305
|
+
end
|
1306
|
+
|
1307
|
+
def test_pass_without_delta
|
1308
|
+
check_nothing_fails do
|
1309
|
+
assert_in_delta(1.401, 1.402)
|
1310
|
+
end
|
1311
|
+
end
|
1312
|
+
|
1313
|
+
def test_pass_with_message
|
1314
|
+
check_nothing_fails do
|
1315
|
+
assert_in_delta(0.5, 0.4, 0.1, "message")
|
1316
|
+
end
|
1317
|
+
end
|
1318
|
+
|
1319
|
+
def test_pass_float_like_object
|
1320
|
+
check_nothing_fails do
|
1321
|
+
float_thing = Object.new
|
1322
|
+
def float_thing.to_f
|
1323
|
+
0.2
|
1324
|
+
end
|
1325
|
+
assert_in_delta(0.1, float_thing, 0.1)
|
1326
|
+
end
|
1327
|
+
end
|
1328
|
+
|
1329
|
+
def test_pass_string_expected
|
1330
|
+
check_nothing_fails do
|
1331
|
+
assert_in_delta("0.5", 0.4, 0.1)
|
1332
|
+
end
|
1333
|
+
end
|
1334
|
+
|
1335
|
+
def test_fail_with_message
|
1336
|
+
check_fails("message.\n" +
|
1337
|
+
"<0.5> -/+ <0.05> expected to include\n" +
|
1338
|
+
"<0.4>.\n" +
|
1339
|
+
"\n" +
|
1340
|
+
"Relation:\n" +
|
1341
|
+
"<<0.4> < <0.5>-<0.05>[0.45] <= <0.5>+<0.05>[0.55]>") do
|
1342
|
+
assert_in_delta(0.5, 0.4, 0.05, "message")
|
1343
|
+
end
|
1344
|
+
end
|
1345
|
+
|
1346
|
+
def test_fail_because_not_float_like_object
|
1347
|
+
object = Object.new
|
1348
|
+
inspected_object = AssertionMessage.convert(object)
|
1349
|
+
check_fails("The arguments must respond to to_f; " +
|
1350
|
+
"the first float did not.\n" +
|
1351
|
+
"<#{inspected_object}>.respond_to?(:to_f) expected\n" +
|
1352
|
+
"(Class: <Object>)") do
|
1353
|
+
assert_in_delta(object, 0.4, 0.1)
|
1354
|
+
end
|
1355
|
+
end
|
1356
|
+
|
1357
|
+
def test_fail_because_negaitve_delta
|
1358
|
+
check_fails("The delta should not be negative.\n" +
|
1359
|
+
"<-0.1> expected to be\n>=\n<0.0>.") do
|
1360
|
+
assert_in_delta(0.5, 0.4, -0.1, "message")
|
1361
|
+
end
|
1362
|
+
end
|
1363
|
+
|
1364
|
+
def test_fail_without_delta
|
1365
|
+
check_fails("<1.402> -/+ <0.001> expected to include\n" +
|
1366
|
+
"<1.404>.\n" +
|
1367
|
+
"\n" +
|
1368
|
+
"Relation:\n" +
|
1369
|
+
"<" +
|
1370
|
+
"<1.402>-<0.001>[#{1.402 - 0.001}] <= " +
|
1371
|
+
"<1.402>+<0.001>[#{1.402 + 0.001}] < " +
|
1372
|
+
"<1.404>" +
|
1373
|
+
">") do
|
1374
|
+
assert_in_delta(1.402, 1.404)
|
1375
|
+
end
|
1376
|
+
end
|
1377
|
+
end
|
1378
|
+
|
1379
|
+
class TestAssertNotInDelta < Test::Unit::TestCase
|
1380
|
+
include AssertionCheckable
|
1381
|
+
|
1382
|
+
def test_pass
|
1383
|
+
check_nothing_fails do
|
1384
|
+
assert_not_in_delta(1.42, 1.44, 0.01)
|
1385
|
+
end
|
1386
|
+
end
|
1387
|
+
|
1388
|
+
def test_pass_without_delta
|
1389
|
+
check_nothing_fails do
|
1390
|
+
assert_not_in_delta(1.402, 1.404)
|
1391
|
+
end
|
1392
|
+
end
|
1393
|
+
|
1394
|
+
def test_pass_with_message
|
1395
|
+
check_nothing_fails do
|
1396
|
+
assert_not_in_delta(0.5, 0.4, 0.09, "message")
|
1397
|
+
end
|
1398
|
+
end
|
1399
|
+
|
1400
|
+
def test_pass_float_like_object
|
1401
|
+
check_nothing_fails do
|
1402
|
+
float_thing = Object.new
|
1403
|
+
def float_thing.to_f
|
1404
|
+
0.2
|
1405
|
+
end
|
1406
|
+
assert_not_in_delta(0.1, float_thing, 0.09)
|
1407
|
+
end
|
1408
|
+
end
|
1409
|
+
|
1410
|
+
def test_pass_string_epxected
|
1411
|
+
check_nothing_fails do
|
1412
|
+
assert_not_in_delta("0.5", 0.4, 0.09)
|
1413
|
+
end
|
1414
|
+
end
|
1415
|
+
|
1416
|
+
def test_fail
|
1417
|
+
check_fails("<1.4> -/+ <0.11> expected to not include\n" +
|
1418
|
+
"<1.5>.\n" +
|
1419
|
+
"\n" +
|
1420
|
+
"Relation:\n" +
|
1421
|
+
"<" +
|
1422
|
+
"<1.4>-<0.11>[#{1.4 - 0.11}] <= " +
|
1423
|
+
"<1.5> <= " +
|
1424
|
+
"<1.4>+<0.11>[#{1.4 + 0.11}]" +
|
1425
|
+
">") do
|
1426
|
+
assert_not_in_delta(1.4, 1.5, 0.11)
|
1427
|
+
end
|
1428
|
+
end
|
1429
|
+
|
1430
|
+
def test_fail_without_delta
|
1431
|
+
check_fails("<1.402> -/+ <0.001> expected to not include\n" +
|
1432
|
+
"<1.4021>.\n" +
|
1433
|
+
"\n" +
|
1434
|
+
"Relation:\n" +
|
1435
|
+
"<" +
|
1436
|
+
"<1.402>-<0.001>[#{1.402 - 0.001}] <= " +
|
1437
|
+
"<1.4021> <= " +
|
1438
|
+
"<1.402>+<0.001>[#{1.402 + 0.001}]" +
|
1439
|
+
">") do
|
1440
|
+
assert_not_in_delta(1.402, 1.4021)
|
1441
|
+
end
|
1442
|
+
end
|
1443
|
+
|
1444
|
+
def test_fail_with_message
|
1445
|
+
check_fails("message.\n" +
|
1446
|
+
"<0.5> -/+ <0.11> expected to not include\n" +
|
1447
|
+
"<0.4>.\n" +
|
1448
|
+
"\n" +
|
1449
|
+
"Relation:\n" +
|
1450
|
+
"<" +
|
1451
|
+
"<0.5>-<0.11>[0.39] <= " +
|
1452
|
+
"<0.4> <= " +
|
1453
|
+
"<0.5>+<0.11>[0.61]" +
|
1454
|
+
">") do
|
1455
|
+
assert_not_in_delta(0.5, 0.4, 0.11, "message")
|
1456
|
+
end
|
1457
|
+
end
|
1458
|
+
|
1459
|
+
def test_fail_because_not_float_like_object
|
1460
|
+
object = Object.new
|
1461
|
+
inspected_object = AssertionMessage.convert(object)
|
1462
|
+
check_fails("The arguments must respond to to_f; " +
|
1463
|
+
"the first float did not.\n" +
|
1464
|
+
"<#{inspected_object}>.respond_to?(:to_f) expected\n" +
|
1465
|
+
"(Class: <Object>)") do
|
1466
|
+
assert_not_in_delta(object, 0.4, 0.1)
|
1467
|
+
end
|
1468
|
+
end
|
1469
|
+
|
1470
|
+
def test_fail_because_negaitve_delta
|
1471
|
+
check_fails("The delta should not be negative.\n" +
|
1472
|
+
"<-0.11> expected to be\n>=\n<0.0>.") do
|
1473
|
+
assert_not_in_delta(0.5, 0.4, -0.11, "message")
|
1474
|
+
end
|
1475
|
+
end
|
1476
|
+
end
|
1477
|
+
|
1478
|
+
class TestAssertInEpsilon < TestCase
|
1479
|
+
include AssertionCheckable
|
1480
|
+
|
1481
|
+
def test_pass
|
1482
|
+
check_nothing_fails do
|
1483
|
+
assert_in_epsilon(10000, 9000, 0.1)
|
1484
|
+
end
|
1485
|
+
end
|
1486
|
+
|
1487
|
+
def test_pass_without_epsilon
|
1488
|
+
check_nothing_fails do
|
1489
|
+
assert_in_epsilon(10000, 9991)
|
1490
|
+
end
|
1491
|
+
end
|
1492
|
+
|
1493
|
+
def test_pass_with_message
|
1494
|
+
check_nothing_fails do
|
1495
|
+
assert_in_epsilon(10000, 9000, 0.1, "message")
|
1496
|
+
end
|
1497
|
+
end
|
1498
|
+
|
1499
|
+
def test_pass_float_like_object
|
1500
|
+
check_nothing_fails do
|
1501
|
+
float_thing = Object.new
|
1502
|
+
def float_thing.to_f
|
1503
|
+
9000.0
|
1504
|
+
end
|
1505
|
+
assert_in_epsilon(10000, float_thing, 0.1)
|
1506
|
+
end
|
1507
|
+
end
|
1508
|
+
|
1509
|
+
def test_pass_string_expected
|
1510
|
+
check_nothing_fails do
|
1511
|
+
assert_in_epsilon("10000", 9000, 0.1)
|
1512
|
+
end
|
1513
|
+
end
|
1514
|
+
|
1515
|
+
def test_fail_with_message
|
1516
|
+
check_fails("message.\n" +
|
1517
|
+
"<10000> -/+ (<10000> * <0.1>)[1000.0] " +
|
1518
|
+
"expected to include\n" +
|
1519
|
+
"<8999>.\n" +
|
1520
|
+
"\n" +
|
1521
|
+
"Relation:\n" +
|
1522
|
+
"<" +
|
1523
|
+
"<8999> < " +
|
1524
|
+
"<10000>-(<10000>*<0.1>)[9000.0] <= " +
|
1525
|
+
"<10000>+(<10000>*<0.1>)[11000.0]" +
|
1526
|
+
">") do
|
1527
|
+
assert_in_epsilon(10000, 8999, 0.1, "message")
|
1528
|
+
end
|
1529
|
+
end
|
1530
|
+
|
1531
|
+
def test_fail_because_not_float_like_object
|
1532
|
+
object = Object.new
|
1533
|
+
inspected_object = AssertionMessage.convert(object)
|
1534
|
+
check_fails("The arguments must respond to to_f; " +
|
1535
|
+
"the first float did not.\n" +
|
1536
|
+
"<#{inspected_object}>.respond_to?(:to_f) expected\n" +
|
1537
|
+
"(Class: <Object>)") do
|
1538
|
+
assert_in_epsilon(object, 9000, 0.1)
|
1539
|
+
end
|
1540
|
+
end
|
1541
|
+
|
1542
|
+
def test_fail_because_negaitve_epsilon
|
1543
|
+
check_fails("The epsilon should not be negative.\n" +
|
1544
|
+
"<-0.1> expected to be\n>=\n<0.0>.") do
|
1545
|
+
assert_in_epsilon(10000, 9000, -0.1, "message")
|
1546
|
+
end
|
1547
|
+
end
|
1548
|
+
|
1549
|
+
def test_fail_without_epsilon
|
1550
|
+
check_fails("<10000> -/+ (<10000> * <0.001>)[10.0] " +
|
1551
|
+
"expected to include\n" +
|
1552
|
+
"<10011>.\n" +
|
1553
|
+
"\n" +
|
1554
|
+
"Relation:\n" +
|
1555
|
+
"<" +
|
1556
|
+
"<10000>-(<10000>*<0.001>)[9990.0] <= " +
|
1557
|
+
"<10000>+(<10000>*<0.001>)[10010.0] < " +
|
1558
|
+
"<10011>" +
|
1559
|
+
">") do
|
1560
|
+
assert_in_epsilon(10000, 10011)
|
1561
|
+
end
|
1562
|
+
end
|
1563
|
+
end
|
1564
|
+
|
1565
|
+
class TestAssertNotInEpsilon < Test::Unit::TestCase
|
1566
|
+
include AssertionCheckable
|
1567
|
+
|
1568
|
+
def test_pass
|
1569
|
+
check_nothing_fails do
|
1570
|
+
assert_not_in_epsilon(10000, 8999, 0.1)
|
1571
|
+
end
|
1572
|
+
end
|
1573
|
+
|
1574
|
+
def test_pass_without_epsilon
|
1575
|
+
check_nothing_fails do
|
1576
|
+
assert_not_in_epsilon(10000, 9989)
|
1577
|
+
end
|
1578
|
+
end
|
1579
|
+
|
1580
|
+
def test_pass_with_message
|
1581
|
+
check_nothing_fails do
|
1582
|
+
assert_not_in_epsilon(10000, 8999, 0.1, "message")
|
1583
|
+
end
|
1584
|
+
end
|
1585
|
+
|
1586
|
+
def test_pass_float_like_object
|
1587
|
+
check_nothing_fails do
|
1588
|
+
float_thing = Object.new
|
1589
|
+
def float_thing.to_f
|
1590
|
+
8999.0
|
1591
|
+
end
|
1592
|
+
assert_not_in_epsilon(10000, float_thing, 0.1)
|
1593
|
+
end
|
1594
|
+
end
|
1595
|
+
|
1596
|
+
def test_pass_string_epxected
|
1597
|
+
check_nothing_fails do
|
1598
|
+
assert_not_in_epsilon("10000", 8999, 0.1)
|
1599
|
+
end
|
1600
|
+
end
|
1601
|
+
|
1602
|
+
def test_fail
|
1603
|
+
check_fails("<10000> -/+ (<10000> * <0.1>)[1000.0] " +
|
1604
|
+
"expected to not include\n" +
|
1605
|
+
"<9000>.\n" +
|
1606
|
+
"\n" +
|
1607
|
+
"Relation:\n" +
|
1608
|
+
"<" +
|
1609
|
+
"<10000>-(<10000>*<0.1>)[9000.0] <= " +
|
1610
|
+
"<9000> <= " +
|
1611
|
+
"<10000>+(<10000>*<0.1>)[11000.0]" +
|
1612
|
+
">") do
|
1613
|
+
assert_not_in_epsilon(10000, 9000, 0.1)
|
1614
|
+
end
|
1615
|
+
end
|
1616
|
+
|
1617
|
+
def test_fail_without_epsilon
|
1618
|
+
check_fails("<10000> -/+ (<10000> * <0.001>)[10.0] " +
|
1619
|
+
"expected to not include\n" +
|
1620
|
+
"<9990>.\n" +
|
1621
|
+
"\n" +
|
1622
|
+
"Relation:\n" +
|
1623
|
+
"<" +
|
1624
|
+
"<10000>-(<10000>*<0.001>)[9990.0] <= " +
|
1625
|
+
"<9990> <= " +
|
1626
|
+
"<10000>+(<10000>*<0.001>)[10010.0]" +
|
1627
|
+
">") do
|
1628
|
+
assert_not_in_epsilon(10000, 9990)
|
1629
|
+
end
|
1630
|
+
end
|
1631
|
+
|
1632
|
+
def test_fail_with_message
|
1633
|
+
check_fails("message.\n" +
|
1634
|
+
"<10000> -/+ (<10000> * <0.1>)[1000.0] " +
|
1635
|
+
"expected to not include\n" +
|
1636
|
+
"<9000>.\n" +
|
1637
|
+
"\n" +
|
1638
|
+
"Relation:\n" +
|
1639
|
+
"<" +
|
1640
|
+
"<10000>-(<10000>*<0.1>)[9000.0] <= " +
|
1641
|
+
"<9000> <= " +
|
1642
|
+
"<10000>+(<10000>*<0.1>)[11000.0]" +
|
1643
|
+
">") do
|
1644
|
+
assert_not_in_epsilon(10000, 9000, 0.1, "message")
|
1645
|
+
end
|
1646
|
+
end
|
1647
|
+
|
1648
|
+
def test_fail_because_not_float_like_object
|
1649
|
+
object = Object.new
|
1650
|
+
inspected_object = AssertionMessage.convert(object)
|
1651
|
+
check_fails("The arguments must respond to to_f; " +
|
1652
|
+
"the first float did not.\n" +
|
1653
|
+
"<#{inspected_object}>.respond_to?(:to_f) expected\n" +
|
1654
|
+
"(Class: <Object>)") do
|
1655
|
+
assert_not_in_epsilon(object, 9000, 0.1)
|
1656
|
+
end
|
1657
|
+
end
|
1658
|
+
|
1659
|
+
def test_fail_because_negaitve_epsilon
|
1660
|
+
check_fails("The epsilon should not be negative.\n" +
|
1661
|
+
"<-0.1> expected to be\n>=\n<0.0>.") do
|
1662
|
+
assert_not_in_epsilon(10000, 9000, -0.1, "message")
|
1663
|
+
end
|
1664
|
+
end
|
1665
|
+
end
|
1666
|
+
|
1667
|
+
class TestAssertInclude < Test::Unit::TestCase
|
1668
|
+
include AssertionCheckable
|
1669
|
+
|
1670
|
+
def test_pass
|
1671
|
+
check_nothing_fails do
|
1672
|
+
assert_include([1, 2, 3], 1)
|
1673
|
+
end
|
1674
|
+
end
|
1675
|
+
|
1676
|
+
def test_pass_with_message
|
1677
|
+
check_nothing_fails do
|
1678
|
+
assert_include([1, 2, 3], 1, "message")
|
1679
|
+
end
|
1680
|
+
end
|
1681
|
+
|
1682
|
+
def test_fail
|
1683
|
+
check_fails("<[1, 2, 3]> expected to include\n" +
|
1684
|
+
"<4>.") do
|
1685
|
+
assert_include([1, 2, 3], 4)
|
1686
|
+
end
|
1687
|
+
end
|
1688
|
+
|
1689
|
+
def test_fail_with_message
|
1690
|
+
check_fails("message.\n" +
|
1691
|
+
"<[1, 2, 3]> expected to include\n" +
|
1692
|
+
"<4>.") do
|
1693
|
+
assert_include([1, 2, 3], 4, "message")
|
1694
|
+
end
|
1695
|
+
end
|
1696
|
+
|
1697
|
+
def test_fail_because_not_collection_like_object
|
1698
|
+
object = Object.new
|
1699
|
+
inspected_object = AssertionMessage.convert(object)
|
1700
|
+
check_fails("The collection must respond to :include?.\n" +
|
1701
|
+
"<#{inspected_object}>.respond_to?(:include?) expected\n" +
|
1702
|
+
"(Class: <Object>)") do
|
1703
|
+
assert_include(object, 1)
|
1704
|
+
end
|
1705
|
+
end
|
1706
|
+
end
|
1707
|
+
|
1708
|
+
class TestAssertNotInclude < Test::Unit::TestCase
|
1709
|
+
include AssertionCheckable
|
1710
|
+
|
1711
|
+
def test_pass
|
1712
|
+
check_nothing_fails do
|
1713
|
+
assert_not_include([1, 2, 3], 5)
|
1714
|
+
end
|
1715
|
+
end
|
1716
|
+
|
1717
|
+
def test_pass_with_message
|
1718
|
+
check_nothing_fails do
|
1719
|
+
assert_not_include([1, 2, 3], 5, "message")
|
1720
|
+
end
|
1721
|
+
end
|
1722
|
+
|
1723
|
+
def test_fail
|
1724
|
+
check_fails("<[1, 2, 3]> expected to not include\n" +
|
1725
|
+
"<2>.") do
|
1726
|
+
assert_not_include([1, 2, 3], 2)
|
1727
|
+
end
|
1728
|
+
end
|
1729
|
+
|
1730
|
+
def test_fail_with_message
|
1731
|
+
check_fails("message.\n" +
|
1732
|
+
"<[1, 2, 3]> expected to not include\n" +
|
1733
|
+
"<2>.") do
|
1734
|
+
assert_not_include([1, 2, 3], 2, "message")
|
1735
|
+
end
|
1736
|
+
end
|
1737
|
+
|
1738
|
+
def test_fail_because_not_collection_like_object
|
1739
|
+
object = Object.new
|
1740
|
+
inspected_object = AssertionMessage.convert(object)
|
1741
|
+
check_fails("The collection must respond to :include?.\n" +
|
1742
|
+
"<#{inspected_object}>.respond_to?(:include?) expected\n" +
|
1743
|
+
"(Class: <Object>)") do
|
1744
|
+
assert_not_include(object, 1)
|
1745
|
+
end
|
1746
|
+
end
|
1747
|
+
end
|
1748
|
+
|
1749
|
+
class TestAssertEmpty < Test::Unit::TestCase
|
1750
|
+
include AssertionCheckable
|
1751
|
+
|
1752
|
+
def test_pass
|
1753
|
+
check_nothing_fails do
|
1754
|
+
assert_empty([])
|
1755
|
+
end
|
1756
|
+
end
|
1757
|
+
|
1758
|
+
def test_pass_with_message
|
1759
|
+
check_nothing_fails do
|
1760
|
+
assert_empty([], "message")
|
1761
|
+
end
|
1762
|
+
end
|
1763
|
+
|
1764
|
+
def test_fail
|
1765
|
+
check_fails("<[1]> expected to be empty.") do
|
1766
|
+
assert_empty([1])
|
1767
|
+
end
|
1768
|
+
end
|
1769
|
+
|
1770
|
+
def test_fail_with_message
|
1771
|
+
check_fails("message.\n" +
|
1772
|
+
"<[1]> expected to be empty.") do
|
1773
|
+
assert_empty([1], "message")
|
1774
|
+
end
|
1775
|
+
end
|
1776
|
+
|
1777
|
+
def test_fail_because_no_empty_method
|
1778
|
+
object = Object.new
|
1779
|
+
inspected_object = AssertionMessage.convert(object)
|
1780
|
+
check_fails("The object must respond to :empty?.\n" +
|
1781
|
+
"<#{inspected_object}>.respond_to?(:empty?) expected\n" +
|
1782
|
+
"(Class: <Object>)") do
|
1783
|
+
assert_empty(object)
|
1784
|
+
end
|
1785
|
+
end
|
1786
|
+
end
|
1787
|
+
|
1788
|
+
class TestAssertNotEmpty < Test::Unit::TestCase
|
1789
|
+
include AssertionCheckable
|
1790
|
+
|
1791
|
+
def test_pass
|
1792
|
+
check_nothing_fails do
|
1793
|
+
assert_not_empty([1])
|
1794
|
+
end
|
1795
|
+
end
|
1796
|
+
|
1797
|
+
def test_pass_with_message
|
1798
|
+
check_nothing_fails do
|
1799
|
+
assert_not_empty([1], "message")
|
1800
|
+
end
|
1801
|
+
end
|
1802
|
+
|
1803
|
+
def test_fail
|
1804
|
+
check_fails("<[]> expected to not be empty.") do
|
1805
|
+
assert_not_empty([])
|
1806
|
+
end
|
1807
|
+
end
|
1808
|
+
|
1809
|
+
def test_fail_with_message
|
1810
|
+
check_fails("message.\n" +
|
1811
|
+
"<[]> expected to not be empty.") do
|
1812
|
+
assert_not_empty([], "message")
|
1813
|
+
end
|
1814
|
+
end
|
1815
|
+
|
1816
|
+
def test_fail_because_no_empty_method
|
1817
|
+
object = Object.new
|
1818
|
+
inspected_object = AssertionMessage.convert(object)
|
1819
|
+
check_fails("The object must respond to :empty?.\n" +
|
1820
|
+
"<#{inspected_object}>.respond_to?(:empty?) expected\n" +
|
1821
|
+
"(Class: <Object>)") do
|
1822
|
+
assert_not_empty(object)
|
1823
|
+
end
|
1824
|
+
end
|
1825
|
+
end
|
1826
|
+
|
1827
|
+
class TestAssertNotSend < Test::Unit::TestCase
|
1828
|
+
include AssertionCheckable
|
1829
|
+
|
1830
|
+
def test_pass
|
1831
|
+
check_nothing_fails do
|
1832
|
+
assert_not_send([[1, 2], :member?, 4], "message")
|
1833
|
+
end
|
1834
|
+
end
|
1835
|
+
|
1836
|
+
def test_fail
|
1837
|
+
expected_message = <<-EOM
|
1838
|
+
message.
|
1839
|
+
<[1, 2]> expected to respond to
|
1840
|
+
<member?(*[2])> with not a true value but was
|
1841
|
+
<true>.
|
1842
|
+
EOM
|
1843
|
+
check_fails(expected_message.chomp) do
|
1844
|
+
assert_not_send([[1, 2], :member?, 2], "message")
|
1214
1845
|
end
|
1215
1846
|
end
|
1216
1847
|
end
|