sportdb-models 1.19.0 → 2.0.3
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 +4 -4
- data/CHANGELOG.md +20 -20
- data/Manifest.txt +27 -38
- data/README.md +31 -31
- data/Rakefile +32 -32
- data/lib/sportdb/models.rb +212 -159
- data/lib/sportdb/{deleter.rb → models/deleter.rb} +3 -9
- data/lib/sportdb/models/formats.rb +23 -0
- data/lib/sportdb/models/models/assoc.rb +38 -0
- data/lib/sportdb/models/{badge.rb → models/badge.rb} +14 -14
- data/lib/sportdb/models/models/event.rb +55 -0
- data/lib/sportdb/models/{forward.rb → models/forward.rb} +55 -55
- data/lib/sportdb/models/{goal.rb → models/goal.rb} +15 -15
- data/lib/sportdb/models/models/ground.rb +16 -0
- data/lib/sportdb/models/{group.rb → models/group.rb} +10 -7
- data/lib/sportdb/models/models/league.rb +20 -0
- data/lib/sportdb/models/{roster.rb → models/lineup.rb} +17 -18
- data/lib/sportdb/models/{game.rb → models/match.rb} +18 -61
- data/lib/sportdb/models/{person.rb → models/person.rb} +21 -21
- data/lib/sportdb/models/{round.rb → models/round.rb} +1 -6
- data/lib/sportdb/models/{season.rb → models/season.rb} +15 -14
- data/lib/sportdb/models/{stage.rb → models/stage.rb} +9 -5
- data/lib/sportdb/models/{stats/alltime_standing_entry.rb → models/stats/alltime_standing.rb} +9 -1
- data/lib/sportdb/models/{stats/event_standing_entry.rb → models/stats/event_standing.rb} +31 -21
- data/lib/sportdb/models/{stats/group_standing_entry.rb → models/stats/group_standing.rb} +10 -1
- data/lib/sportdb/models/models/team.rb +56 -0
- data/lib/sportdb/models/{world → models/world}/city.rb +2 -2
- data/lib/sportdb/models/{world → models/world}/continent.rb +20 -20
- data/lib/sportdb/models/{world → models/world}/country.rb +0 -0
- data/lib/sportdb/models/{world → models/world}/state.rb +19 -19
- data/lib/sportdb/models/schema.rb +466 -0
- data/lib/sportdb/models/stats.rb +23 -0
- data/lib/sportdb/models/utils.rb +24 -24
- data/lib/sportdb/{version.rb → models/version.rb} +27 -22
- data/test/helper.rb +46 -42
- data/test/test_changes.rb +38 -38
- data/test/test_cursor.rb +15 -15
- data/test/test_winner.rb +75 -70
- metadata +39 -44
- data/lib/sportdb/calc.rb +0 -279
- data/lib/sportdb/models/assoc.rb +0 -106
- data/lib/sportdb/models/assoc_assoc.rb +0 -15
- data/lib/sportdb/models/event.rb +0 -66
- data/lib/sportdb/models/event_ground.rb +0 -15
- data/lib/sportdb/models/event_team.rb +0 -16
- data/lib/sportdb/models/ground.rb +0 -100
- data/lib/sportdb/models/group_team.rb +0 -14
- data/lib/sportdb/models/league.rb +0 -83
- data/lib/sportdb/models/stage_team.rb +0 -14
- data/lib/sportdb/models/stats/alltime_standing.rb +0 -44
- data/lib/sportdb/models/stats/event_standing.rb +0 -55
- data/lib/sportdb/models/stats/group_standing.rb +0 -50
- data/lib/sportdb/models/team.rb +0 -119
- data/lib/sportdb/models/team_compat.rb +0 -64
- data/lib/sportdb/patterns.rb +0 -37
- data/lib/sportdb/schema.rb +0 -397
- data/lib/sportdb/standings.rb +0 -178
- data/lib/sportdb/stats.rb +0 -27
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
module SportDb
|
3
|
+
|
4
|
+
class Stats
|
5
|
+
include Models
|
6
|
+
|
7
|
+
def tables
|
8
|
+
puts " #{League.count} leagues / #{Season.count} seasons"
|
9
|
+
puts " #{Event.count} events (league+season recs) / #{Round.count} rounds / #{Group.count} groups / #{Stage.count} stages"
|
10
|
+
puts " #{Team.count} teams"
|
11
|
+
puts " #{Match.count} matches"
|
12
|
+
puts " #{Badge.count} badges"
|
13
|
+
|
14
|
+
puts " #{Lineup.count} lineups (person+team+event recs)"
|
15
|
+
puts " #{Goal.count} goals (person+match recs)"
|
16
|
+
|
17
|
+
puts " #{Assoc.count} assocs|orgs"
|
18
|
+
puts " #{Ground.count} grounds|stadiums"
|
19
|
+
end
|
20
|
+
|
21
|
+
end # class Stats
|
22
|
+
|
23
|
+
end # module SportDb
|
data/lib/sportdb/models/utils.rb
CHANGED
@@ -2,27 +2,27 @@ module SportDb
|
|
2
2
|
module Model
|
3
3
|
|
4
4
|
|
5
|
-
class
|
5
|
+
class MatchCursor
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
7
|
+
def initialize( matches )
|
8
|
+
@matches = matches
|
9
9
|
end
|
10
10
|
|
11
11
|
def each
|
12
|
-
state =
|
12
|
+
state = MatchCursorState.new
|
13
13
|
|
14
|
-
@
|
15
|
-
state.next(
|
16
|
-
yield(
|
14
|
+
@matches.each do |match|
|
15
|
+
state.next( match )
|
16
|
+
yield( match, state ) # e.g. lets you use state.new_date? or state.new_week? or state.new_year? etc.
|
17
17
|
end
|
18
18
|
end # method each
|
19
|
-
end # class
|
19
|
+
end # class MatchCursor
|
20
20
|
|
21
21
|
|
22
|
-
class
|
22
|
+
class MatchCursorState
|
23
23
|
|
24
24
|
def initialize
|
25
|
-
@
|
25
|
+
@last_date = DateTime.new( 1971, 1, 1 )
|
26
26
|
@new_date = true
|
27
27
|
@new_year = true
|
28
28
|
@new_week = true
|
@@ -34,44 +34,44 @@ class GameCursorState
|
|
34
34
|
def new_date?() @new_date; end
|
35
35
|
def new_year?() @new_year; end
|
36
36
|
def new_week?() @new_week; end
|
37
|
-
|
37
|
+
|
38
38
|
|
39
39
|
## add new league ?
|
40
40
|
## add new round ?
|
41
41
|
## add new time ?
|
42
|
-
|
43
|
-
def next(
|
42
|
+
|
43
|
+
def next( match )
|
44
44
|
@index += 1 # zero-based index; start off with -1 (undefined/uninitialized)
|
45
|
-
|
45
|
+
match_date = match.date # cache date value ref
|
46
46
|
|
47
|
-
if @
|
48
|
-
@
|
49
|
-
@
|
47
|
+
if @last_date.year == match_date.year &&
|
48
|
+
@last_date.month == match_date.month &&
|
49
|
+
@last_date.day == match_date.day
|
50
50
|
@new_date = false
|
51
51
|
else
|
52
52
|
@new_date = true
|
53
|
-
|
53
|
+
|
54
54
|
# check for new_year
|
55
|
-
if @
|
55
|
+
if @last_date.year == match_date.year
|
56
56
|
@new_year = false
|
57
57
|
else
|
58
58
|
@new_year = true
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
# check for new_week
|
62
62
|
# -- todo: find a method for week number; do NOT use strftime; there must be something easier
|
63
63
|
# -- check if activesupport adds .week or similar ??? use it if it exists
|
64
|
-
if @
|
64
|
+
if @last_date.strftime('%V') == match_date.strftime('%V')
|
65
65
|
@new_week = false
|
66
66
|
else
|
67
67
|
@new_week = true
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
@
|
71
|
+
@last_date = match.date
|
72
72
|
end # method next
|
73
|
-
|
74
|
-
end # class
|
73
|
+
|
74
|
+
end # class MatchCursorState
|
75
75
|
|
76
76
|
|
77
77
|
end # module Model
|
@@ -1,22 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end # module
|
1
|
+
module SportDb
|
2
|
+
module Module
|
3
|
+
module Models
|
4
|
+
MAJOR = 2
|
5
|
+
MINOR = 0
|
6
|
+
PATCH = 3
|
7
|
+
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
8
|
+
|
9
|
+
def self.version
|
10
|
+
VERSION
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.banner
|
14
|
+
"sportdb-models/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.root
|
18
|
+
"#{File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )}"
|
19
|
+
end
|
20
|
+
|
21
|
+
end # module Models
|
22
|
+
end # module Module
|
23
|
+
|
24
|
+
#################
|
25
|
+
## add convenience shortcuts
|
26
|
+
VERSION = Module::Models::VERSION
|
27
|
+
end # module SportDb
|
data/test/helper.rb
CHANGED
@@ -1,42 +1,46 @@
|
|
1
|
-
## minitest setup
|
2
|
-
require 'minitest/autorun'
|
3
|
-
|
4
|
-
|
5
|
-
## our own code
|
6
|
-
require 'sportdb/models'
|
7
|
-
|
8
|
-
|
9
|
-
#####################
|
10
|
-
# Models shortcuts
|
11
|
-
|
12
|
-
Country = WorldDb::Model::Country
|
13
|
-
|
14
|
-
Person = PersonDb::Model::Person
|
15
|
-
|
16
|
-
League = SportDb::Model::League
|
17
|
-
Season = SportDb::Model::Season
|
18
|
-
Event = SportDb::Model::Event
|
19
|
-
Team = SportDb::Model::Team
|
20
|
-
|
21
|
-
Assoc = SportDb::Model::Assoc
|
22
|
-
AssocAssoc = SportDb::Model::AssocAssoc
|
23
|
-
|
24
|
-
Round
|
25
|
-
Group
|
26
|
-
Stage
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
EventStanding = SportDb::Model::EventStanding
|
32
|
-
EventStandingEntry = SportDb::Model::EventStandingEntry
|
33
|
-
GroupStanding = SportDb::Model::GroupStanding
|
34
|
-
GroupStandingEntry = SportDb::Model::GroupStandingEntry
|
35
|
-
AlltimeStanding = SportDb::Model::AlltimeStanding
|
36
|
-
AlltimeStandingEntry = SportDb::Model::AlltimeStandingEntry
|
37
|
-
|
38
|
-
|
39
|
-
#################################
|
40
|
-
# setup db -> schema / tables
|
41
|
-
|
42
|
-
SportDb.setup_in_memory_db
|
1
|
+
## minitest setup
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
|
5
|
+
## our own code
|
6
|
+
require 'sportdb/models'
|
7
|
+
|
8
|
+
|
9
|
+
#####################
|
10
|
+
# Models shortcuts
|
11
|
+
|
12
|
+
Country = WorldDb::Model::Country
|
13
|
+
|
14
|
+
Person = PersonDb::Model::Person
|
15
|
+
|
16
|
+
League = SportDb::Model::League
|
17
|
+
Season = SportDb::Model::Season
|
18
|
+
Event = SportDb::Model::Event
|
19
|
+
Team = SportDb::Model::Team
|
20
|
+
Lineup = SportDb::Model::Lineup
|
21
|
+
Assoc = SportDb::Model::Assoc
|
22
|
+
AssocAssoc = SportDb::Model::AssocAssoc
|
23
|
+
|
24
|
+
Round = SportDb::Model::Round
|
25
|
+
Group = SportDb::Model::Group
|
26
|
+
Stage = SportDb::Model::Stage
|
27
|
+
Match = SportDb::Model::Match
|
28
|
+
MatchCursor = SportDb::Model::MatchCursor
|
29
|
+
|
30
|
+
|
31
|
+
EventStanding = SportDb::Model::EventStanding
|
32
|
+
EventStandingEntry = SportDb::Model::EventStandingEntry
|
33
|
+
GroupStanding = SportDb::Model::GroupStanding
|
34
|
+
GroupStandingEntry = SportDb::Model::GroupStandingEntry
|
35
|
+
AlltimeStanding = SportDb::Model::AlltimeStanding
|
36
|
+
AlltimeStandingEntry = SportDb::Model::AlltimeStandingEntry
|
37
|
+
|
38
|
+
|
39
|
+
#################################
|
40
|
+
# setup db -> schema / tables
|
41
|
+
|
42
|
+
SportDb.setup_in_memory_db
|
43
|
+
|
44
|
+
## test helpers here
|
45
|
+
SportDb.delete!
|
46
|
+
SportDb.tables
|
data/test/test_changes.rb
CHANGED
@@ -8,18 +8,18 @@ require 'helper'
|
|
8
8
|
|
9
9
|
class TestChanges < MiniTest::Test
|
10
10
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
11
|
+
def test_score
|
12
|
+
match1 = Match.new
|
13
|
+
match1.score1 = 1
|
14
|
+
match1.score2 = 2
|
15
|
+
|
16
|
+
match2 = Match.new
|
17
|
+
match2.score1 = 1
|
18
|
+
match2.score2 = 1
|
19
|
+
match2.score1p = 5
|
20
|
+
match2.score2p = 3
|
21
|
+
|
22
|
+
match_attribs = {
|
23
23
|
score1: 1,
|
24
24
|
score2: 2,
|
25
25
|
score1et: nil,
|
@@ -28,50 +28,50 @@ class TestChanges < MiniTest::Test
|
|
28
28
|
score2p: nil
|
29
29
|
}
|
30
30
|
|
31
|
-
assert_equal false,
|
32
|
-
assert_equal true,
|
31
|
+
assert_equal false, match1.check_for_changes( match_attribs )
|
32
|
+
assert_equal true, match2.check_for_changes( match_attribs )
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
def test_date
|
36
|
+
match1 = Match.new
|
37
|
+
match1.score1 = 1
|
38
|
+
match1.score2 = 2
|
39
|
+
match1.date = Date.new( 2012, 11, 5 )
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
match2 = Match.new
|
42
|
+
match2.score1 = 1
|
43
|
+
match2.score2 = 2
|
44
|
+
match2.date = DateTime.new( 2012, 12, 24 )
|
45
45
|
|
46
|
-
|
46
|
+
match_attribs = {
|
47
47
|
score1: 1,
|
48
48
|
score2: 2,
|
49
|
-
|
49
|
+
date: DateTime.new( 2012, 11, 5 )
|
50
50
|
}
|
51
51
|
|
52
|
-
assert_equal false,
|
53
|
-
assert_equal true,
|
52
|
+
assert_equal false, match1.check_for_changes( match_attribs )
|
53
|
+
assert_equal true, match2.check_for_changes( match_attribs )
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_group_id
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
match1 = Match.new
|
58
|
+
match1.score1 = 1
|
59
|
+
match1.score2 = 2
|
60
|
+
match1.group_id = 1
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
match2 = Match.new
|
63
|
+
match2.score1 = 1
|
64
|
+
match2.score2 = 2
|
65
|
+
match2.group_id = 2
|
66
66
|
|
67
|
-
|
67
|
+
match_attribs = {
|
68
68
|
score1: 1,
|
69
69
|
score2: 2,
|
70
70
|
group_id: 1
|
71
71
|
}
|
72
72
|
|
73
|
-
assert_equal false,
|
74
|
-
assert_equal true,
|
73
|
+
assert_equal false, match1.check_for_changes( match_attribs )
|
74
|
+
assert_equal true, match2.check_for_changes( match_attribs )
|
75
75
|
end
|
76
76
|
|
77
77
|
|
data/test/test_cursor.rb
CHANGED
@@ -9,42 +9,42 @@ require 'helper'
|
|
9
9
|
|
10
10
|
class TestCursor < MiniTest::Test
|
11
11
|
|
12
|
-
def
|
13
|
-
|
12
|
+
def test_matches
|
13
|
+
matches = []
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
matches << Match.new( score1: 3, score2: 1, date: Date.new(2013, 8, 9) )
|
16
|
+
matches << Match.new( score1: 1, score2: 3, date: Date.new(2013, 8, 10) )
|
17
|
+
matches << Match.new( score1: 2, score2: 0, date: Date.new(2013, 8, 10) )
|
18
|
+
matches << Match.new( score1: 3, score2: 2, date: Date.new(2013, 8, 12) ) # new_week
|
19
19
|
|
20
|
-
|
20
|
+
MatchCursor.new( matches ).each do |match,state|
|
21
21
|
if state.index == 0
|
22
|
-
assert_equal 3,
|
23
|
-
assert_equal 1,
|
22
|
+
assert_equal 3, match.score1
|
23
|
+
assert_equal 1, match.score2
|
24
24
|
assert_equal true, state.new_date?
|
25
25
|
assert_equal true, state.new_year?
|
26
26
|
assert_equal true, state.new_week?
|
27
27
|
end
|
28
28
|
|
29
29
|
if state.index == 1
|
30
|
-
assert_equal 1,
|
31
|
-
assert_equal 3,
|
30
|
+
assert_equal 1, match.score1
|
31
|
+
assert_equal 3, match.score2
|
32
32
|
assert_equal true, state.new_date?
|
33
33
|
assert_equal false, state.new_year?
|
34
34
|
assert_equal false, state.new_week?
|
35
35
|
end
|
36
36
|
|
37
37
|
if state.index == 2
|
38
|
-
assert_equal 2,
|
39
|
-
assert_equal 0,
|
38
|
+
assert_equal 2, match.score1
|
39
|
+
assert_equal 0, match.score2
|
40
40
|
assert_equal false, state.new_date?
|
41
41
|
assert_equal false, state.new_year?
|
42
42
|
assert_equal false, state.new_week?
|
43
43
|
end
|
44
44
|
|
45
45
|
if state.index == 3
|
46
|
-
assert_equal 3,
|
47
|
-
assert_equal 2,
|
46
|
+
assert_equal 3, match.score1
|
47
|
+
assert_equal 2, match.score2
|
48
48
|
assert_equal true, state.new_date?
|
49
49
|
assert_equal true, state.new_week?
|
50
50
|
assert_equal false, state.new_year?
|
data/test/test_winner.rb
CHANGED
@@ -1,95 +1,100 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_winner.rb
|
6
|
+
|
7
|
+
|
3
8
|
require 'helper'
|
4
9
|
|
5
10
|
class TestWinner < MiniTest::Test
|
6
11
|
|
7
12
|
def test_1_2
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
assert_equal 2,
|
14
|
-
assert_equal 2,
|
15
|
-
assert_equal true,
|
16
|
-
assert_equal false,
|
17
|
-
assert_equal false,
|
13
|
+
match = Match.new
|
14
|
+
match.score1 = 1
|
15
|
+
match.score2 = 2
|
16
|
+
match.calc_winner
|
17
|
+
|
18
|
+
assert_equal 2, match.winner90
|
19
|
+
assert_equal 2, match.winner
|
20
|
+
assert_equal true, match.winner2?
|
21
|
+
assert_equal false, match.winner1?
|
22
|
+
assert_equal false, match.draw?
|
18
23
|
end
|
19
24
|
|
20
25
|
def test_1_1
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
assert_equal 0,
|
27
|
-
assert_equal 0,
|
28
|
-
assert_equal true,
|
29
|
-
assert_equal false,
|
30
|
-
assert_equal false,
|
26
|
+
match = Match.new
|
27
|
+
match.score1 = 1
|
28
|
+
match.score2 = 1
|
29
|
+
match.calc_winner
|
30
|
+
|
31
|
+
assert_equal 0, match.winner90
|
32
|
+
assert_equal 0, match.winner
|
33
|
+
assert_equal true, match.draw?
|
34
|
+
assert_equal false, match.winner1?
|
35
|
+
assert_equal false, match.winner2?
|
31
36
|
end
|
32
37
|
|
33
38
|
def test_2_1
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
assert_equal 1,
|
40
|
-
assert_equal 1,
|
41
|
-
assert_equal true,
|
42
|
-
assert_equal false,
|
43
|
-
assert_equal false,
|
39
|
+
match = Match.new
|
40
|
+
match.score1 = 2
|
41
|
+
match.score2 = 1
|
42
|
+
match.calc_winner
|
43
|
+
|
44
|
+
assert_equal 1, match.winner90
|
45
|
+
assert_equal 1, match.winner
|
46
|
+
assert_equal true, match.winner1?
|
47
|
+
assert_equal false, match.winner2?
|
48
|
+
assert_equal false, match.draw?
|
44
49
|
end
|
45
50
|
|
46
51
|
def test_1_1__2_1
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
assert_equal 0,
|
55
|
-
assert_equal 1,
|
56
|
-
assert_equal true,
|
57
|
-
assert_equal false,
|
58
|
-
assert_equal false,
|
52
|
+
match = Match.new
|
53
|
+
match.score1 = 1
|
54
|
+
match.score2 = 1
|
55
|
+
match.score1et = 2
|
56
|
+
match.score2et = 1
|
57
|
+
match.calc_winner
|
58
|
+
|
59
|
+
assert_equal 0, match.winner90
|
60
|
+
assert_equal 1, match.winner
|
61
|
+
assert_equal true, match.winner1?
|
62
|
+
assert_equal false, match.winner2?
|
63
|
+
assert_equal false, match.draw?
|
59
64
|
end
|
60
65
|
|
61
66
|
def test_1_1__2_2__3_5
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
assert_equal 0,
|
72
|
-
assert_equal 2,
|
73
|
-
assert_equal true,
|
74
|
-
assert_equal false,
|
75
|
-
assert_equal false,
|
67
|
+
match = Match.new
|
68
|
+
match.score1 = 1
|
69
|
+
match.score2 = 1
|
70
|
+
match.score1et = 2
|
71
|
+
match.score2et = 2
|
72
|
+
match.score1p = 3
|
73
|
+
match.score2p = 5
|
74
|
+
match.calc_winner
|
75
|
+
|
76
|
+
assert_equal 0, match.winner90
|
77
|
+
assert_equal 2, match.winner
|
78
|
+
assert_equal true, match.winner2?
|
79
|
+
assert_equal false, match.winner1?
|
80
|
+
assert_equal false, match.draw?
|
76
81
|
end
|
77
82
|
|
78
83
|
def test_1_1_x_3_5
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
assert_equal 0,
|
89
|
-
assert_equal 2,
|
90
|
-
assert_equal true,
|
91
|
-
assert_equal false,
|
92
|
-
assert_equal false,
|
84
|
+
match = Match.new
|
85
|
+
match.score1 = 1
|
86
|
+
match.score2 = 1
|
87
|
+
match.score1et = nil
|
88
|
+
match.score2et = nil
|
89
|
+
match.score1p = 3
|
90
|
+
match.score2p = 5
|
91
|
+
match.calc_winner
|
92
|
+
|
93
|
+
assert_equal 0, match.winner90
|
94
|
+
assert_equal 2, match.winner
|
95
|
+
assert_equal true, match.winner2?
|
96
|
+
assert_equal false, match.winner1?
|
97
|
+
assert_equal false, match.draw?
|
93
98
|
end
|
94
99
|
|
95
100
|
end # class TestWinner
|