stable_match 0.1.1 → 0.2.0
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.
- checksums.yaml +15 -0
- data/Gemfile +1 -4
- data/README.md +46 -7
- data/Rakefile +35 -40
- data/examples/example_1.rb +12 -12
- data/lib/stable_match.rb +3 -6
- data/lib/stable_match/candidate.rb +74 -104
- data/lib/stable_match/runner.rb +81 -98
- data/lib/stable_match/test.rb +49 -0
- data/lib/stable_match/util.rb +1 -0
- data/lib/stable_match/util/initialize_with_defaults.rb +27 -0
- data/lib/stable_match/version.rb +1 -1
- data/stable_match.gemspec +7 -15
- data/test/functional/nrmp_test.rb +18 -16
- data/test/functional/stable_marriage_test.rb +75 -0
- data/test/test_helper.rb +22 -7
- data/test/unit/lib/stable_match/candidate_test.rb +3 -41
- data/test/unit/lib/stable_match/runner_test.rb +11 -34
- data/test/unit/lib/stable_match/util/intialize_with_defaults_test.rb +49 -0
- data/test/unit/lib/stable_match_test.rb +2 -2
- metadata +26 -56
- data/test/support/minitest.rb +0 -51
data/test/support/minitest.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
module MiniTest
|
2
|
-
class Unit
|
3
|
-
class TestCase
|
4
|
-
alias_method '__assert__' , 'assert'
|
5
|
-
|
6
|
-
## TestCase#assert
|
7
|
-
#
|
8
|
-
# See: https://github.com/ahoward/testing.rb/blob/08dd643239a23543409ecb5fee100181f1621794/lib/testing.rb#L82-107
|
9
|
-
#
|
10
|
-
# Override assert to take a few different kinds of options
|
11
|
-
# Most notable argument type is a block that:
|
12
|
-
# -> asserts no exceptions were raised
|
13
|
-
# -> asserts the result of the block is truthy
|
14
|
-
# -> returns the result of the block
|
15
|
-
#
|
16
|
-
def assert( *args , &block )
|
17
|
-
if args.size == 1 and args.first.is_a?(Hash)
|
18
|
-
options = args.first
|
19
|
-
expected = getopt(:expected, options){ missing }
|
20
|
-
actual = getopt(:actual, options){ missing }
|
21
|
-
if expected == missing and actual == missing
|
22
|
-
actual , expected , *_ = options.to_a.flatten
|
23
|
-
end
|
24
|
-
expected = expected.call() if expected.respond_to?(:call)
|
25
|
-
actual = actual.call() if actual.respond_to?(:call)
|
26
|
-
assert_equal expected , actual
|
27
|
-
end
|
28
|
-
|
29
|
-
if block
|
30
|
-
label = "assert(#{ args.join(' ') })"
|
31
|
-
result = nil
|
32
|
-
raised = false
|
33
|
-
result = begin
|
34
|
-
block.call
|
35
|
-
rescue Object => e
|
36
|
-
raised = e
|
37
|
-
false
|
38
|
-
end
|
39
|
-
__assert__ !raised , ( raised.message rescue label )
|
40
|
-
__assert__ result , label
|
41
|
-
result
|
42
|
-
else
|
43
|
-
result = args.shift
|
44
|
-
label = "assert(#{ args.join(' ') })"
|
45
|
-
__assert__ result , label
|
46
|
-
result
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|