Added tests for Base64, Dice, EmToPx, FlipText, GoldenRatio, Guid, Periemeter, Roman, SigFigs, TitleCase, Unicode
2012-04-15 16:17:12 -07:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Test::More;
|
2016-05-16 06:07:57 -07:00
|
|
|
use Test::Deep;
|
Added tests for Base64, Dice, EmToPx, FlipText, GoldenRatio, Guid, Periemeter, Roman, SigFigs, TitleCase, Unicode
2012-04-15 16:17:12 -07:00
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
|
|
|
zci answer_type => 'dice_roll';
|
|
|
|
zci is_cached => 0;
|
|
|
|
|
2014-01-09 14:55:15 -08:00
|
|
|
my $heading = 'Random Dice Roll';
|
|
|
|
|
Added tests for Base64, Dice, EmToPx, FlipText, GoldenRatio, Guid, Periemeter, Roman, SigFigs, TitleCase, Unicode
2012-04-15 16:17:12 -07:00
|
|
|
ddg_goodie_test(
|
2015-12-28 11:32:41 -08:00
|
|
|
[qw(
|
|
|
|
DDG::Goodie::Dice
|
|
|
|
)],
|
|
|
|
|
|
|
|
# Check trigger kicks in.
|
|
|
|
'throw dice' => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^., .$/),
|
2016-02-28 12:05:34 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2016-02-28 12:05:34 -08:00
|
|
|
templates => {
|
|
|
|
group => 'text',
|
|
|
|
options => {
|
|
|
|
subtitle_content => 'DDH.dice.subtitle_content'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
'throw dices' => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^., .$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
|
|
|
group => 'text',
|
2016-02-24 08:57:15 -08:00
|
|
|
options => {
|
|
|
|
subtitle_content => 'DDH.dice.subtitle_content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
'roll dice' => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^., .$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
|
|
|
group => 'text',
|
2016-02-24 08:57:15 -08:00
|
|
|
options => {
|
|
|
|
subtitle_content => 'DDH.dice.subtitle_content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
'throw die' => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^.$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
|
|
|
group => 'text',
|
2016-02-24 08:57:15 -08:00
|
|
|
options => {
|
|
|
|
subtitle_content => 'DDH.dice.subtitle_content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
# Simple "dice" query
|
|
|
|
"roll 5 dice" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/., ., ., ., .$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
|
|
|
group => 'text',
|
2016-02-24 08:57:15 -08:00
|
|
|
options => {
|
|
|
|
subtitle_content => 'DDH.dice.subtitle_content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
|
|
|
|
# Simple shorthand query
|
|
|
|
"roll 2d6" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^\d (\+|-) \d$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
|
|
|
group => 'text',
|
2016-02-24 08:57:15 -08:00
|
|
|
options => {
|
|
|
|
subtitle_content => 'DDH.dice.subtitle_content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
2016-02-29 20:39:29 -08:00
|
|
|
|
|
|
|
# Query with numbers as words
|
|
|
|
"roll five dice" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/., ., ., ., .$/),
|
2016-02-29 20:39:29 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2016-03-01 11:56:27 -08:00
|
|
|
templates => {
|
|
|
|
group => 'text',
|
|
|
|
options => {
|
|
|
|
subtitle_content => 'DDH.dice.subtitle_content'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
2016-02-29 20:39:29 -08:00
|
|
|
"roll seven dices" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/., ., ., ., .$/),
|
2016-02-29 20:39:29 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2016-02-29 20:39:29 -08:00
|
|
|
templates => {
|
|
|
|
group => 'text',
|
|
|
|
options => {
|
|
|
|
subtitle_content => 'DDH.dice.subtitle_content'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
# Invalid numeric words
|
|
|
|
"roll foo dice" => undef,
|
|
|
|
|
2017-04-10 09:08:59 -07:00
|
|
|
# Out of range number of dice or number of face values
|
|
|
|
"roll 11d3" => undef,
|
|
|
|
"roll 2d32" => undef,
|
|
|
|
"roll twenty five dice" => undef,
|
|
|
|
"roll fifty-four dice" => undef,
|
|
|
|
|
2015-12-28 11:32:41 -08:00
|
|
|
"throw 1d20" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^\d{1,2}$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
|
|
|
group => 'text',
|
2016-02-24 08:57:15 -08:00
|
|
|
options => {
|
|
|
|
subtitle_content => 'DDH.dice.subtitle_content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
"roll d20" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^\d{1,2}$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
|
|
|
group => 'text',
|
2016-02-24 08:57:15 -08:00
|
|
|
options => {
|
|
|
|
subtitle_content => 'DDH.dice.subtitle_content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
|
|
|
|
# Simple shorthand queries with +-
|
|
|
|
"roll 3d12 + 4" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2}$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
|
|
|
group => 'text',
|
2016-02-24 08:57:15 -08:00
|
|
|
options => {
|
|
|
|
subtitle_content => 'DDH.dice.subtitle_content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
"roll 3d8 - 8" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^\d (\+|-) \d (\+|-) \d (\+|-) \d$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
|
|
|
group => 'text',
|
2016-02-24 08:57:15 -08:00
|
|
|
options => {
|
|
|
|
subtitle_content => 'DDH.dice.subtitle_content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
"roll 4d6-l" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^([1-6] \+ ){3}[1-6] - [1-6]$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
|
|
|
group => 'text',
|
2016-02-24 08:57:15 -08:00
|
|
|
options => {
|
|
|
|
subtitle_content => 'DDH.dice.subtitle_content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
|
|
|
|
# Simple conjunctive "dice" query
|
|
|
|
"throw 2 dice and 3 dice" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/., .., ., .Total: \d+$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
2016-02-24 08:57:15 -08:00
|
|
|
group => 'list',
|
|
|
|
options => {
|
|
|
|
list_content => 'DDH.dice.content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
|
|
|
|
# Shorthand conjunctive query
|
|
|
|
"roll 2w6 and d20" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^\d (\+|-) \d = \d+\d+Total: \d+$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
2016-02-24 08:57:15 -08:00
|
|
|
group => 'list',
|
|
|
|
options => {
|
|
|
|
list_content => 'DDH.dice.content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
|
|
|
|
# Shorthand conjunctive queries with +-
|
|
|
|
"roll 2d6 and 3d12 + 4" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^\d (\+|-) \d = \d+\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = \d+Total: \d+$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
2016-02-24 08:57:15 -08:00
|
|
|
group => 'list',
|
|
|
|
options => {
|
|
|
|
list_content => 'DDH.dice.content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
"roll 2d6 and 3d12 - 4" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^\d (\+|-) \d = \d+\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = -?\d+Total: \d+$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
2016-02-24 08:57:15 -08:00
|
|
|
group => 'list',
|
|
|
|
options => {
|
|
|
|
list_content => 'DDH.dice.content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
"throw 3d12 - 4 and 2d6" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = -?\d{1,2}\d (\+|-) \d = \d+Total: \d+$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
2016-02-24 08:57:15 -08:00
|
|
|
group => 'list',
|
|
|
|
options => {
|
|
|
|
list_content => 'DDH.dice.content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
"throw 2d6 and 3d12 + 4" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^\d (\+|-) \d = \d+\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = \d+Total: \d+$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
2016-02-24 08:57:15 -08:00
|
|
|
group => 'list',
|
|
|
|
options => {
|
|
|
|
list_content => 'DDH.dice.content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
"roll 2d6 and 4w6-l" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^\d (\+|-) \d = \d+([1-6] \+ ){3}[1-6] - [1-6] = \d{1,2}Total: \d+$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
2016-02-24 08:57:15 -08:00
|
|
|
group => 'list',
|
|
|
|
options => {
|
|
|
|
list_content => 'DDH.dice.content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
"roll 2 dice and 3d5 + 4" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^., .\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = \d+Total: \d+$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
2016-02-24 08:57:15 -08:00
|
|
|
group => 'list',
|
|
|
|
options => {
|
|
|
|
list_content => 'DDH.dice.content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
|
|
|
|
# Don't trigger
|
|
|
|
"roll 2d3 2d6 and 3d3" => undef,
|
|
|
|
"roll 2d4 and 2d30 d30" => undef,
|
|
|
|
"roll 222d3 and 3d2" => undef,
|
|
|
|
"roll the ball" => undef,
|
|
|
|
"throw the ball" => undef,
|
|
|
|
"roll " => undef,
|
|
|
|
"roll the" => undef,
|
|
|
|
"roll over" => undef,
|
|
|
|
"roll 0 dice" => undef,
|
|
|
|
"roll 0d6" => undef,
|
|
|
|
"roll 2d3 and 2d4-a" => undef,
|
|
|
|
|
|
|
|
"throw die" => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/^.$/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
|
|
|
group => 'text',
|
2016-02-24 08:57:15 -08:00
|
|
|
options => {
|
|
|
|
subtitle_content => 'DDH.dice.subtitle_content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
|
|
|
|
'roll 3d12' => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/\d{1,2} \+ \d{1,2} \+ \d{1,2}/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
|
|
|
group => 'text',
|
2016-02-24 08:57:15 -08:00
|
|
|
options => {
|
|
|
|
subtitle_content => 'DDH.dice.subtitle_content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
'roll 3d12 and 2d4' => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/\d{1,2} \+ \d{1,2} \+ \d{1,2} = \d+[1-4]+ \+ [1-4]+ = \dTotal: \d+/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
2016-02-24 08:57:15 -08:00
|
|
|
group => 'list',
|
|
|
|
options => {
|
|
|
|
list_content => 'DDH.dice.content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
'roll 2 dice and 3d5' => test_zci(
|
2016-05-16 06:07:57 -07:00
|
|
|
re(qr/[1-5]+ \+ [1-5]+ \+ [1-5]+ = \d+Total: \d+/),
|
2015-12-28 11:32:41 -08:00
|
|
|
structured_answer => {
|
2016-05-16 06:07:57 -07:00
|
|
|
data => ignore(),
|
2015-12-28 11:32:41 -08:00
|
|
|
templates => {
|
2016-02-24 08:57:15 -08:00
|
|
|
group => 'list',
|
|
|
|
options => {
|
|
|
|
list_content => 'DDH.dice.content'
|
|
|
|
}
|
2015-12-28 11:32:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
Added tests for Base64, Dice, EmToPx, FlipText, GoldenRatio, Guid, Periemeter, Roman, SigFigs, TitleCase, Unicode
2012-04-15 16:17:12 -07:00
|
|
|
);
|
|
|
|
|
2016-05-16 06:18:04 -07:00
|
|
|
done_testing;
|