win32-api 1.10.0 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +3 -0
  3. data/Gemfile.lock +5 -5
  4. data/ext/mkmf.log +3 -27
  5. data/ext/win32/api.c +16 -15
  6. data/lib/win32/ruby2_32/win32/api.so +0 -0
  7. data/pkg/win32-api-1.10.1-universal-mingw32.gem +0 -0
  8. data/test/test_win32_api.rb +1 -1
  9. data/vendor/bundle/ruby/3.0.0/bin/rake +27 -0
  10. data/vendor/bundle/ruby/3.0.0/bin/rake.bat +2 -0
  11. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/BSDL +22 -0
  12. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/COPYING +57 -0
  13. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/Gemfile +9 -0
  14. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/LEGAL +4 -0
  15. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/README.md +96 -0
  16. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/Rakefile +59 -0
  17. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/bin/console +12 -0
  18. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/bin/setup +6 -0
  19. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/lib/power_assert.rb +91 -0
  20. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/lib/power_assert/colorize.rb +7 -0
  21. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/lib/power_assert/configuration.rb +46 -0
  22. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/lib/power_assert/context.rb +233 -0
  23. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/lib/power_assert/enable_tracepoint_events.rb +58 -0
  24. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/lib/power_assert/inspector.rb +62 -0
  25. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/lib/power_assert/parser.rb +251 -0
  26. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/lib/power_assert/version.rb +3 -0
  27. data/vendor/bundle/ruby/3.0.0/gems/power_assert-2.0.0/power_assert.gemspec +31 -0
  28. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/CONTRIBUTING.rdoc +43 -0
  29. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/Gemfile +10 -0
  30. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/History.rdoc +2386 -0
  31. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/MIT-LICENSE +21 -0
  32. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/README.rdoc +155 -0
  33. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/Rakefile +41 -0
  34. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/bin/bundle +105 -0
  35. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/bin/console +7 -0
  36. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/bin/rake +29 -0
  37. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/bin/rdoc +29 -0
  38. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/bin/rubocop +29 -0
  39. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/bin/setup +6 -0
  40. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/doc/command_line_usage.rdoc +158 -0
  41. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/doc/example/Rakefile1 +38 -0
  42. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/doc/example/Rakefile2 +35 -0
  43. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/doc/example/a.c +6 -0
  44. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/doc/example/b.c +6 -0
  45. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/doc/example/main.c +11 -0
  46. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/doc/glossary.rdoc +42 -0
  47. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/doc/jamis.rb +592 -0
  48. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/doc/proto_rake.rdoc +127 -0
  49. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/doc/rake.1 +156 -0
  50. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/doc/rakefile.rdoc +622 -0
  51. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/doc/rational.rdoc +151 -0
  52. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/exe/rake +27 -0
  53. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake.rb +71 -0
  54. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/application.rb +824 -0
  55. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/backtrace.rb +24 -0
  56. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/clean.rb +78 -0
  57. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/cloneable.rb +17 -0
  58. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/cpu_counter.rb +107 -0
  59. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/default_loader.rb +15 -0
  60. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/dsl_definition.rb +195 -0
  61. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/early_time.rb +22 -0
  62. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/ext/core.rb +26 -0
  63. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/ext/string.rb +176 -0
  64. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/file_creation_task.rb +25 -0
  65. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/file_list.rb +435 -0
  66. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/file_task.rb +54 -0
  67. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/file_utils.rb +134 -0
  68. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/file_utils_ext.rb +134 -0
  69. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/invocation_chain.rb +57 -0
  70. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/invocation_exception_mixin.rb +17 -0
  71. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/late_time.rb +18 -0
  72. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/linked_list.rb +112 -0
  73. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/loaders/makefile.rb +54 -0
  74. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/multi_task.rb +14 -0
  75. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/name_space.rb +38 -0
  76. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/packagetask.rb +222 -0
  77. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/phony.rb +16 -0
  78. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/private_reader.rb +21 -0
  79. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/promise.rb +100 -0
  80. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/pseudo_status.rb +30 -0
  81. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/rake_module.rb +67 -0
  82. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/rake_test_loader.rb +27 -0
  83. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/rule_recursion_overflow_error.rb +20 -0
  84. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/scope.rb +43 -0
  85. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/task.rb +434 -0
  86. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/task_argument_error.rb +8 -0
  87. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/task_arguments.rb +109 -0
  88. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/task_manager.rb +331 -0
  89. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/tasklib.rb +12 -0
  90. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/testtask.rb +189 -0
  91. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/thread_history_display.rb +49 -0
  92. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/thread_pool.rb +163 -0
  93. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/trace_output.rb +23 -0
  94. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/version.rb +10 -0
  95. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/win32.rb +51 -0
  96. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/rake.gemspec +43 -0
  97. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/BSDL +24 -0
  98. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/COPYING +64 -0
  99. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/PSFL +271 -0
  100. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/README.md +97 -0
  101. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/Rakefile +66 -0
  102. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/doc/text/getting-started.md +246 -0
  103. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/doc/text/how-to.md +90 -0
  104. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/doc/text/news.md +1552 -0
  105. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test-unit.rb +19 -0
  106. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit.rb +521 -0
  107. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/assertion-failed-error.rb +25 -0
  108. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/assertions.rb +2256 -0
  109. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/attribute-matcher.rb +26 -0
  110. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/attribute.rb +227 -0
  111. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/auto-runner-loader.rb +17 -0
  112. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/autorunner.rb +569 -0
  113. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/code-snippet-fetcher.rb +58 -0
  114. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/collector.rb +73 -0
  115. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/collector/descendant.rb +19 -0
  116. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/collector/dir.rb +108 -0
  117. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/collector/load.rb +197 -0
  118. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/collector/objectspace.rb +34 -0
  119. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/collector/xml.rb +249 -0
  120. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/color-scheme.rb +216 -0
  121. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/color.rb +134 -0
  122. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/data-sets.rb +116 -0
  123. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/data.rb +371 -0
  124. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/diff.rb +745 -0
  125. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/error.rb +158 -0
  126. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/exception-handler.rb +82 -0
  127. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/failure.rb +169 -0
  128. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/fault-location-detector.rb +100 -0
  129. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/fixture.rb +304 -0
  130. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/notification.rb +138 -0
  131. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/omission.rb +198 -0
  132. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/pending.rb +155 -0
  133. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/priority.rb +196 -0
  134. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/runner/console.rb +67 -0
  135. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/runner/emacs.rb +8 -0
  136. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/runner/xml.rb +15 -0
  137. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/test-suite-creator.rb +103 -0
  138. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/testcase.rb +899 -0
  139. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/testresult.rb +132 -0
  140. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/testsuite.rb +175 -0
  141. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/ui/console/outputlevel.rb +15 -0
  142. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/ui/console/testrunner.rb +733 -0
  143. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/ui/emacs/testrunner.rb +49 -0
  144. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/ui/testrunner.rb +53 -0
  145. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/ui/testrunnermediator.rb +114 -0
  146. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/ui/testrunnerutilities.rb +41 -0
  147. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/ui/xml/testrunner.rb +224 -0
  148. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/util/backtracefilter.rb +59 -0
  149. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/util/method-owner-finder.rb +28 -0
  150. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/util/observable.rb +90 -0
  151. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/util/output.rb +32 -0
  152. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/util/procwrapper.rb +48 -0
  153. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/version.rb +5 -0
  154. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/lib/test/unit/warning.rb +3 -0
  155. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/sample/adder.rb +13 -0
  156. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/sample/subtracter.rb +12 -0
  157. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/sample/test_adder.rb +20 -0
  158. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/sample/test_subtracter.rb +20 -0
  159. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/sample/test_user.rb +23 -0
  160. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/collector/test-descendant.rb +182 -0
  161. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/collector/test-load.rb +475 -0
  162. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/collector/test_dir.rb +407 -0
  163. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/collector/test_objectspace.rb +102 -0
  164. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/fixtures/header-label.csv +3 -0
  165. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/fixtures/header-label.tsv +3 -0
  166. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/fixtures/header.csv +3 -0
  167. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/fixtures/header.tsv +3 -0
  168. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/fixtures/no-header.csv +2 -0
  169. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/fixtures/no-header.tsv +2 -0
  170. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/fixtures/plus.csv +3 -0
  171. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/run-test.rb +22 -0
  172. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-assertions.rb +2187 -0
  173. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-attribute-matcher.rb +38 -0
  174. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-attribute.rb +123 -0
  175. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-code-snippet.rb +79 -0
  176. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-color-scheme.rb +123 -0
  177. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-color.rb +47 -0
  178. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-data.rb +419 -0
  179. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-diff.rb +518 -0
  180. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-emacs-runner.rb +60 -0
  181. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-error.rb +26 -0
  182. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-failure.rb +33 -0
  183. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-fault-location-detector.rb +163 -0
  184. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-fixture.rb +713 -0
  185. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-notification.rb +33 -0
  186. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-omission.rb +81 -0
  187. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-pending.rb +70 -0
  188. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-priority.rb +184 -0
  189. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-test-case.rb +1284 -0
  190. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-test-result.rb +113 -0
  191. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-test-suite-creator.rb +97 -0
  192. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/test-test-suite.rb +151 -0
  193. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/testunit-test-util.rb +33 -0
  194. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/ui/test_testrunmediator.rb +20 -0
  195. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/util/test-method-owner-finder.rb +38 -0
  196. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/util/test-output.rb +11 -0
  197. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/util/test_backtracefilter.rb +52 -0
  198. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/util/test_observable.rb +102 -0
  199. data/vendor/bundle/ruby/3.0.0/gems/test-unit-3.4.1/test/util/test_procwrapper.rb +36 -0
  200. data/vendor/bundle/ruby/3.0.0/specifications/power_assert-2.0.0.gemspec +46 -0
  201. data/vendor/bundle/ruby/3.0.0/specifications/rake-13.0.3.gemspec +26 -0
  202. data/vendor/bundle/ruby/3.0.0/specifications/test-unit-3.4.1.gemspec +41 -0
  203. data/win32-api.gemspec +1 -1
  204. metadata +199 -8
  205. data/ext/Makefile +0 -269
  206. data/ext/api-x64-mingw32.def +0 -2
  207. data/ext/api.o +0 -0
  208. data/ext/api.so +0 -0
  209. data/ext/win32/api.so +0 -0
@@ -0,0 +1,3 @@
1
+ label,expected,label
2
+ upper case,HELLO,HELLO
3
+ lower case,Hello,hello
@@ -0,0 +1,3 @@
1
+ label expected label
2
+ upper case HELLO HELLO
3
+ lower case Hello hello
@@ -0,0 +1,3 @@
1
+ label,expected,target
2
+ empty string,true,""
3
+ plain string,false,hello
@@ -0,0 +1,3 @@
1
+ label expected target
2
+ empty string true ""
3
+ plain string false hello
@@ -0,0 +1,2 @@
1
+ empty string,true,""
2
+ plain string,false,hello
@@ -0,0 +1,2 @@
1
+ empty string true ""
2
+ plain string false hello
@@ -0,0 +1,3 @@
1
+ label,expected,augend,addend
2
+ positive positive,4,3,1
3
+ positive negative,-1,1,-2
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $VERBOSE = true
4
+
5
+ $KCODE = "utf8" unless "".respond_to?(:encoding)
6
+
7
+ base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
8
+ lib_dir = File.join(base_dir, "lib")
9
+ test_dir = File.join(base_dir, "test")
10
+
11
+ $LOAD_PATH.unshift(lib_dir)
12
+
13
+ require 'test/unit'
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
+
22
+ exit Test::Unit::AutoRunner.run(true, test_dir)
@@ -0,0 +1,2187 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Author:: Nathaniel Talbott.
4
+ # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
5
+ # Copyright (c) 2009-2014 Kouhei Sutou. All rights reserved.
6
+ # License:: Ruby license.
7
+
8
+ require 'test/unit'
9
+ require "testunit-test-util"
10
+
11
+ module Test
12
+ module Unit
13
+ module AssertionCheckable
14
+ include TestUnitTestUtil
15
+
16
+ private
17
+ def check(value, message="")
18
+ add_assertion
19
+ raise AssertionFailedError.new(message) unless value
20
+ end
21
+
22
+ def check_assertions(expect_fail, options={})
23
+ expected_message = options[:expected_message]
24
+ actual_message_normalizer = options[:actual_message_normalizer]
25
+ return_value_expected = options[:return_value_expected]
26
+ @actual_assertion_count = 0
27
+ failed = true
28
+ actual_message = nil
29
+ @catch_assertions = true
30
+ return_value = nil
31
+ begin
32
+ return_value = yield
33
+ failed = false
34
+ rescue AssertionFailedError => error
35
+ return_value = error
36
+ actual_message = error.message
37
+ end
38
+ @catch_assertions = false
39
+
40
+ if expect_fail
41
+ message = "Should have failed, but didn't"
42
+ else
43
+ message = "Should not have failed, but did with message\n" +
44
+ "<#{actual_message}>"
45
+ end
46
+ check(expect_fail == failed, message)
47
+
48
+ message = "Should have made one assertion but made\n" +
49
+ "<#{@actual_assertion_count}>"
50
+ check(1 == @actual_assertion_count, message)
51
+
52
+ if expect_fail
53
+ if actual_message_normalizer
54
+ actual_message = actual_message_normalizer.call(actual_message)
55
+ end
56
+ case expected_message
57
+ when String
58
+ check(expected_message == actual_message,
59
+ "Should have the correct message.\n" +
60
+ "<#{expected_message.inspect}> expected but was\n" +
61
+ "<#{actual_message.inspect}>")
62
+ when Regexp
63
+ check(expected_message =~ actual_message,
64
+ "The message should match correctly.\n" +
65
+ "</#{expected_message.source}/> expected to match\n" +
66
+ "<#{actual_message.inspect}>")
67
+ else
68
+ check(false,
69
+ "Incorrect expected message type in assert_nothing_failed")
70
+ end
71
+ else
72
+ case return_value_expected
73
+ when :dont_care
74
+ # do nothing
75
+ when true
76
+ check(!return_value.nil?, "Should return a value")
77
+ else
78
+ check(return_value.nil?,
79
+ "Should not return a value but returned <#{return_value}>")
80
+ end
81
+ end
82
+
83
+ return_value
84
+ end
85
+
86
+ def check_nothing_fails(return_value_expected=false, &proc)
87
+ check_assertions(false,
88
+ {:expected_message => nil,
89
+ :return_value_expected => return_value_expected},
90
+ &proc)
91
+ end
92
+
93
+ def check_fail(expected_message, options={}, &proc)
94
+ check_assertions(true,
95
+ options.merge(:expected_message => expected_message),
96
+ &proc)
97
+ end
98
+
99
+ def check_fail_exception(expected_message, options={}, &proc)
100
+ normalizer = lambda do |actual_message|
101
+ actual_message.gsub(/^(?:<internal:core> )?[^:\n]+:\d+:.+\n/, "")
102
+ end
103
+ check_assertions(true,
104
+ options.merge(:expected_message => expected_message,
105
+ :actual_message_normalizer => normalizer),
106
+ &proc)
107
+ end
108
+
109
+ def inspect_tag(tag)
110
+ tag.inspect
111
+ end
112
+
113
+ def add_failure(message, location=caller, options=nil)
114
+ unless @catch_assertions
115
+ super
116
+ end
117
+ end
118
+
119
+ def add_assertion
120
+ if @catch_assertions
121
+ @actual_assertion_count += 1
122
+ else
123
+ super
124
+ end
125
+ end
126
+ end
127
+
128
+ class TestAssertions < TestCase
129
+ include AssertionCheckable
130
+
131
+ class TestAssertBlock < self
132
+ def test_pass_without_message
133
+ check_nothing_fails {
134
+ assert_block {true}
135
+ }
136
+ end
137
+
138
+ def test_pass_with_message
139
+ check_nothing_fails {
140
+ assert_block("successful assert_block") {true}
141
+ }
142
+ end
143
+
144
+ def test_failure_without_message
145
+ check_fail("assert_block failed.") {
146
+ assert_block {false}
147
+ }
148
+ end
149
+
150
+ def test_failure_with_message
151
+ check_fail("failed assert_block") {
152
+ assert_block("failed assert_block") {false}
153
+ }
154
+ end
155
+ end
156
+
157
+ class TestAssertEqual < self
158
+ class TestSuccess < self
159
+ def test_without_message
160
+ check_nothing_fails {
161
+ assert_equal("string1", "string1")
162
+ }
163
+ end
164
+
165
+ def test_with_message
166
+ check_nothing_fails {
167
+ assert_equal("string1", "string1", "successful assert_equal")
168
+ }
169
+ end
170
+ end
171
+
172
+ class TestFailure < self
173
+ def test_without_message
174
+ message = <<-EOM.chomp
175
+ <"string1"> expected but was
176
+ <"string2">.
177
+
178
+ diff:
179
+ - string1
180
+ ? ^
181
+ + string2
182
+ ? ^
183
+ EOM
184
+ check_fail(message) {
185
+ assert_equal("string1", "string2")
186
+ }
187
+ end
188
+
189
+ def test_with_message
190
+ message = <<-EOM.chomp
191
+ failed assert_equal.
192
+ <"string1"> expected but was
193
+ <"string2">.
194
+
195
+ diff:
196
+ - string1
197
+ ? ^
198
+ + string2
199
+ ? ^
200
+ EOM
201
+ check_fail(message) {
202
+ assert_equal("string1", "string2", "failed assert_equal")
203
+ }
204
+ end
205
+
206
+ def test_with_message_proc
207
+ message = <<-EOM.chomp
208
+ failed assert_equal.
209
+ <"string1"> expected but was
210
+ <"string2">.
211
+
212
+ diff:
213
+ - string1
214
+ ? ^
215
+ + string2
216
+ ? ^
217
+ EOM
218
+ check_fail(message) do
219
+ assert_equal("string1", "string2", lambda {"failed assert_equal"})
220
+ end
221
+ end
222
+ end
223
+
224
+ class TestSystemMessage < self
225
+ def test_different_type
226
+ message = <<-EOM.chomp
227
+ <"111111"> expected but was
228
+ <111111>.
229
+
230
+ diff:
231
+ - "111111"
232
+ ? - -
233
+ + 111111
234
+ EOM
235
+ check_fail(message) do
236
+ assert_equal("111111", 111111)
237
+ end
238
+ end
239
+
240
+ def test_long_line
241
+ expected = ["0123456789",
242
+ "1123456789",
243
+ "2123456789",
244
+ "3123456789",
245
+ "4123456789",
246
+ "5123456789",
247
+ "6123456789",
248
+ "7123456789",
249
+ "8123456789"].join
250
+ actual = ["0000000000",
251
+ "1123456789",
252
+ "2123456789",
253
+ "3123456789",
254
+ "4123456789",
255
+ "5123456789",
256
+ "6123456789",
257
+ "7123456789",
258
+ "8123456789"].join
259
+ message = <<-EOM.chomp
260
+ <"#{expected}"> expected but was
261
+ <"#{actual}">.
262
+
263
+ diff:
264
+ - #{expected}
265
+ ? ^^^^^^^^^
266
+ + #{actual}
267
+ ? ^^^^^^^^^
268
+
269
+ folded diff:
270
+ - 012345678911234567892123456789312345678941234567895123456789612345678971234567
271
+ ? ^^^^^^^^^
272
+ + 000000000011234567892123456789312345678941234567895123456789612345678971234567
273
+ ? ^^^^^^^^^
274
+ 898123456789
275
+ EOM
276
+ check_fail(message) do
277
+ assert_equal(expected, actual)
278
+ end
279
+ end
280
+
281
+ def test_too_small_difference
282
+ message = <<-EOM.chomp
283
+ <1> expected but was
284
+ <2>.
285
+ EOM
286
+ check_fail(message) do
287
+ assert_equal(1, 2)
288
+ end
289
+ end
290
+
291
+ def test_same_inspected_objects
292
+ same_inspected_class = Class.new do
293
+ def inspect
294
+ "inspected"
295
+ end
296
+ end
297
+ object1 = same_inspected_class.new
298
+ object2 = same_inspected_class.new
299
+ message = <<-EOM.chomp
300
+ <inspected> expected but was
301
+ <inspected>.
302
+ EOM
303
+ check_fail(message) do
304
+ assert_equal(object1, object2)
305
+ end
306
+ end
307
+
308
+ def test_multi_lines_result
309
+ message = <<-EOM.chomp
310
+ <#{AssertionMessage.convert("a\nb")}> expected but was
311
+ <#{AssertionMessage.convert("x")}>.
312
+
313
+ diff:
314
+ + x
315
+ - a
316
+ - b
317
+ EOM
318
+ check_fail(message) do
319
+ assert_equal("a\nb", "x")
320
+ end
321
+ end
322
+
323
+ def test_large_string
324
+ message = <<-EOM.chomp
325
+ <#{AssertionMessage.convert("a\n" + "x" * 997)}> expected but was
326
+ <#{AssertionMessage.convert("x")}>.
327
+
328
+ diff:
329
+ + x
330
+ - a
331
+ - #{"x" * 997}
332
+
333
+ folded diff:
334
+ + x
335
+ - a
336
+ #{(["- " + ("x" * 78)] * 12).join("\n")}
337
+ - #{"x" * 61}
338
+ EOM
339
+ check_fail(message) do
340
+ assert_equal("a\n" + "x" * 997, "x")
341
+ end
342
+
343
+ message = <<-EOM.chomp
344
+ <#{AssertionMessage.convert("a\n" + "x" * 998)}> expected but was
345
+ <#{AssertionMessage.convert("x")}>.
346
+ EOM
347
+ check_fail(message) do
348
+ assert_equal("a\n" + "x" * 998, "x")
349
+ end
350
+ end
351
+
352
+ def test_max_diff_target_string_size
353
+ key = "TEST_UNIT_MAX_DIFF_TARGET_STRING_SIZE"
354
+ before_value = ENV[key]
355
+ ENV[key] = "100"
356
+ begin
357
+ message = <<-EOM.chomp
358
+ <#{AssertionMessage.convert("a\n" + "x" * 97)}> expected but was
359
+ <#{AssertionMessage.convert("x")}>.
360
+
361
+ diff:
362
+ + x
363
+ - a
364
+ - #{"x" * 97}
365
+
366
+ folded diff:
367
+ + x
368
+ - a
369
+ #{(["- " + ("x" * 78)]).join("\n")}
370
+ - #{"x" * 19}
371
+ EOM
372
+ check_fail(message) do
373
+ assert_equal("a\n" + "x" * 97, "x")
374
+ end
375
+
376
+ message = <<-EOM.chomp
377
+ <#{AssertionMessage.convert("a\n" + "x" * 98)}> expected but was
378
+ <#{AssertionMessage.convert("x")}>.
379
+ EOM
380
+ check_fail(message) do
381
+ assert_equal("a\n" + "x" * 98, "x")
382
+ end
383
+ ensure
384
+ ENV[key] = before_value
385
+ end
386
+ end
387
+
388
+ def test_different_encoding
389
+ utf8_string = "こんにちは"
390
+ unless utf8_string.respond_to?(:force_encoding)
391
+ omit("encoding test is for Ruby >= 1.9")
392
+ end
393
+ ascii_8bit_string = utf8_string.dup.force_encoding("ascii-8bit")
394
+ message = <<-EOM.chomp
395
+ <#{utf8_string.inspect}>("UTF-8") expected but was
396
+ <#{ascii_8bit_string.inspect}>("ASCII-8BIT").
397
+ EOM
398
+ check_fail(message) do
399
+ assert_equal(utf8_string, ascii_8bit_string)
400
+ end
401
+ end
402
+
403
+ def test_different_hash
404
+ designers = {
405
+ "Ruby" => "Matz",
406
+ "Lisp" => "John McCarthy",
407
+ }
408
+ categories = {
409
+ "LL" => ["Ruby", "Python"],
410
+ "Heavy" => ["C", "C++"],
411
+ }
412
+ message = <<-EOM.chomp
413
+ <{"Lisp"=>"John McCarthy", "Ruby"=>"Matz"}> expected but was
414
+ <{"Heavy"=>["C", "C++"], "LL"=>["Ruby", "Python"]}>.
415
+ EOM
416
+ check_fail(message) do
417
+ assert_equal(designers, categories)
418
+ end
419
+ end
420
+
421
+ def test_recursive_hash
422
+ alice = {"name" => "Alice"}
423
+ bob = {"name" => "Bob"}
424
+ alice["followers"] = [bob]
425
+ bob["followers"] = [alice]
426
+ message = <<-EOM.chomp
427
+ <{"followers"=>[{"followers"=>[{...}], "name"=>"Bob"}], "name"=>"Alice"}> expected but was
428
+ <{"followers"=>[{"followers"=>[{...}], "name"=>"Alice"}], "name"=>"Bob"}>.
429
+
430
+ diff:
431
+ - {"followers"=>[{"followers"=>[{...}], "name"=>"Bob"}], "name"=>"Alice"}
432
+ ? -----------------
433
+ + {"followers"=>[{"followers"=>[{...}], "name"=>"Alice"}], "name"=>"Bob"}
434
+ ? +++++++++++++++++
435
+ EOM
436
+ check_fail(message) do
437
+ assert_equal(alice, bob)
438
+ end
439
+ end
440
+
441
+ def test_numeric
442
+ numeric_family_class = Class.new(Numeric) do
443
+ def inspect
444
+ "inspect is called"
445
+ end
446
+
447
+ def to_s
448
+ "to_s is called"
449
+ end
450
+ end
451
+ numeric = numeric_family_class.new
452
+
453
+ message = <<-MESSAGE.chomp
454
+ <to_s is called> expected but was
455
+ <"must be failed">.
456
+ MESSAGE
457
+ check_fail(message) do
458
+ assert_equal(numeric, "must be failed")
459
+ end
460
+ end
461
+ end
462
+ end
463
+
464
+ def test_assert_raise_success
465
+ return_value = nil
466
+ check_nothing_fails(true) do
467
+ return_value = assert_raise(RuntimeError) do
468
+ raise "Error"
469
+ end
470
+ end
471
+ check(return_value.kind_of?(Exception),
472
+ "Should have returned the exception " +
473
+ "from a successful assert_raise")
474
+ check(return_value.message == "Error",
475
+ "Should have returned the correct exception " +
476
+ "from a successful assert_raise")
477
+
478
+ check_nothing_fails(true) do
479
+ assert_raise(ArgumentError, "successful assert_raise") do
480
+ raise ArgumentError.new("Error")
481
+ end
482
+ end
483
+
484
+ check_nothing_fails(true) do
485
+ assert_raise(RuntimeError) do
486
+ raise "Error"
487
+ end
488
+ end
489
+
490
+ check_nothing_fails(true) do
491
+ assert_raise(RuntimeError, "successful assert_raise") do
492
+ raise "Error"
493
+ end
494
+ end
495
+
496
+ check_nothing_fails(true) do
497
+ assert_raise do
498
+ raise Exception, "Any exception"
499
+ end
500
+ end
501
+ end
502
+
503
+ def test_assert_raise_fail
504
+ check_fail("<RuntimeError> exception was expected but none was thrown.") do
505
+ assert_raise(RuntimeError) do
506
+ 1 + 1
507
+ end
508
+ end
509
+
510
+ message = <<-EOM.chomp
511
+ failed assert_raise.
512
+ <ArgumentError> exception expected but was
513
+ <RuntimeError(<Error>)
514
+ >.
515
+ EOM
516
+ check_fail_exception(message) do
517
+ assert_raise(ArgumentError, "failed assert_raise") do
518
+ raise "Error"
519
+ end
520
+ end
521
+
522
+ message = <<-EOM
523
+ <Object> must be a subclass of Exception, an object of Exception subclasses or a Module.
524
+ EOM
525
+ check_fail(message.chomp) do
526
+ assert_nothing_raised(Object) do
527
+ 1 + 1
528
+ end
529
+ end
530
+ end
531
+
532
+ def test_assert_raise_module
533
+ exceptions = [ArgumentError, TypeError]
534
+ modules = [Math, Comparable]
535
+ rescues = exceptions + modules
536
+
537
+ exceptions.each do |exc|
538
+ return_value = nil
539
+ check_nothing_fails(true) do
540
+ return_value = assert_raise(*rescues) do
541
+ raise exc, "Error"
542
+ end
543
+ end
544
+ check(return_value.instance_of?(exc),
545
+ "Should have returned #{exc} but was #{return_value.class}")
546
+ check(return_value.message == "Error",
547
+ "Should have returned the correct exception " +
548
+ "from a successful assert_raise")
549
+ end
550
+
551
+ modules.each do |mod|
552
+ return_value = nil
553
+ check_nothing_fails(true) do
554
+ return_value = assert_raise(*rescues) do
555
+ raise Exception.new("Error").extend(mod)
556
+ end
557
+ end
558
+ check(mod === return_value,
559
+ "Should have returned #{mod}")
560
+ check(return_value.message == "Error",
561
+ "Should have returned the correct exception " +
562
+ "from a successful assert_raise")
563
+ end
564
+
565
+ check_fail("<[ArgumentError, TypeError, Math, Comparable]> exception " +
566
+ "was expected but none was thrown.") do
567
+ assert_raise(*rescues) do
568
+ 1 + 1
569
+ end
570
+ end
571
+
572
+ message = <<-EOM.chomp
573
+ failed assert_raise.
574
+ <[ArgumentError, TypeError]> exception expected but was
575
+ <RuntimeError(<Error>)
576
+ >.
577
+ EOM
578
+ check_fail_exception(message) do
579
+ assert_raise(ArgumentError, TypeError, "failed assert_raise") do
580
+ raise "Error"
581
+ end
582
+ end
583
+ end
584
+
585
+ def test_assert_raise_instance
586
+ return_value = nil
587
+ check_nothing_fails(true) do
588
+ return_value = assert_raise(RuntimeError.new("Error")) do
589
+ raise "Error"
590
+ end
591
+ end
592
+ check(return_value.kind_of?(Exception),
593
+ "Should have returned the exception " +
594
+ "from a successful assert_raise")
595
+ check(return_value.message == "Error",
596
+ "Should have returned the correct exception " +
597
+ "from a successful assert_raise")
598
+
599
+ message = <<-EOM.chomp
600
+ <RuntimeError(<XXX>)> exception expected but was
601
+ <RuntimeError(<Error>)
602
+ >.
603
+ EOM
604
+ check_fail_exception(message) do
605
+ return_value = assert_raise(RuntimeError.new("XXX")) do
606
+ raise "Error"
607
+ end
608
+ end
609
+
610
+ different_error_class = Class.new(StandardError)
611
+ message = <<-EOM.chomp
612
+ <#{different_error_class.inspect}(<Error>)> exception expected but was
613
+ <RuntimeError(<Error>)
614
+ >.
615
+ EOM
616
+ check_fail_exception(message) do
617
+ assert_raise(different_error_class.new("Error")) do
618
+ raise "Error"
619
+ end
620
+ end
621
+
622
+ different_error = different_error_class.new("Error")
623
+ def different_error.inspect
624
+ "DifferentError: \"Error\""
625
+ end
626
+ message = <<-EOM.chomp
627
+ <DifferentError: "Error"> exception expected but was
628
+ <RuntimeError(<Error>)
629
+ >.
630
+ EOM
631
+ check_fail_exception(message) do
632
+ assert_raise(different_error) do
633
+ raise "Error"
634
+ end
635
+ end
636
+
637
+ check_nothing_fails(true) do
638
+ assert_raise(different_error_class.new("Error"),
639
+ RuntimeError.new("Error"),
640
+ RuntimeError.new("XXX")) do
641
+ raise "Error"
642
+ end
643
+ end
644
+ end
645
+
646
+ def test_assert_raise_jruby
647
+ jruby_only_test
648
+
649
+ exception = Java::JavaLang::StringIndexOutOfBoundsException
650
+
651
+ return_value = nil
652
+ check_nothing_fails(true) do
653
+ return_value = assert_raise(exception) do
654
+ Java::JavaLang::String.new("abc").char_at(4)
655
+ end
656
+ end
657
+ check(return_value.instance_of?(exception),
658
+ "Should have returned #{exception} but was #{return_value.class}")
659
+ end
660
+
661
+ def test_assert_instance_of
662
+ check_nothing_fails {
663
+ assert_instance_of(String, "string")
664
+ }
665
+ check_nothing_fails {
666
+ assert_instance_of(String, "string", "successful assert_instance_of")
667
+ }
668
+ check_nothing_fails {
669
+ assert_instance_of(String, "string", "successful assert_instance_of")
670
+ }
671
+ check_fail(%Q{<"string"> was expected to be instance_of?\n<Hash> but was\n<String>.}) {
672
+ assert_instance_of(Hash, "string")
673
+ }
674
+ check_fail(%Q{failed assert_instance_of.\n<"string"> was expected to be instance_of?\n<Hash> but was\n<String>.}) {
675
+ assert_instance_of(Hash, "string", "failed assert_instance_of")
676
+ }
677
+
678
+ check_nothing_fails do
679
+ assert_instance_of([Class, NilClass], Array)
680
+ end
681
+ check_fail(%Q{<"string"> was expected to be instance_of?\n[<Class>, <NilClass>] but was\n<String>.}) do
682
+ assert_instance_of([Class, NilClass], "string")
683
+ end
684
+ check_fail(%Q{<Array> was expected to be instance_of?\n[<Module>, <NilClass>] but was\n<Class>.}) do
685
+ assert_instance_of([Module, NilClass], Array)
686
+ end
687
+ end
688
+
689
+ def test_assert_not_instance_of
690
+ check_nothing_fails {
691
+ assert_not_instance_of(NilClass, "string")
692
+ }
693
+ check_nothing_fails {
694
+ assert_not_instance_of(NilClass, "string", "successful assert_instance_of")
695
+ }
696
+ check_fail(%Q{<"string"> was expected to not be instance_of?\n<String> but was.}) {
697
+ assert_not_instance_of(String, "string")
698
+ }
699
+ check_fail(%Q{failed assert.\n<"string"> was expected to not be instance_of?\n<String> but was.}) {
700
+ assert_not_instance_of(String, "string", "failed assert")
701
+ }
702
+
703
+ check_nothing_fails do
704
+ assert_not_instance_of([Module, NilClass], Array)
705
+ end
706
+ check_fail(%Q{<Array> was expected to not be instance_of?\n[<Class>, <NilClass>] but was.}) do
707
+ assert_not_instance_of([Class, NilClass], Array)
708
+ end
709
+ check_fail(%Q{<"str"> was expected to not be instance_of?\n[<Numeric>, <String>] but was.}) do
710
+ assert_not_instance_of([Numeric, String], 'str')
711
+ end
712
+ end
713
+
714
+ def test_assert_nil
715
+ check_nothing_fails {
716
+ assert_nil(nil)
717
+ }
718
+ check_nothing_fails {
719
+ assert_nil(nil, "successful assert_nil")
720
+ }
721
+ check_nothing_fails {
722
+ assert_nil(nil, "successful assert_nil")
723
+ }
724
+ check_fail(%Q{<"string"> was expected to be nil.}) {
725
+ assert_nil("string")
726
+ }
727
+ check_fail(%Q{failed assert_nil.\n<"string"> was expected to be nil.}) {
728
+ assert_nil("string", "failed assert_nil")
729
+ }
730
+ end
731
+
732
+ def test_assert_not_nil
733
+ check_nothing_fails{assert_not_nil(false)}
734
+ check_nothing_fails{assert_not_nil(false, "message")}
735
+ check_fail("<nil> was expected to not be nil."){assert_not_nil(nil)}
736
+ check_fail("message.\n<nil> was expected to not be nil.") {assert_not_nil(nil, "message")}
737
+ end
738
+
739
+ def test_assert_kind_of
740
+ check_nothing_fails {
741
+ assert_kind_of(Module, Array)
742
+ }
743
+ check_nothing_fails {
744
+ assert_kind_of(Object, "string", "successful assert_kind_of")
745
+ }
746
+ check_nothing_fails {
747
+ assert_kind_of(String, "string", "successful assert_kind_of")
748
+ }
749
+ check_nothing_fails {
750
+ assert_kind_of(Comparable, 1)
751
+ }
752
+ check_fail(%Q{<"string"> was expected to be kind_of?\n<Class> but was\n<String>.}) {
753
+ assert_kind_of(Class, "string")
754
+ }
755
+ check_fail(%Q{failed assert_kind_of.\n<"string"> was expected to be kind_of?\n<Class> but was\n<String>.}) {
756
+ assert_kind_of(Class, "string", "failed assert_kind_of")
757
+ }
758
+
759
+ check_nothing_fails do
760
+ assert_kind_of([Class, NilClass], Array)
761
+ end
762
+ check_fail(%Q{<"string"> was expected to be kind_of?\n[<Class>, <NilClass>] but was\n<String>.}) do
763
+ assert_kind_of([Class, NilClass], "string")
764
+ end
765
+ end
766
+
767
+ def test_assert_not_kind_of
768
+ check_nothing_fails {
769
+ assert_not_kind_of(Class, 42)
770
+ }
771
+ check_nothing_fails {
772
+ assert_not_kind_of(Symbol, "string", "successful assert_not_kind_of")
773
+ }
774
+ check_nothing_fails {
775
+ assert_not_kind_of(Integer, 1.1)
776
+ }
777
+ check_fail(%Q{<1> was expected to not be kind_of?\n<Integer> but was.}) {
778
+ assert_not_kind_of(Integer, 1)
779
+ }
780
+ check_fail(%Q{failed assert_not_kind_of.\n<"string"> was expected to not be kind_of?\n<String> but was.}) {
781
+ assert_not_kind_of(String, "string", "failed assert_not_kind_of")
782
+ }
783
+
784
+ check_nothing_fails do
785
+ assert_not_kind_of([String, NilClass], 100)
786
+ end
787
+ check_fail(%Q{<Array> was expected to not be kind_of?\n[<Class>, <NilClass>] but was.}) do
788
+ assert_not_kind_of([Class, NilClass], Array)
789
+ end
790
+ end
791
+
792
+ def test_assert_match
793
+ check_nothing_fails {
794
+ assert_match(/strin./, "string")
795
+ }
796
+ check_nothing_fails {
797
+ assert_match("strin", "string")
798
+ }
799
+ check_nothing_fails {
800
+ assert_match(/strin./, "string", "successful assert_match")
801
+ }
802
+ check_nothing_fails {
803
+ assert_match(/strin./, "string", "successful assert_match")
804
+ }
805
+ check_fail(%Q{</slin./> was expected to be =~\n<"string">.}) {
806
+ assert_match(/slin./, "string")
807
+ }
808
+ check_fail(%Q{</strin\\./> was expected to be =~\n<"string">.}) {
809
+ assert_match("strin.", "string")
810
+ }
811
+ check_fail(%Q{failed assert_match.\n</slin./> was expected to be =~\n<"string">.}) {
812
+ assert_match(/slin./, "string", "failed assert_match")
813
+ }
814
+ end
815
+
816
+ def test_assert_same
817
+ thing = "thing"
818
+ check_nothing_fails {
819
+ assert_same(thing, thing)
820
+ }
821
+ check_nothing_fails {
822
+ assert_same(thing, thing, "successful assert_same")
823
+ }
824
+ check_nothing_fails {
825
+ assert_same(thing, thing, "successful assert_same")
826
+ }
827
+ thing2 = thing.dup
828
+ check_fail(%Q{<"thing">\nwith id <#{thing.__id__}> was expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
829
+ assert_same(thing, thing2)
830
+ }
831
+ check_fail(%Q{failed assert_same.\n<"thing">\nwith id <#{thing.__id__}> was expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
832
+ assert_same(thing, thing2, "failed assert_same")
833
+ }
834
+ end
835
+
836
+ def test_assert_nothing_raised
837
+ check_nothing_fails(:dont_care) {
838
+ assert_nothing_raised {
839
+ 1 + 1
840
+ }
841
+ }
842
+ check_nothing_fails(:dont_care) {
843
+ assert_nothing_raised("successful assert_nothing_raised") {
844
+ 1 + 1
845
+ }
846
+ }
847
+ check_nothing_fails(:dont_care) {
848
+ assert_nothing_raised("successful assert_nothing_raised") {
849
+ 1 + 1
850
+ }
851
+ }
852
+ check_nothing_fails(:dont_care) {
853
+ begin
854
+ assert_nothing_raised(RuntimeError, StandardError, Comparable, "successful assert_nothing_raised") {
855
+ raise ZeroDivisionError.new("ArgumentError")
856
+ }
857
+ rescue ZeroDivisionError
858
+ end
859
+ }
860
+ expected_message =
861
+ "<Object> must be a subclass of Exception, " +
862
+ "an object of Exception subclasses or a Module."
863
+ check_fail(expected_message) {
864
+ assert_nothing_raised(Object) {
865
+ 1 + 1
866
+ }
867
+ }
868
+ expected_message = <<-EOM.chomp
869
+ Exception raised:
870
+ RuntimeError(<Error>)
871
+
872
+ EOM
873
+ check_fail_exception(expected_message) {
874
+ assert_nothing_raised {
875
+ raise "Error"
876
+ }
877
+ }
878
+ expected_message = <<-EOM.chomp
879
+ failed assert_nothing_raised.
880
+ Exception raised:
881
+ RuntimeError(<Error>)
882
+
883
+ EOM
884
+ check_fail_exception(expected_message) {
885
+ assert_nothing_raised("failed assert_nothing_raised") {
886
+ raise "Error"
887
+ }
888
+ }
889
+ expected_message = <<-EOM.chomp
890
+ Exception raised:
891
+ RuntimeError(<Error>)
892
+
893
+ EOM
894
+ check_fail_exception(expected_message) {
895
+ assert_nothing_raised(StandardError, RuntimeError) {
896
+ raise "Error"
897
+ }
898
+ }
899
+ check_fail("Failure.") do
900
+ assert_nothing_raised do
901
+ flunk("Failure")
902
+ end
903
+ end
904
+ end
905
+
906
+ def test_flunk
907
+ check_fail("Flunked.") {
908
+ flunk
909
+ }
910
+ check_fail("flunk message.") {
911
+ flunk("flunk message")
912
+ }
913
+ end
914
+
915
+ def test_assert_not_same
916
+ thing = "thing"
917
+ thing2 = thing.dup
918
+ check_nothing_fails {
919
+ assert_not_same(thing, thing2)
920
+ }
921
+ check_nothing_fails {
922
+ assert_not_same(thing, thing2, "message")
923
+ }
924
+ check_fail(%Q{<"thing">\nwith id <#{thing.__id__}> was expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
925
+ assert_not_same(thing, thing)
926
+ }
927
+ check_fail(%Q{message.\n<"thing">\nwith id <#{thing.__id__}> was expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
928
+ assert_not_same(thing, thing, "message")
929
+ }
930
+ end
931
+
932
+ def test_assert_not_equal
933
+ check_nothing_fails {
934
+ assert_not_equal("string1", "string2")
935
+ }
936
+ check_nothing_fails {
937
+ assert_not_equal("string1", "string2", "message")
938
+ }
939
+ check_fail(%Q{<"string"> was expected to be != to\n<"string">.}) {
940
+ assert_not_equal("string", "string")
941
+ }
942
+ check_fail(%Q{message.\n<"string"> was expected to be != to\n<"string">.}) {
943
+ assert_not_equal("string", "string", "message")
944
+ }
945
+ end
946
+
947
+ def test_assert_not_match_pass
948
+ check_nothing_fails do
949
+ assert_not_match(/sling/, "string")
950
+ end
951
+ end
952
+
953
+ def test_assert_not_match_pass_with_message
954
+ check_nothing_fails do
955
+ assert_not_match(/sling/, "string", "message")
956
+ end
957
+ end
958
+
959
+ def test_assert_not_match_fail_match
960
+ check_fail("</string/> was expected to not match\n" +
961
+ "<\"string\">.") do
962
+ assert_not_match(/string/, "string")
963
+ end
964
+ end
965
+
966
+ def test_assert_not_match_fail_match_string
967
+ check_fail("</asdf/> was expected to not match\n" +
968
+ "<\"asdf\">.") do
969
+ assert_not_match("asdf", "asdf")
970
+ end
971
+ end
972
+
973
+ def test_assert_not_match_fail_match_with_message
974
+ check_fail("message.\n" +
975
+ "</string/> was expected to not match\n" +
976
+ "<\"string\">.") do
977
+ assert_not_match(/string/, "string", "message")
978
+ end
979
+ end
980
+
981
+ def test_assert_no_match
982
+ check_nothing_fails{assert_no_match(/sling/, "string")}
983
+ check_nothing_fails{assert_no_match(/sling/, "string", "message")}
984
+ check_fail(%Q{The first argument to assert_no_match should be a Regexp.\n<"asdf"> was expected to be instance_of?\n<Regexp> but was\n<String>.}) do
985
+ assert_no_match("asdf", "asdf")
986
+ end
987
+ check_fail(%Q{</string/> was expected to not match\n<"string">.}) do
988
+ assert_no_match(/string/, "string")
989
+ end
990
+ check_fail(%Q{message.\n</string/> was expected to not match\n<"string">.}) do
991
+ assert_no_match(/string/, "string", "message")
992
+ end
993
+ end
994
+
995
+ def test_assert_throw
996
+ check_nothing_fails do
997
+ assert_throw(:thing, "message") do
998
+ throw :thing
999
+ end
1000
+ end
1001
+
1002
+ tag = :thing2
1003
+ check_fail("message.\n" +
1004
+ "<:thing> was expected to be thrown but\n" +
1005
+ "<#{inspect_tag(tag)}> was thrown.") do
1006
+ assert_throw(:thing, "message") do
1007
+ throw :thing2
1008
+ end
1009
+ end
1010
+ check_fail("message.\n" +
1011
+ "<:thing> should have been thrown.") do
1012
+ assert_throw(:thing, "message") do
1013
+ 1 + 1
1014
+ end
1015
+ end
1016
+ end
1017
+
1018
+ def test_assert_nothing_thrown
1019
+ check_nothing_fails do
1020
+ assert_nothing_thrown("message") do
1021
+ 1 + 1
1022
+ end
1023
+ end
1024
+
1025
+ tag = :thing
1026
+ inspected = inspect_tag(tag)
1027
+ check_fail("message.\n" +
1028
+ "<#{inspected}> was thrown when nothing was expected.") do
1029
+ assert_nothing_thrown("message") do
1030
+ throw tag
1031
+ end
1032
+ end
1033
+ end
1034
+
1035
+ def test_assert_operator
1036
+ check_nothing_fails {
1037
+ assert_operator("thing", :==, "thing", "message")
1038
+ }
1039
+ check_fail(%Q{<0.15>\ngiven as the operator for #assert_operator must be a Symbol or #respond_to?(:to_str).}) do
1040
+ assert_operator("thing", 0.15, "thing")
1041
+ end
1042
+ check_fail(%Q{message.\n<"thing1"> was expected to be\n==\n<"thing2">.}) {
1043
+ assert_operator("thing1", :==, "thing2", "message")
1044
+ }
1045
+ end
1046
+
1047
+ def test_assert_not_operator
1048
+ check_nothing_fails {
1049
+ assert_not_operator("thing", :==, "Thing", "message")
1050
+ }
1051
+ check_fail(%Q{<42>\ngiven as the operator for #assert_not_operator must be a Symbol or #respond_to?(:to_str).}) do
1052
+ assert_not_operator("thing", 42, "message")
1053
+ end
1054
+ check_fail(%Q{message.\n<0> was expected to not be\n==\n<0.0>.}) {
1055
+ assert_not_operator(0, :==, 0.0, "message")
1056
+ }
1057
+ end
1058
+
1059
+ def test_assert_respond_to
1060
+ check_nothing_fails {
1061
+ assert_respond_to("thing", :to_s, "message")
1062
+ }
1063
+ check_nothing_fails {
1064
+ assert_respond_to("thing", "to_s", "message")
1065
+ }
1066
+ check_fail("<0.15>.kind_of?(Symbol) or\n" +
1067
+ "<0.15>.respond_to?(:to_str) expected") {
1068
+ assert_respond_to("thing", 0.15)
1069
+ }
1070
+ check_fail("message.\n" +
1071
+ "<:symbol>.respond_to?(:nonexistence) expected\n" +
1072
+ "(Class: <Symbol>)") {
1073
+ assert_respond_to(:symbol, :nonexistence, "message")
1074
+ }
1075
+ end
1076
+
1077
+ def test_assert_not_respond_to_pass_symbol
1078
+ check_nothing_fails do
1079
+ assert_not_respond_to("thing", :nonexistent, "message")
1080
+ end
1081
+ end
1082
+
1083
+ def test_assert_not_respond_to_pass_string
1084
+ check_nothing_fails do
1085
+ assert_not_respond_to("thing", :nonexistent, "message")
1086
+ end
1087
+ end
1088
+
1089
+ def test_assert_not_respond_to_fail_number
1090
+ check_fail("<0.15>.kind_of?(Symbol) or\n" +
1091
+ "<0.15>.respond_to?(:to_str) expected") do
1092
+ assert_respond_to("thing", 0.15)
1093
+ end
1094
+ end
1095
+
1096
+ def tset_assert_not_respond_to_fail_existence
1097
+ check_fail("message.\n" +
1098
+ "!<:symbol>.respond_to?(:to_s) expected\n" +
1099
+ "(Class: <Symbol>)") do
1100
+ assert_respond_to(:symbol, :to_s, "message")
1101
+ end
1102
+ end
1103
+
1104
+ def test_assert_send
1105
+ object = Object.new
1106
+ class << object
1107
+ private
1108
+ def return_argument(argument, bogus)
1109
+ return argument
1110
+ end
1111
+ end
1112
+ check_nothing_fails do
1113
+ assert_send([object, :return_argument, true, "bogus"], "message")
1114
+ end
1115
+
1116
+ inspected_object = AssertionMessage.convert(object)
1117
+ expected_message = <<-EOM
1118
+ message.
1119
+ <#{inspected_object}> was expected to respond to
1120
+ <return_argument(*[false, "bogus"])> with a true value but was
1121
+ <false>.
1122
+ EOM
1123
+ check_fail(expected_message.chomp) do
1124
+ assert_send([object, :return_argument, false, "bogus"], "message")
1125
+ end
1126
+ end
1127
+
1128
+ def test_condition_invariant
1129
+ object = Object.new
1130
+ def object.inspect
1131
+ @changed = true
1132
+ end
1133
+ def object.==(other)
1134
+ @changed ||= false
1135
+ return (!@changed)
1136
+ end
1137
+ check_nothing_fails do
1138
+ assert_equal(object, object, "message")
1139
+ end
1140
+ end
1141
+
1142
+ def test_assert_boolean
1143
+ check_nothing_fails do
1144
+ assert_boolean(true)
1145
+ end
1146
+ check_nothing_fails do
1147
+ assert_boolean(false)
1148
+ end
1149
+
1150
+ check_fail("<true> or <false> expected but was\n<1>") do
1151
+ assert_boolean(1)
1152
+ end
1153
+
1154
+ check_fail("<true> or <false> expected but was\n<nil>") do
1155
+ assert_boolean(nil)
1156
+ end
1157
+
1158
+ check_fail("message.\n<true> or <false> expected but was\n<\"XXX\">") do
1159
+ assert_boolean("XXX", "message")
1160
+ end
1161
+ end
1162
+
1163
+ def test_assert_true
1164
+ check_nothing_fails do
1165
+ assert_true(true)
1166
+ end
1167
+
1168
+ check_fail("<true> expected but was\n<false>") do
1169
+ assert_true(false)
1170
+ end
1171
+
1172
+ check_fail("<true> expected but was\n<1>") do
1173
+ assert_true(1)
1174
+ end
1175
+
1176
+ exception = check_fail("message.\n<true> expected but was\n<nil>") do
1177
+ assert_true(nil, "message")
1178
+ end
1179
+ assert_equal("message", exception.user_message)
1180
+ end
1181
+
1182
+ def test_assert_false
1183
+ check_nothing_fails do
1184
+ assert_false(false)
1185
+ end
1186
+
1187
+ check_fail("<false> expected but was\n<true>") do
1188
+ assert_false(true)
1189
+ end
1190
+
1191
+ check_fail("<false> expected but was\n<nil>") do
1192
+ assert_false(nil)
1193
+ end
1194
+
1195
+ check_fail("message.\n<false> expected but was\n<:false>") do
1196
+ assert_false(:false, "message")
1197
+ end
1198
+ end
1199
+
1200
+ def test_assert_compare
1201
+ check_nothing_fails do
1202
+ assert_compare(1.4, "<", 10.0)
1203
+ end
1204
+
1205
+ check_nothing_fails do
1206
+ assert_compare(2, "<=", 2)
1207
+ end
1208
+
1209
+ check_nothing_fails do
1210
+ assert_compare(14, ">=", 10.0)
1211
+ end
1212
+
1213
+ check_nothing_fails do
1214
+ assert_compare(14, ">", 13.9)
1215
+ end
1216
+
1217
+ expected_message = <<-EOM
1218
+ <15> < <10> should be true
1219
+ <15> was expected to be less than
1220
+ <10>.
1221
+ EOM
1222
+ check_fail(expected_message.chomp) do
1223
+ assert_compare(15, "<", 10)
1224
+ end
1225
+
1226
+ expected_message = <<-EOM
1227
+ <15> <= <10> should be true
1228
+ <15> was expected to be less than or equal to
1229
+ <10>.
1230
+ EOM
1231
+ check_fail(expected_message.chomp) do
1232
+ assert_compare(15, "<=", 10)
1233
+ end
1234
+
1235
+ expected_message = <<-EOM
1236
+ <10> > <15> should be true
1237
+ <10> was expected to be greater than
1238
+ <15>.
1239
+ EOM
1240
+ check_fail(expected_message.chomp) do
1241
+ assert_compare(10, ">", 15)
1242
+ end
1243
+
1244
+ expected_message = <<-EOM
1245
+ <10> >= <15> should be true
1246
+ <10> was expected to be greater than or equal to
1247
+ <15>.
1248
+ EOM
1249
+ check_fail(expected_message.chomp) do
1250
+ assert_compare(10, ">=", 15)
1251
+ end
1252
+ end
1253
+
1254
+ def test_assert_fail_assertion
1255
+ check_nothing_fails do
1256
+ assert_fail_assertion do
1257
+ flunk
1258
+ end
1259
+ end
1260
+
1261
+ check_fail("Failed assertion was expected.") do
1262
+ assert_fail_assertion do
1263
+ end
1264
+ end
1265
+ end
1266
+
1267
+ def test_assert_raise_message
1268
+ check_nothing_fails do
1269
+ assert_raise_message("Raise!") do
1270
+ raise "Raise!"
1271
+ end
1272
+ end
1273
+
1274
+ check_nothing_fails do
1275
+ assert_raise_message("Raise!") do
1276
+ raise Exception, "Raise!"
1277
+ end
1278
+ end
1279
+
1280
+ check_nothing_fails do
1281
+ assert_raise_message(/raise/i) do
1282
+ raise "Raise!"
1283
+ end
1284
+ end
1285
+
1286
+ expected_message = <<-EOM
1287
+ <"Expected message"> exception message expected but was
1288
+ <"Actual message">.
1289
+ EOM
1290
+ check_fail(expected_message.chomp) do
1291
+ assert_raise_message("Expected message") do
1292
+ raise "Actual message"
1293
+ end
1294
+ end
1295
+
1296
+ expected_message = <<-EOM
1297
+ <"Expected message"> exception message was expected but none was thrown.
1298
+ EOM
1299
+ check_fail(expected_message.chomp) do
1300
+ assert_raise_message("Expected message") do
1301
+ end
1302
+ end
1303
+ end
1304
+
1305
+ def test_assert_raise_kind_of
1306
+ check_nothing_fails(true) do
1307
+ assert_raise_kind_of(SystemCallError) do
1308
+ raise Errno::EACCES
1309
+ end
1310
+ end
1311
+
1312
+ expected_message = <<-EOM.chomp
1313
+ <SystemCallError> family exception expected but was
1314
+ <RuntimeError(<XXX>)
1315
+ >.
1316
+ EOM
1317
+ check_fail_exception(expected_message) do
1318
+ assert_raise_kind_of(SystemCallError) do
1319
+ raise RuntimeError, "XXX"
1320
+ end
1321
+ end
1322
+ end
1323
+
1324
+ def test_assert_const_defined
1325
+ check_nothing_fails do
1326
+ assert_const_defined(Test, :Unit)
1327
+ end
1328
+
1329
+ check_nothing_fails do
1330
+ assert_const_defined(Test, "Unit")
1331
+ end
1332
+
1333
+ check_fail("<Test>.const_defined?(<:Nonexistence>) expected.") do
1334
+ assert_const_defined(Test, :Nonexistence)
1335
+ end
1336
+ end
1337
+
1338
+ def test_assert_not_const_defined
1339
+ check_nothing_fails do
1340
+ assert_not_const_defined(Test, :Nonexistence)
1341
+ end
1342
+
1343
+ check_fail("!<Test>.const_defined?(<:Unit>) expected.") do
1344
+ assert_not_const_defined(Test, :Unit)
1345
+ end
1346
+
1347
+ check_fail("!<Test>.const_defined?(<\"Unit\">) expected.") do
1348
+ assert_not_const_defined(Test, "Unit")
1349
+ end
1350
+ end
1351
+
1352
+ def test_assert_predicate
1353
+ check_nothing_fails do
1354
+ assert_predicate([], :empty?)
1355
+ end
1356
+
1357
+ check_fail("<[1]>.empty? is true value expected but was\n<false>") do
1358
+ assert_predicate([1], :empty?)
1359
+ end
1360
+
1361
+ check_fail("<[1]>.respond_to?(:nonexistent?) expected\n" +
1362
+ "(Class: <Array>)") do
1363
+ assert_predicate([1], :nonexistent?)
1364
+ end
1365
+ end
1366
+
1367
+ def test_assert_not_predicate
1368
+ check_nothing_fails do
1369
+ assert_not_predicate([1], :empty?)
1370
+ end
1371
+
1372
+ check_fail("<[]>.empty? is false value expected but was\n<true>") do
1373
+ assert_not_predicate([], :empty?)
1374
+ end
1375
+
1376
+ check_fail("<[]>.respond_to?(:nonexistent?) expected\n" +
1377
+ "(Class: <Array>)") do
1378
+ assert_not_predicate([], :nonexistent?)
1379
+ end
1380
+ end
1381
+
1382
+ def test_assert_alias_method
1383
+ object = Object.new
1384
+ class << object
1385
+ def original_method
1386
+ end
1387
+ alias_method :alias_method, :original_method
1388
+
1389
+ def other
1390
+ end
1391
+ end
1392
+
1393
+ check_nothing_fails do
1394
+ assert_alias_method(object, :alias_method, :original_method)
1395
+ end
1396
+
1397
+ check_nothing_fails do
1398
+ assert_alias_method(object, :original_method, :alias_method)
1399
+ end
1400
+
1401
+ check_fail("<#{object.method(:other).inspect}> is alias of\n" +
1402
+ "<#{object.method(:original_method).inspect}> expected") do
1403
+ assert_alias_method(object, :other, :original_method)
1404
+ end
1405
+
1406
+ inspected_object = AssertionMessage.convert(object)
1407
+ check_fail("<#{inspected_object}>.nonexistent doesn't exist\n" +
1408
+ "(Class: <Object>)") do
1409
+ assert_alias_method(object, :nonexistent, :original_method)
1410
+ end
1411
+
1412
+ check_fail("<#{inspected_object}>.nonexistent doesn't exist\n" +
1413
+ "(Class: <Object>)") do
1414
+ assert_alias_method(object, :alias_method, :nonexistent)
1415
+ end
1416
+ end
1417
+
1418
+ def test_assert_path_exist
1419
+ check_nothing_fails do
1420
+ assert_path_exist(__FILE__)
1421
+ end
1422
+
1423
+ nonexistent_file = __FILE__ + ".nonexistent"
1424
+ check_fail("<#{nonexistent_file.inspect}> was expected to exist") do
1425
+ assert_path_exist(nonexistent_file)
1426
+ end
1427
+ end
1428
+
1429
+ def test_assert_path_not_exist
1430
+ nonexistent_file = __FILE__ + ".nonexistent"
1431
+ check_nothing_fails do
1432
+ assert_path_not_exist(nonexistent_file)
1433
+ end
1434
+
1435
+ check_fail("<#{__FILE__.inspect}> was expected to not exist") do
1436
+ assert_path_not_exist(__FILE__)
1437
+ end
1438
+ end
1439
+ end
1440
+
1441
+ class TestAssert < TestCase
1442
+ include AssertionCheckable
1443
+
1444
+ def test_pass
1445
+ check_nothing_fails do
1446
+ assert(true)
1447
+ end
1448
+ end
1449
+
1450
+ def test_pass_neither_false_or_nil
1451
+ check_nothing_fails do
1452
+ assert("a")
1453
+ end
1454
+ end
1455
+
1456
+ def test_pass_with_message
1457
+ check_nothing_fails do
1458
+ assert(true, "successful assert")
1459
+ end
1460
+ end
1461
+
1462
+ def test_pass_block
1463
+ check_nothing_fails do
1464
+ assert do
1465
+ true
1466
+ end
1467
+ end
1468
+ end
1469
+
1470
+ def test_fail_nil
1471
+ check_fail("<nil> is not true.") do
1472
+ assert(nil)
1473
+ end
1474
+ end
1475
+
1476
+ def test_fail_false
1477
+ check_fail("<false> is not true.") do
1478
+ assert(false)
1479
+ end
1480
+ end
1481
+
1482
+ def test_fail_false_with_message
1483
+ check_fail("failed assert.\n" +
1484
+ "<false> is not true.") do
1485
+ assert(false, "failed assert")
1486
+ end
1487
+ end
1488
+
1489
+ def test_fail_with_assertion_message
1490
+ check_fail("user message.\n" +
1491
+ "placeholder <:in> message") do
1492
+ assert(false, build_message("user message",
1493
+ "placeholder <?> message",
1494
+ :in))
1495
+ end
1496
+ end
1497
+
1498
+ def test_fail_block
1499
+ check_fail(//) do
1500
+ assert do
1501
+ 0.odd?
1502
+ end
1503
+ end
1504
+ end
1505
+
1506
+ def test_error_invalid_message_true
1507
+ check_fail("assertion message must be String, Proc or " +
1508
+ "Test::Unit::Assertions::AssertionMessage: " +
1509
+ "<true>(<TrueClass>)") do
1510
+ begin
1511
+ assert(true, true)
1512
+ rescue ArgumentError
1513
+ raise AssertionFailedError, $!.message
1514
+ end
1515
+ end
1516
+ end
1517
+
1518
+ def test_error_wrong_number_of_arguments
1519
+ check_fail("wrong number of arguments (0 for 1..2)") do
1520
+ begin
1521
+ assert
1522
+ rescue ArgumentError
1523
+ raise AssertionFailedError, $!.message
1524
+ end
1525
+ end
1526
+ end
1527
+
1528
+ class TestBlock < self
1529
+ def test_with_message
1530
+ if defined?(PowerAssert)
1531
+ system_message = <<-MESSAGE.chomp
1532
+ 1.to_s == "2"
1533
+ | |
1534
+ | false
1535
+ "1"
1536
+ MESSAGE
1537
+ else
1538
+ system_message = "<false> is not true."
1539
+ end
1540
+ check_fail("user message.\n#{system_message}") do
1541
+ assert("user message") do
1542
+ 1.to_s == "2"
1543
+ end
1544
+ end
1545
+ end
1546
+ end
1547
+ end
1548
+
1549
+ class TestRefute < TestCase
1550
+ include AssertionCheckable
1551
+
1552
+ class TestPass < self
1553
+ def test_nil
1554
+ check_nothing_fails do
1555
+ refute(nil)
1556
+ end
1557
+ end
1558
+
1559
+ def test_false
1560
+ check_nothing_fails do
1561
+ refute(false)
1562
+ end
1563
+ end
1564
+
1565
+ def test_with_message
1566
+ check_nothing_fails do
1567
+ refute(nil, "successful refute")
1568
+ end
1569
+ end
1570
+ end
1571
+
1572
+ class TestFailure < self
1573
+ def test_true
1574
+ check_fail("<true> is neither nil or false.") do
1575
+ refute(true)
1576
+ end
1577
+ end
1578
+
1579
+ def test_with_message
1580
+ check_fail("failed refute.\n" +
1581
+ "<true> is neither nil or false.") do
1582
+ refute(true, "failed refute")
1583
+ end
1584
+ end
1585
+
1586
+ def test_fail_with_assertion_message
1587
+ check_fail("user message.\n" +
1588
+ "placeholder <:in> message") do
1589
+ refute(true, build_message("user message",
1590
+ "placeholder <?> message",
1591
+ :in))
1592
+ end
1593
+ end
1594
+
1595
+ def test_error_invalid_message_true
1596
+ check_fail("assertion message must be String, Proc or " +
1597
+ "Test::Unit::Assertions::AssertionMessage: " +
1598
+ "<false>(<FalseClass>)") do
1599
+ begin
1600
+ refute(true, false)
1601
+ rescue ArgumentError
1602
+ raise AssertionFailedError, $!.message
1603
+ end
1604
+ end
1605
+ end
1606
+ end
1607
+ end
1608
+
1609
+ class TestAssertInDelta < TestCase
1610
+ include AssertionCheckable
1611
+
1612
+ def test_pass
1613
+ check_nothing_fails do
1614
+ assert_in_delta(1.4, 1.4, 0)
1615
+ end
1616
+ end
1617
+
1618
+ def test_pass_without_delta
1619
+ check_nothing_fails do
1620
+ assert_in_delta(1.401, 1.402)
1621
+ end
1622
+ end
1623
+
1624
+ def test_pass_with_message
1625
+ check_nothing_fails do
1626
+ assert_in_delta(0.5, 0.4, 0.1, "message")
1627
+ end
1628
+ end
1629
+
1630
+ def test_pass_float_like_object
1631
+ check_nothing_fails do
1632
+ float_thing = Object.new
1633
+ def float_thing.to_f
1634
+ 0.2
1635
+ end
1636
+ assert_in_delta(0.1, float_thing, 0.1)
1637
+ end
1638
+ end
1639
+
1640
+ def test_pass_string_expected
1641
+ check_nothing_fails do
1642
+ assert_in_delta("0.5", 0.4, 0.1)
1643
+ end
1644
+ end
1645
+
1646
+ def test_fail_with_message
1647
+ check_fail("message.\n" +
1648
+ "<0.5> -/+ <0.05> was expected to include\n" +
1649
+ "<0.4>.\n" +
1650
+ "\n" +
1651
+ "Relation:\n" +
1652
+ "<<0.4> < <0.5>-<0.05>[0.45] <= <0.5>+<0.05>[0.55]>") do
1653
+ assert_in_delta(0.5, 0.4, 0.05, "message")
1654
+ end
1655
+ end
1656
+
1657
+ def test_fail_because_not_float_like_object
1658
+ object = Object.new
1659
+ inspected_object = AssertionMessage.convert(object)
1660
+ check_fail("The arguments must respond to to_f; " +
1661
+ "the first float did not.\n" +
1662
+ "<#{inspected_object}>.respond_to?(:to_f) expected\n" +
1663
+ "(Class: <Object>)") do
1664
+ assert_in_delta(object, 0.4, 0.1)
1665
+ end
1666
+ end
1667
+
1668
+ def test_fail_because_negaitve_delta
1669
+ check_fail("The delta should not be negative.\n" +
1670
+ "<-0.1> was expected to be\n>=\n<0.0>.") do
1671
+ assert_in_delta(0.5, 0.4, -0.1, "message")
1672
+ end
1673
+ end
1674
+
1675
+ def test_fail_without_delta
1676
+ check_fail("<1.402> -/+ <0.001> was expected to include\n" +
1677
+ "<1.404>.\n" +
1678
+ "\n" +
1679
+ "Relation:\n" +
1680
+ "<" +
1681
+ "<1.402>-<0.001>[#{1.402 - 0.001}] <= " +
1682
+ "<1.402>+<0.001>[#{1.402 + 0.001}] < " +
1683
+ "<1.404>" +
1684
+ ">") do
1685
+ assert_in_delta(1.402, 1.404)
1686
+ end
1687
+ end
1688
+ end
1689
+
1690
+ class TestAssertNotInDelta < Test::Unit::TestCase
1691
+ include AssertionCheckable
1692
+
1693
+ def test_pass
1694
+ check_nothing_fails do
1695
+ assert_not_in_delta(1.42, 1.44, 0.01)
1696
+ end
1697
+ end
1698
+
1699
+ def test_pass_without_delta
1700
+ check_nothing_fails do
1701
+ assert_not_in_delta(1.402, 1.404)
1702
+ end
1703
+ end
1704
+
1705
+ def test_pass_with_message
1706
+ check_nothing_fails do
1707
+ assert_not_in_delta(0.5, 0.4, 0.09, "message")
1708
+ end
1709
+ end
1710
+
1711
+ def test_pass_float_like_object
1712
+ check_nothing_fails do
1713
+ float_thing = Object.new
1714
+ def float_thing.to_f
1715
+ 0.2
1716
+ end
1717
+ assert_not_in_delta(0.1, float_thing, 0.09)
1718
+ end
1719
+ end
1720
+
1721
+ def test_pass_string_epxected
1722
+ check_nothing_fails do
1723
+ assert_not_in_delta("0.5", 0.4, 0.09)
1724
+ end
1725
+ end
1726
+
1727
+ def test_fail
1728
+ check_fail("<1.4> -/+ <0.11> was expected to not include\n" +
1729
+ "<1.5>.\n" +
1730
+ "\n" +
1731
+ "Relation:\n" +
1732
+ "<" +
1733
+ "<1.4>-<0.11>[#{1.4 - 0.11}] <= " +
1734
+ "<1.5> <= " +
1735
+ "<1.4>+<0.11>[#{1.4 + 0.11}]" +
1736
+ ">") do
1737
+ assert_not_in_delta(1.4, 1.5, 0.11)
1738
+ end
1739
+ end
1740
+
1741
+ def test_fail_without_delta
1742
+ check_fail("<1.402> -/+ <0.001> was expected to not include\n" +
1743
+ "<1.4021>.\n" +
1744
+ "\n" +
1745
+ "Relation:\n" +
1746
+ "<" +
1747
+ "<1.402>-<0.001>[#{1.402 - 0.001}] <= " +
1748
+ "<1.4021> <= " +
1749
+ "<1.402>+<0.001>[#{1.402 + 0.001}]" +
1750
+ ">") do
1751
+ assert_not_in_delta(1.402, 1.4021)
1752
+ end
1753
+ end
1754
+
1755
+ def test_fail_with_message
1756
+ check_fail("message.\n" +
1757
+ "<0.5> -/+ <0.11> was expected to not include\n" +
1758
+ "<0.4>.\n" +
1759
+ "\n" +
1760
+ "Relation:\n" +
1761
+ "<" +
1762
+ "<0.5>-<0.11>[0.39] <= " +
1763
+ "<0.4> <= " +
1764
+ "<0.5>+<0.11>[0.61]" +
1765
+ ">") do
1766
+ assert_not_in_delta(0.5, 0.4, 0.11, "message")
1767
+ end
1768
+ end
1769
+
1770
+ def test_fail_because_not_float_like_object
1771
+ object = Object.new
1772
+ inspected_object = AssertionMessage.convert(object)
1773
+ check_fail("The arguments must respond to to_f; " +
1774
+ "the first float did not.\n" +
1775
+ "<#{inspected_object}>.respond_to?(:to_f) expected\n" +
1776
+ "(Class: <Object>)") do
1777
+ assert_not_in_delta(object, 0.4, 0.1)
1778
+ end
1779
+ end
1780
+
1781
+ def test_fail_because_negaitve_delta
1782
+ check_fail("The delta should not be negative.\n" +
1783
+ "<-0.11> was expected to be\n>=\n<0.0>.") do
1784
+ assert_not_in_delta(0.5, 0.4, -0.11, "message")
1785
+ end
1786
+ end
1787
+ end
1788
+
1789
+ class TestAssertInEpsilon < TestCase
1790
+ include AssertionCheckable
1791
+
1792
+ def test_pass
1793
+ check_nothing_fails do
1794
+ assert_in_epsilon(10000, 9000, 0.1)
1795
+ end
1796
+ end
1797
+
1798
+ def test_pass_without_epsilon
1799
+ check_nothing_fails do
1800
+ assert_in_epsilon(10000, 9991)
1801
+ end
1802
+ end
1803
+
1804
+ def test_pass_with_message
1805
+ check_nothing_fails do
1806
+ assert_in_epsilon(10000, 9000, 0.1, "message")
1807
+ end
1808
+ end
1809
+
1810
+ def test_pass_float_like_object
1811
+ check_nothing_fails do
1812
+ float_thing = Object.new
1813
+ def float_thing.to_f
1814
+ 9000.0
1815
+ end
1816
+ assert_in_epsilon(10000, float_thing, 0.1)
1817
+ end
1818
+ end
1819
+
1820
+ def test_pass_string_expected
1821
+ check_nothing_fails do
1822
+ assert_in_epsilon("10000", 9000, 0.1)
1823
+ end
1824
+ end
1825
+
1826
+ def test_pass_zero_expected
1827
+ check_nothing_fails do
1828
+ assert_in_epsilon(0, 0.00000001)
1829
+ end
1830
+ end
1831
+
1832
+ def test_pass_minus_expected
1833
+ check_nothing_fails do
1834
+ assert_in_epsilon(-1, -1)
1835
+ end
1836
+ end
1837
+
1838
+ def test_fail_with_message
1839
+ check_fail("message.\n" +
1840
+ "<10000> -/+ (<10000> * <0.1>)[1000.0] " +
1841
+ "was expected to include\n" +
1842
+ "<8999>.\n" +
1843
+ "\n" +
1844
+ "Relation:\n" +
1845
+ "<" +
1846
+ "<8999> < " +
1847
+ "<10000>-(<10000>*<0.1>)[9000.0] <= " +
1848
+ "<10000>+(<10000>*<0.1>)[11000.0]" +
1849
+ ">") do
1850
+ assert_in_epsilon(10000, 8999, 0.1, "message")
1851
+ end
1852
+ end
1853
+
1854
+ def test_fail_because_not_float_like_object
1855
+ object = Object.new
1856
+ inspected_object = AssertionMessage.convert(object)
1857
+ check_fail("The arguments must respond to to_f; " +
1858
+ "the first float did not.\n" +
1859
+ "<#{inspected_object}>.respond_to?(:to_f) expected\n" +
1860
+ "(Class: <Object>)") do
1861
+ assert_in_epsilon(object, 9000, 0.1)
1862
+ end
1863
+ end
1864
+
1865
+ def test_fail_because_negaitve_epsilon
1866
+ check_fail("The epsilon should not be negative.\n" +
1867
+ "<-0.1> was expected to be\n>=\n<0.0>.") do
1868
+ assert_in_epsilon(10000, 9000, -0.1, "message")
1869
+ end
1870
+ end
1871
+
1872
+ def test_fail_without_epsilon
1873
+ check_fail("<10000> -/+ (<10000> * <0.001>)[10.0] " +
1874
+ "was expected to include\n" +
1875
+ "<10011>.\n" +
1876
+ "\n" +
1877
+ "Relation:\n" +
1878
+ "<" +
1879
+ "<10000>-(<10000>*<0.001>)[9990.0] <= " +
1880
+ "<10000>+(<10000>*<0.001>)[10010.0] < " +
1881
+ "<10011>" +
1882
+ ">") do
1883
+ assert_in_epsilon(10000, 10011)
1884
+ end
1885
+ end
1886
+ end
1887
+
1888
+ class TestAssertNotInEpsilon < Test::Unit::TestCase
1889
+ include AssertionCheckable
1890
+
1891
+ def test_pass
1892
+ check_nothing_fails do
1893
+ assert_not_in_epsilon(10000, 8999, 0.1)
1894
+ end
1895
+ end
1896
+
1897
+ def test_pass_without_epsilon
1898
+ check_nothing_fails do
1899
+ assert_not_in_epsilon(10000, 9989)
1900
+ end
1901
+ end
1902
+
1903
+ def test_pass_with_message
1904
+ check_nothing_fails do
1905
+ assert_not_in_epsilon(10000, 8999, 0.1, "message")
1906
+ end
1907
+ end
1908
+
1909
+ def test_pass_float_like_object
1910
+ check_nothing_fails do
1911
+ float_thing = Object.new
1912
+ def float_thing.to_f
1913
+ 8999.0
1914
+ end
1915
+ assert_not_in_epsilon(10000, float_thing, 0.1)
1916
+ end
1917
+ end
1918
+
1919
+ def test_pass_string_epxected
1920
+ check_nothing_fails do
1921
+ assert_not_in_epsilon("10000", 8999, 0.1)
1922
+ end
1923
+ end
1924
+
1925
+ def test_fail
1926
+ check_fail("<10000> -/+ (<10000> * <0.1>)[1000.0] " +
1927
+ "was expected to not include\n" +
1928
+ "<9000>.\n" +
1929
+ "\n" +
1930
+ "Relation:\n" +
1931
+ "<" +
1932
+ "<10000>-(<10000>*<0.1>)[9000.0] <= " +
1933
+ "<9000> <= " +
1934
+ "<10000>+(<10000>*<0.1>)[11000.0]" +
1935
+ ">") do
1936
+ assert_not_in_epsilon(10000, 9000, 0.1)
1937
+ end
1938
+ end
1939
+
1940
+ def test_fail_without_epsilon
1941
+ check_fail("<10000> -/+ (<10000> * <0.001>)[10.0] " +
1942
+ "was expected to not include\n" +
1943
+ "<9990>.\n" +
1944
+ "\n" +
1945
+ "Relation:\n" +
1946
+ "<" +
1947
+ "<10000>-(<10000>*<0.001>)[9990.0] <= " +
1948
+ "<9990> <= " +
1949
+ "<10000>+(<10000>*<0.001>)[10010.0]" +
1950
+ ">") do
1951
+ assert_not_in_epsilon(10000, 9990)
1952
+ end
1953
+ end
1954
+
1955
+ def test_fail_with_message
1956
+ check_fail("message.\n" +
1957
+ "<10000> -/+ (<10000> * <0.1>)[1000.0] " +
1958
+ "was expected to not include\n" +
1959
+ "<9000>.\n" +
1960
+ "\n" +
1961
+ "Relation:\n" +
1962
+ "<" +
1963
+ "<10000>-(<10000>*<0.1>)[9000.0] <= " +
1964
+ "<9000> <= " +
1965
+ "<10000>+(<10000>*<0.1>)[11000.0]" +
1966
+ ">") do
1967
+ assert_not_in_epsilon(10000, 9000, 0.1, "message")
1968
+ end
1969
+ end
1970
+
1971
+ def test_fail_because_not_float_like_object
1972
+ object = Object.new
1973
+ inspected_object = AssertionMessage.convert(object)
1974
+ check_fail("The arguments must respond to to_f; " +
1975
+ "the first float did not.\n" +
1976
+ "<#{inspected_object}>.respond_to?(:to_f) expected\n" +
1977
+ "(Class: <Object>)") do
1978
+ assert_not_in_epsilon(object, 9000, 0.1)
1979
+ end
1980
+ end
1981
+
1982
+ def test_fail_because_negaitve_epsilon
1983
+ check_fail("The epsilon should not be negative.\n" +
1984
+ "<-0.1> was expected to be\n>=\n<0.0>.") do
1985
+ assert_not_in_epsilon(10000, 9000, -0.1, "message")
1986
+ end
1987
+ end
1988
+ end
1989
+
1990
+ class TestAssertInclude < Test::Unit::TestCase
1991
+ include AssertionCheckable
1992
+
1993
+ def test_pass
1994
+ check_nothing_fails do
1995
+ assert_include([1, 2, 3], 1)
1996
+ end
1997
+ end
1998
+
1999
+ def test_pass_with_message
2000
+ check_nothing_fails do
2001
+ assert_include([1, 2, 3], 1, "message")
2002
+ end
2003
+ end
2004
+
2005
+ def test_fail
2006
+ check_fail("<[1, 2, 3]> was expected to include\n" +
2007
+ "<4>.") do
2008
+ assert_include([1, 2, 3], 4)
2009
+ end
2010
+ end
2011
+
2012
+ def test_fail_with_message
2013
+ check_fail("message.\n" +
2014
+ "<[1, 2, 3]> was expected to include\n" +
2015
+ "<4>.") do
2016
+ assert_include([1, 2, 3], 4, "message")
2017
+ end
2018
+ end
2019
+
2020
+ def test_fail_because_not_collection_like_object
2021
+ object = Object.new
2022
+ inspected_object = AssertionMessage.convert(object)
2023
+ check_fail("The collection must respond to :include?.\n" +
2024
+ "<#{inspected_object}>.respond_to?(:include?) expected\n" +
2025
+ "(Class: <Object>)") do
2026
+ assert_include(object, 1)
2027
+ end
2028
+ end
2029
+ end
2030
+
2031
+ class TestAssertNotInclude < Test::Unit::TestCase
2032
+ include AssertionCheckable
2033
+
2034
+ def test_pass
2035
+ check_nothing_fails do
2036
+ assert_not_include([1, 2, 3], 5)
2037
+ end
2038
+ end
2039
+
2040
+ def test_pass_with_message
2041
+ check_nothing_fails do
2042
+ assert_not_include([1, 2, 3], 5, "message")
2043
+ end
2044
+ end
2045
+
2046
+ def test_fail
2047
+ check_fail("<[1, 2, 3]> was expected to not include\n" +
2048
+ "<2>.") do
2049
+ assert_not_include([1, 2, 3], 2)
2050
+ end
2051
+ end
2052
+
2053
+ def test_fail_with_message
2054
+ check_fail("message.\n" +
2055
+ "<[1, 2, 3]> was expected to not include\n" +
2056
+ "<2>.") do
2057
+ assert_not_include([1, 2, 3], 2, "message")
2058
+ end
2059
+ end
2060
+
2061
+ def test_fail_because_not_collection_like_object
2062
+ object = Object.new
2063
+ inspected_object = AssertionMessage.convert(object)
2064
+ check_fail("The collection must respond to :include?.\n" +
2065
+ "<#{inspected_object}>.respond_to?(:include?) expected\n" +
2066
+ "(Class: <Object>)") do
2067
+ assert_not_include(object, 1)
2068
+ end
2069
+ end
2070
+ end
2071
+
2072
+ class TestAssertEmpty < Test::Unit::TestCase
2073
+ include AssertionCheckable
2074
+
2075
+ def test_pass
2076
+ check_nothing_fails do
2077
+ assert_empty([])
2078
+ end
2079
+ end
2080
+
2081
+ def test_pass_with_message
2082
+ check_nothing_fails do
2083
+ assert_empty([], "message")
2084
+ end
2085
+ end
2086
+
2087
+ def test_fail
2088
+ check_fail("<[1]> was expected to be empty.") do
2089
+ assert_empty([1])
2090
+ end
2091
+ end
2092
+
2093
+ def test_fail_with_message
2094
+ check_fail("message.\n" +
2095
+ "<[1]> was expected to be empty.") do
2096
+ assert_empty([1], "message")
2097
+ end
2098
+ end
2099
+
2100
+ def test_fail_because_no_empty_method
2101
+ object = Object.new
2102
+ inspected_object = AssertionMessage.convert(object)
2103
+ check_fail("The object must respond to :empty?.\n" +
2104
+ "<#{inspected_object}>.respond_to?(:empty?) expected\n" +
2105
+ "(Class: <Object>)") do
2106
+ assert_empty(object)
2107
+ end
2108
+ end
2109
+ end
2110
+
2111
+ class TestAssertNotEmpty < Test::Unit::TestCase
2112
+ include AssertionCheckable
2113
+
2114
+ def test_pass
2115
+ check_nothing_fails do
2116
+ assert_not_empty([1])
2117
+ end
2118
+ end
2119
+
2120
+ def test_pass_with_message
2121
+ check_nothing_fails do
2122
+ assert_not_empty([1], "message")
2123
+ end
2124
+ end
2125
+
2126
+ def test_fail
2127
+ check_fail("<[]> was expected to not be empty.") do
2128
+ assert_not_empty([])
2129
+ end
2130
+ end
2131
+
2132
+ def test_fail_with_message
2133
+ check_fail("message.\n" +
2134
+ "<[]> was expected to not be empty.") do
2135
+ assert_not_empty([], "message")
2136
+ end
2137
+ end
2138
+
2139
+ def test_fail_because_no_empty_method
2140
+ object = Object.new
2141
+ inspected_object = AssertionMessage.convert(object)
2142
+ check_fail("The object must respond to :empty?.\n" +
2143
+ "<#{inspected_object}>.respond_to?(:empty?) expected\n" +
2144
+ "(Class: <Object>)") do
2145
+ assert_not_empty(object)
2146
+ end
2147
+ end
2148
+ end
2149
+
2150
+ class TestAssertNotSend < Test::Unit::TestCase
2151
+ include AssertionCheckable
2152
+
2153
+ def test_pass
2154
+ check_nothing_fails do
2155
+ assert_not_send([[1, 2], :member?, 4], "message")
2156
+ end
2157
+ end
2158
+
2159
+ def test_fail
2160
+ expected_message = <<-EOM
2161
+ message.
2162
+ <[1, 2]> was expected to respond to
2163
+ <member?(*[2])> with not a true value but was
2164
+ <true>.
2165
+ EOM
2166
+ check_fail(expected_message.chomp) do
2167
+ assert_not_send([[1, 2], :member?, 2], "message")
2168
+ end
2169
+ end
2170
+ end
2171
+
2172
+ class TestTemplate < Test::Unit::TestCase
2173
+ def test_incompatible_encoding_by_diff
2174
+ need_encoding
2175
+ assert_raise(AssertionFailedError) do
2176
+ assert_equal("UTF-8の日本語\n" * 3,
2177
+ ("Shift_JISの日本語\n" * 3).force_encoding("ASCII-8BIT"))
2178
+ end
2179
+ end
2180
+
2181
+ private
2182
+ def need_encoding
2183
+ omit("need Encoding") unless Object.const_defined?(:Encoding)
2184
+ end
2185
+ end
2186
+ end
2187
+ end