Merge remote-tracking branch 'upstream/master' into issue-2002
commit
7e056981e9
|
@ -30,13 +30,17 @@ handle remainder => sub {
|
||||||
return unless $month;
|
return unless $month;
|
||||||
my $stone = $birthstones{$month};
|
my $stone = $birthstones{$month};
|
||||||
return unless $stone;
|
return unless $stone;
|
||||||
|
|
||||||
return $month . " birthstone: $stone",
|
return $month . " birthstone: $stone",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [$month],
|
data => {
|
||||||
operation => 'Birthstone',
|
title => $stone,
|
||||||
result => $stone
|
subtitle => 'Birthstone for '.$month
|
||||||
};
|
},
|
||||||
|
templates => {
|
||||||
|
group => "text",
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use DDG::Goodie;
|
||||||
use Convert::Braille;
|
use Convert::Braille;
|
||||||
use utf8;
|
use utf8;
|
||||||
|
|
||||||
triggers query_raw => qr/\p{Braille}|braille/i;
|
triggers query_raw => qr/\p{Braille}|( in| to){1} braille$|^braille:/i;
|
||||||
|
|
||||||
zci is_cached => 1;
|
zci is_cached => 1;
|
||||||
|
|
||||||
|
@ -16,22 +16,29 @@ my $braille_space = '⠀'; # the braille unicode space (U+2800)
|
||||||
handle query_raw => sub {
|
handle query_raw => sub {
|
||||||
|
|
||||||
my $query = $_;
|
my $query = $_;
|
||||||
$query =~ s/translate to braille |( in)? braille$|^braille //;
|
$query =~ s/( in| to){1} braille$|^braille:\s?//;
|
||||||
return unless $query;
|
return unless $query;
|
||||||
|
|
||||||
my $result;
|
my $response;
|
||||||
|
my $type;
|
||||||
|
|
||||||
if ($query =~ /\p{Braille}/) {
|
if ($query =~ /\p{Braille}/) {
|
||||||
$result = join(" ", map { lc(brailleDotsToAscii($_)) } split(/$braille_space/, $query));
|
$response = join(" ", map { lc(brailleDotsToAscii($_)) } split(/$braille_space/, $query));
|
||||||
|
$type = "Ascii/Unicode";
|
||||||
} else {
|
} else {
|
||||||
$result = join($braille_space, map { brailleAsciiToUnicode(uc $_) } split(/\s/, $query));
|
$response = join($braille_space, map { brailleAsciiToUnicode(uc $_) } split(/\s/, $query));
|
||||||
|
$type = "Braille";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result . ' (Braille)',
|
return $response,
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [html_enc($query)],
|
data => {
|
||||||
operation => 'Braille translation',
|
title => $response,
|
||||||
result => html_enc($result),
|
subtitle => 'Braille translation: ' . html_enc($query),
|
||||||
|
},
|
||||||
|
templates => {
|
||||||
|
group => 'text',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -45,12 +45,23 @@ sub generate_triggers {
|
||||||
my %triggers;
|
my %triggers;
|
||||||
# This will contain a lookup from triggers to categories and/or files.
|
# This will contain a lookup from triggers to categories and/or files.
|
||||||
my %trigger_lookup;
|
my %trigger_lookup;
|
||||||
|
# This will contain all the ignored phrases and their associated categories.
|
||||||
|
my %ignore_phrases;
|
||||||
|
|
||||||
while (my ($name, $trigger_setsh) = each %spec_triggers) {
|
while (my ($name, $trigger_setsh) = each %spec_triggers) {
|
||||||
|
my $ignore_phrases = delete $trigger_setsh->{ignore};
|
||||||
while (my ($trigger_type, $triggersh) = each %$trigger_setsh) {
|
while (my ($trigger_type, $triggersh) = each %$trigger_setsh) {
|
||||||
foreach my $trigger (@{$triggersh}) {
|
foreach my $trigger (@{$triggersh}) {
|
||||||
# Add trigger to global triggers.
|
# Add trigger to global triggers.
|
||||||
$triggers{$trigger_type}{$trigger} = 1;
|
$triggers{$trigger_type}{$trigger} = 1;
|
||||||
|
# Handle ignored components - these will be stripped
|
||||||
|
# from query and not be included in final trigger.
|
||||||
|
if (defined $ignore_phrases) {
|
||||||
|
my %new_ignore_phrases = map { $_ => 1 }
|
||||||
|
(keys %{$ignore_phrases{$trigger} || {}},
|
||||||
|
@$ignore_phrases);
|
||||||
|
$ignore_phrases{$trigger} = \%new_ignore_phrases;
|
||||||
|
}
|
||||||
my %new_triggers = map { $_ => 1}
|
my %new_triggers = map { $_ => 1}
|
||||||
(keys %{$trigger_lookup{$trigger}});
|
(keys %{$trigger_lookup{$trigger}});
|
||||||
if ($name !~ /cheat_sheet$/) {
|
if ($name !~ /cheat_sheet$/) {
|
||||||
|
@ -65,7 +76,7 @@ sub generate_triggers {
|
||||||
while (my ($trigger_type, $triggers) = each %triggers) {
|
while (my ($trigger_type, $triggers) = each %triggers) {
|
||||||
triggers $trigger_type => (keys %{$triggers});
|
triggers $trigger_type => (keys %{$triggers});
|
||||||
}
|
}
|
||||||
return %trigger_lookup;
|
return (\%ignore_phrases, %trigger_lookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Initialize aliases.
|
# Initialize aliases.
|
||||||
|
@ -100,15 +111,17 @@ sub get_aliases {
|
||||||
|
|
||||||
my $aliases = get_aliases();
|
my $aliases = get_aliases();
|
||||||
|
|
||||||
my %trigger_lookup = generate_triggers($aliases);
|
my ($trigger_ignore, %trigger_lookup) = generate_triggers($aliases);
|
||||||
|
|
||||||
handle remainder => sub {
|
handle remainder_lc => sub {
|
||||||
my $remainder = shift;
|
my @query_parts = split /\s+/o, shift;
|
||||||
|
|
||||||
my $trigger = join(' ', split /\s+/o, lc($req->matched_trigger));
|
my $trigger = join(' ', split /\s+/o, lc($req->matched_trigger));
|
||||||
my $lookup = $trigger_lookup{$trigger};
|
my $lookup = $trigger_lookup{$trigger};
|
||||||
|
my $alias = join ' ', exists $trigger_ignore->{$trigger}
|
||||||
my $file = $aliases->{join(' ', split /\s+/o, lc($remainder))} or return;
|
? grep { not exists $trigger_ignore->{$trigger}{$_} } @query_parts
|
||||||
|
: @query_parts;
|
||||||
|
my $file = $aliases->{$alias} or return;
|
||||||
open my $fh, $file or return;
|
open my $fh, $file or return;
|
||||||
my $json = do { local $/; <$fh> };
|
my $json = do { local $/; <$fh> };
|
||||||
my $data = decode_json($json) or return;
|
my $data = decode_json($json) or return;
|
||||||
|
|
|
@ -51,11 +51,14 @@ handle query => sub {
|
||||||
|
|
||||||
my $formatted_result = $style->for_display($result);
|
my $formatted_result = $style->for_display($result);
|
||||||
|
|
||||||
return $formatted_result,
|
return $formatted_result, structured_answer => {
|
||||||
structured_answer => {
|
data => {
|
||||||
input => [$style->for_display($n) . " $operation " . $style->for_display($k)],
|
title => $formatted_result,
|
||||||
operation => 'Calculate',
|
subtitle => $style->for_display($n) . " $operation " . $style->for_display($k)
|
||||||
result => $formatted_result,
|
},
|
||||||
|
templates => {
|
||||||
|
group => 'text'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ with 'DDG::GoodieRole::NumberStyler';
|
||||||
use Math::Round qw/nearest/;
|
use Math::Round qw/nearest/;
|
||||||
use utf8;
|
use utf8;
|
||||||
use YAML::XS 'LoadFile';
|
use YAML::XS 'LoadFile';
|
||||||
|
use List::Util qw(any);
|
||||||
|
|
||||||
zci answer_type => 'conversions';
|
zci answer_type => 'conversions';
|
||||||
zci is_cached => 1;
|
zci is_cached => 1;
|
||||||
|
@ -16,10 +17,15 @@ use bignum;
|
||||||
|
|
||||||
my @types = LoadFile(share('ratios.yml'));
|
my @types = LoadFile(share('ratios.yml'));
|
||||||
|
|
||||||
|
my %unit_to_plural = ();
|
||||||
my @units = ();
|
my @units = ();
|
||||||
|
my %plural_to_unit = ();
|
||||||
foreach my $type (@types) {
|
foreach my $type (@types) {
|
||||||
push(@units, $type->{'unit'});
|
push(@units, $type->{'unit'});
|
||||||
|
push(@units, $type->{'plural'}) unless lc $type->{'unit'} eq lc $type->{'plural'};
|
||||||
push(@units, @{$type->{'aliases'}});
|
push(@units, @{$type->{'aliases'}});
|
||||||
|
$unit_to_plural{lc $type->{'unit'}} = $type->{'plural'};
|
||||||
|
$plural_to_unit{lc $type->{'plural'}} = $type->{'unit'};
|
||||||
}
|
}
|
||||||
|
|
||||||
# build triggers based on available conversion units:
|
# build triggers based on available conversion units:
|
||||||
|
@ -35,32 +41,6 @@ my $question_prefix = qr/(?<prefix>convert|what (?:is|are|does)|how (?:much|many
|
||||||
my $factor_re = join('|', ('a', 'an', number_style_regex()));
|
my $factor_re = join('|', ('a', 'an', number_style_regex()));
|
||||||
my $guard = qr/^(?<question>$question_prefix)\s?(?<left_num>$factor_re*)\s?(?<left_unit>$keys)\s(?<connecting_word>in|to|into|(?:in to)|from)?\s?(?<right_num>$factor_re*)\s?(?:of\s)?(?<right_unit>$keys)[\?]?$/i;
|
my $guard = qr/^(?<question>$question_prefix)\s?(?<left_num>$factor_re*)\s?(?<left_unit>$keys)\s(?<connecting_word>in|to|into|(?:in to)|from)?\s?(?<right_num>$factor_re*)\s?(?:of\s)?(?<right_unit>$keys)[\?]?$/i;
|
||||||
|
|
||||||
# exceptions for pluralized forms:
|
|
||||||
my %plural_exceptions = (
|
|
||||||
'stone' => 'stone',
|
|
||||||
'foot' => 'feet',
|
|
||||||
'inch' => 'inches',
|
|
||||||
'pounds per square inch' => 'pounds per square inch',
|
|
||||||
'ton of TNT' => 'tons of TNT',
|
|
||||||
'metric horsepower' => 'metric horsepower',
|
|
||||||
'horsepower' => 'horsepower',
|
|
||||||
'electrical horsepower' => 'electrical horsepower',
|
|
||||||
'pounds force' => 'pounds force',
|
|
||||||
'坪' => '坪',
|
|
||||||
'km/h' => 'km/h',
|
|
||||||
'mph' => 'mph',
|
|
||||||
'm/s' => 'm/s',
|
|
||||||
'ft/s' => 'ft/s',
|
|
||||||
'dram avoirdupois' => 'drams avoirdupois',
|
|
||||||
'thousandth of an inch' => 'thousandths of an inch',
|
|
||||||
'century' => 'centuries',
|
|
||||||
'millennium' => 'millennia',
|
|
||||||
'mmHg' => 'mmHg',
|
|
||||||
'torr' => 'torr',
|
|
||||||
'cubic inch' => 'cubic inches'
|
|
||||||
);
|
|
||||||
my %singular_exceptions = reverse %plural_exceptions;
|
|
||||||
|
|
||||||
# fix precision and rounding:
|
# fix precision and rounding:
|
||||||
my $precision = 3;
|
my $precision = 3;
|
||||||
my $nearest = '.' . ('0' x ($precision-1)) . '1';
|
my $nearest = '.' . ('0' x ($precision-1)) . '1';
|
||||||
|
@ -132,8 +112,7 @@ handle query_lc => sub {
|
||||||
&& "" eq $+{'right_num'}
|
&& "" eq $+{'right_num'}
|
||||||
&& $+{'question'} !~ qr/convert/i
|
&& $+{'question'} !~ qr/convert/i
|
||||||
&& !looks_plural($+{'right_unit'})
|
&& !looks_plural($+{'right_unit'})
|
||||||
&& $+{'connecting_word'} !~ qr/to/i
|
&& $+{'connecting_word'} !~ qr/to/i ))
|
||||||
&& $factor1[0] > $factor2[0]))
|
|
||||||
{
|
{
|
||||||
$factor = $+{'right_num'};
|
$factor = $+{'right_num'};
|
||||||
@matches = ($matches[1], $matches[0]);
|
@matches = ($matches[1], $matches[0]);
|
||||||
|
@ -193,31 +172,31 @@ handle query_lc => sub {
|
||||||
};
|
};
|
||||||
$factor = $styler->for_display($factor);
|
$factor = $styler->for_display($factor);
|
||||||
|
|
||||||
return $factor . " $result->{'from_unit'} = $result->{'result'} $result->{'to_unit'}",
|
return "$factor $result->{'from_unit'} = $result->{'result'} $result->{'to_unit'}",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => {
|
data => {
|
||||||
raw_input => $styler->for_computation($factor),
|
raw_input => $styler->for_computation($factor),
|
||||||
raw_answer => $styler->for_computation($result->{'result'}),
|
raw_answer => $styler->for_computation($result->{'result'}),
|
||||||
left_unit => $result->{'from_unit'},
|
left_unit => $result->{'from_unit'},
|
||||||
right_unit => $result->{'to_unit'},
|
right_unit => $result->{'to_unit'},
|
||||||
markup_input => $styler->with_html($factor),
|
markup_input => $styler->with_html($factor),
|
||||||
styled_output => $styler->with_html($result->{'result'}),
|
styled_output => $styler->with_html($result->{'result'}),
|
||||||
physical_quantity => $result->{'type'}
|
physical_quantity => $result->{'type'}
|
||||||
},
|
},
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
content => 'DDH.conversions.content'
|
content => 'DDH.conversions.content'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
sub looks_plural {
|
sub looks_plural {
|
||||||
my ($unit) = @_;
|
my ($input) = @_;
|
||||||
my @unit_letters = split //, $unit;
|
return defined $plural_to_unit{lc $input};
|
||||||
return exists $singular_exceptions{$unit} || $unit_letters[-1] eq 's';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub convert_temperatures {
|
sub convert_temperatures {
|
||||||
my ($from, $to, $in_temperature) = @_;
|
my ($from, $to, $in_temperature) = @_;
|
||||||
|
|
||||||
|
@ -243,11 +222,10 @@ sub convert_temperatures {
|
||||||
}
|
}
|
||||||
sub get_matches {
|
sub get_matches {
|
||||||
my @input_matches = @_;
|
my @input_matches = @_;
|
||||||
|
|
||||||
my @output_matches = ();
|
my @output_matches = ();
|
||||||
foreach my $match (@input_matches) {
|
foreach my $match (@input_matches) {
|
||||||
foreach my $type (@types) {
|
foreach my $type (@types) {
|
||||||
if (lc $match eq $type->{'unit'} || grep { $_ eq lc $match } @{$type->{'aliases'}}) {
|
if (lc $match eq $type->{'unit'} || lc $match eq lc $type->{'plural'} || grep { $_ eq lc $match } @{$type->{'aliases'}}) {
|
||||||
push(@output_matches,{
|
push(@output_matches,{
|
||||||
type => $type->{'type'},
|
type => $type->{'type'},
|
||||||
factor => $type->{'factor'},
|
factor => $type->{'factor'},
|
||||||
|
@ -266,6 +244,7 @@ sub convert {
|
||||||
my @matches = get_matches($conversion->{'from_unit'}, $conversion->{'to_unit'});
|
my @matches = get_matches($conversion->{'from_unit'}, $conversion->{'to_unit'});
|
||||||
|
|
||||||
return if $conversion->{'factor'} < 0 && !($matches[0]->{'can_be_negative'});
|
return if $conversion->{'factor'} < 0 && !($matches[0]->{'can_be_negative'});
|
||||||
|
|
||||||
# matches must be of the same type (e.g., can't convert mass to length):
|
# matches must be of the same type (e.g., can't convert mass to length):
|
||||||
return if ($matches[0]->{'type'} ne $matches[1]->{'type'});
|
return if ($matches[0]->{'type'} ne $matches[1]->{'type'});
|
||||||
|
|
||||||
|
@ -285,19 +264,11 @@ sub convert {
|
||||||
"type" => $matches[0]->{'type'}
|
"type" => $matches[0]->{'type'}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_unit_pluralisation {
|
sub set_unit_pluralisation {
|
||||||
my ($unit, $count) = @_;
|
my ($unit, $count) = @_;
|
||||||
my $proper_unit = $unit;
|
$unit = $unit_to_plural{lc $unit} if ($count != 1 && !looks_plural($unit));
|
||||||
|
return $unit;
|
||||||
my $already_plural = looks_plural($unit);
|
|
||||||
|
|
||||||
if ($already_plural && $count == 1) {
|
|
||||||
$proper_unit = $singular_exceptions{$unit} || substr($unit, 0, -1);
|
|
||||||
} elsif (!$already_plural && $count != 1) {
|
|
||||||
$proper_unit = $plural_exceptions{$unit} || $unit . 's';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $proper_unit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -36,9 +36,13 @@ handle remainder => sub {
|
||||||
|
|
||||||
return 'ISO 3166: '. ucfirst $input .' - '. $answer[0],
|
return 'ISO 3166: '. ucfirst $input .' - '. $answer[0],
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [ucfirst $input],
|
data => {
|
||||||
operation => 'ISO 3166 Country code',
|
title => $answer[0],
|
||||||
result => ($answer[0]),
|
subtitle => "ISO 3166 Country code: " . ucfirst ($input)
|
||||||
|
},
|
||||||
|
templates => {
|
||||||
|
group => "text"
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,15 @@ handle remainder => sub {
|
||||||
|
|
||||||
my $factors = join ', ', divisors($query);
|
my $factors = join ', ', divisors($query);
|
||||||
|
|
||||||
return "Factors of $query: $factors",
|
return "Factors of $query: $factors", structured_answer => {
|
||||||
structured_answer => {
|
data => {
|
||||||
input => [$query],
|
title => $factors,
|
||||||
operation => 'Factors',
|
subtitle => "Factors of: $query"
|
||||||
result => $factors
|
},
|
||||||
};
|
templates => {
|
||||||
|
group => 'text'
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -20,9 +20,13 @@ handle remainder => sub {
|
||||||
|
|
||||||
return $result,
|
return $result,
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [html_enc($input)],
|
data => {
|
||||||
operation => 'Flip text',
|
title => $result,
|
||||||
result => html_enc($result),
|
subtitle => "Flip text $input"
|
||||||
|
},
|
||||||
|
templates => {
|
||||||
|
group => 'text',
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,15 @@ handle remainder => sub {
|
||||||
my $output = $fortune_file->get_random_fortune();
|
my $output = $fortune_file->get_random_fortune();
|
||||||
$output =~ s/\n/ /g;
|
$output =~ s/\n/ /g;
|
||||||
|
|
||||||
return $output,
|
return $output, structured_answer => {
|
||||||
structured_answer => {
|
data => {
|
||||||
input => [],
|
title => $output,
|
||||||
operation => 'Random fortune',
|
subtitle => "Random Fortune"
|
||||||
result => $output
|
},
|
||||||
};
|
templates => {
|
||||||
|
group => 'text'
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -20,12 +20,15 @@ handle remainder => sub {
|
||||||
|
|
||||||
my $address = join(':', map { sprintf '%0.2X', rand(255) } (1 .. 6));
|
my $address = join(':', map { sprintf '%0.2X', rand(255) } (1 .. 6));
|
||||||
|
|
||||||
return "Here's a random MAC address: $address",
|
return "Here's a random MAC address: $address", structured_answer => {
|
||||||
structured_answer => {
|
data => {
|
||||||
input => [],
|
title => $address,
|
||||||
operation => 'Random MAC address',
|
subtitle => 'Random MAC Address'
|
||||||
result => $address
|
},
|
||||||
};
|
templates => {
|
||||||
|
group => 'text'
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -3,6 +3,7 @@ package DDG::Goodie::GreatestCommonFactor;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use DDG::Goodie;
|
use DDG::Goodie;
|
||||||
|
use Math::BigInt try => 'GMP';
|
||||||
|
|
||||||
zci answer_type => "greatest_common_factor";
|
zci answer_type => "greatest_common_factor";
|
||||||
zci is_cached => 1;
|
zci is_cached => 1;
|
||||||
|
@ -22,23 +23,18 @@ handle remainder => sub {
|
||||||
my $formatted_numbers = join(', ', @numbers);
|
my $formatted_numbers = join(', ', @numbers);
|
||||||
$formatted_numbers =~ s/, ([^,]*)$/ and $1/;
|
$formatted_numbers =~ s/, ([^,]*)$/ and $1/;
|
||||||
|
|
||||||
my $result = shift @numbers;
|
my $result = Math::BigInt::bgcd(@numbers);
|
||||||
foreach (@numbers) {
|
|
||||||
$result = gcf($result, $_)
|
|
||||||
}
|
|
||||||
|
|
||||||
return "Greatest common factor of $formatted_numbers is $result.",
|
return "Greatest common factor of $formatted_numbers is $result.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [$formatted_numbers],
|
data => {
|
||||||
operation => 'Greatest common factor',
|
title => "$result",
|
||||||
result => $result
|
subtitle => "Greatest common factor: $formatted_numbers"
|
||||||
|
},
|
||||||
|
templates => {
|
||||||
|
group => "text",
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
sub gcf {
|
|
||||||
my ($x, $y) = @_;
|
|
||||||
($x, $y) = ($y, $x % $y) while $y;
|
|
||||||
return $x;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -17,10 +17,14 @@ handle query_raw => sub {
|
||||||
my $decimal = Math::BigInt->from_hex($hex);
|
my $decimal = Math::BigInt->from_hex($hex);
|
||||||
|
|
||||||
return "$hex base 16 = $decimal base 10", structured_answer => {
|
return "$hex base 16 = $decimal base 10", structured_answer => {
|
||||||
input => ['0x' . $hex],
|
data => {
|
||||||
operation => 'Hex to decimal',
|
title => "$decimal", # Quoted for display precision as string.
|
||||||
result => "$decimal", # Quoted for display precision as string.
|
subtitle => "Hex to decimal: 0x" . $hex
|
||||||
|
},
|
||||||
|
templates => {
|
||||||
|
group => 'text',
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
0x41414141;
|
0x01;
|
||||||
|
|
|
@ -18,12 +18,15 @@ handle remainder => sub {
|
||||||
|
|
||||||
return if ($lower eq $input);
|
return if ($lower eq $input);
|
||||||
|
|
||||||
return $lower,
|
return $lower, structured_answer => {
|
||||||
structured_answer => {
|
data => {
|
||||||
input => [html_enc($input)],
|
title => html_enc($lower),
|
||||||
operation => 'Lowercase',
|
subtitle => "Lowercase: " . html_enc($input)
|
||||||
result => html_enc($lower)
|
},
|
||||||
};
|
templates => {
|
||||||
|
group => 'text',
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -37,12 +37,15 @@ handle remainder => sub {
|
||||||
my $the_guy = $presidents[$index];
|
my $the_guy = $presidents[$index];
|
||||||
my $which = ordinate($num);
|
my $which = ordinate($num);
|
||||||
|
|
||||||
return "$the_guy $fact $which $POTUS.",
|
return "$the_guy $fact $which $POTUS.", structured_answer => {
|
||||||
structured_answer => {
|
data => {
|
||||||
input => [$which],
|
title => $the_guy,
|
||||||
operation => $POTUS,
|
subtitle => "$which $POTUS",
|
||||||
result => $the_guy,
|
},
|
||||||
};
|
templates => {
|
||||||
|
group => 'text'
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -38,11 +38,15 @@ handle query_lc => sub {
|
||||||
$rand = int($rand) + $start;
|
$rand = int($rand) + $start;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $rand . " (random number)",
|
return "$rand (random number)",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [$start, $end],
|
data => {
|
||||||
operation => 'Random number between',
|
title => $rand,
|
||||||
result => $rand
|
subtitle => "Random number between $start - $end"
|
||||||
|
},
|
||||||
|
templates => {
|
||||||
|
group => "text",
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,12 +29,15 @@ handle remainder => sub {
|
||||||
} @words
|
} @words
|
||||||
);
|
);
|
||||||
|
|
||||||
return $title_case,
|
return $title_case, structured_answer => {
|
||||||
structured_answer => {
|
data => {
|
||||||
input => [html_enc($input)],
|
title => html_enc($title_case),
|
||||||
operation => 'Title case',
|
subtitle => 'Title case: '.html_enc($input)
|
||||||
result => html_enc($title_case),
|
},
|
||||||
};
|
templates => {
|
||||||
|
group => 'text'
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -8,7 +8,7 @@ use DateTime;
|
||||||
use List::MoreUtils qw( uniq );
|
use List::MoreUtils qw( uniq );
|
||||||
use Try::Tiny;
|
use Try::Tiny;
|
||||||
|
|
||||||
my @trigger_words = ("unixtime", "datetime", "unix timestamp", "unix time stamp", "unix epoch", "epoch", "timestamp", "unix time", "utc time", "utc now", "current utc", "time since epoch");
|
my @trigger_words = ("unixtime", "datetime", "unix timestamp", "unix time stamp", "unix epoch", "epoch", "timestamp", "unix time", "utc time", "utc now", "current utc", "time since epoch", "epoch converter", "epoch time converter");
|
||||||
triggers startend => @trigger_words;
|
triggers startend => @trigger_words;
|
||||||
|
|
||||||
zci answer_type => "time_conversion";
|
zci answer_type => "time_conversion";
|
||||||
|
|
|
@ -20,12 +20,15 @@ handle remainder => sub {
|
||||||
|
|
||||||
my $upper = uc $input;
|
my $upper = uc $input;
|
||||||
|
|
||||||
return $upper,
|
return $upper, structured_answer => {
|
||||||
structured_answer => {
|
data => {
|
||||||
input => [html_enc($input)],
|
title => html_enc($upper),
|
||||||
operation => 'Uppercase',
|
subtitle => "Uppercase: ".html_enc($input)
|
||||||
result => html_enc($upper),
|
},
|
||||||
};
|
templates => {
|
||||||
|
group => 'text'
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -17,9 +17,13 @@ handle remainder => sub {
|
||||||
|
|
||||||
return $answer,
|
return $answer,
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['Valar morghulis'],
|
data => {
|
||||||
operation => 'Code phrase',
|
title => $answer,
|
||||||
result => $answer
|
subtitle => 'Code phrase: Valar morghulis'
|
||||||
|
},
|
||||||
|
templates => {
|
||||||
|
group => 'text'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,17 @@ handle query => sub {
|
||||||
|
|
||||||
return join("\n", @quote),
|
return join("\n", @quote),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [],
|
data => {
|
||||||
operation => 'Zapp Brannigan quote',
|
content => join("<br>", @quote),
|
||||||
result => join('<br>', @quote)};
|
subtitle => 'Zapp Brannigan quote'
|
||||||
|
},
|
||||||
|
templates => {
|
||||||
|
group => "text",
|
||||||
|
options => {
|
||||||
|
content => 'DDH.zapp_brannigan.content'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"id": "backbonejs_cheat_sheet",
|
"id": "backbone_js_cheat_sheet",
|
||||||
"name": "Backbone.js",
|
"name": "Backbone.js",
|
||||||
"description": "A quick reference for Backbone.js, a JavaScript framework with a RESTful JSON interface and is based on the model–view–presenter (MVP) application design paradigm",
|
"description": "A quick reference for Backbone.js, a JavaScript framework with a RESTful JSON interface and is based on the model–view–presenter (MVP) application design paradigm",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
},
|
},
|
||||||
"aliases": [
|
"aliases": [
|
||||||
"backbone.js",
|
"backbone.js",
|
||||||
"backbone js",
|
"backbonejs",
|
||||||
"backbone"
|
"backbone"
|
||||||
],
|
],
|
||||||
"template_type": "terminal",
|
"template_type": "terminal",
|
||||||
|
@ -162,4 +162,4 @@
|
||||||
"key": "Backbone.setDomLibrary(jQueryNew);"
|
"key": "Backbone.setDomLibrary(jQueryNew);"
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,18 +23,6 @@
|
||||||
],
|
],
|
||||||
"sections": {
|
"sections": {
|
||||||
"Arithmetic Operators": [
|
"Arithmetic Operators": [
|
||||||
{
|
|
||||||
"val": "Basic assignment",
|
|
||||||
"key": "a = b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"val": "Addition",
|
|
||||||
"key": "a + b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"val": "Subtraction",
|
|
||||||
"key": "a - b"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"val": "Unary plus (integer promotion)",
|
"val": "Unary plus (integer promotion)",
|
||||||
"key": "+a"
|
"key": "+a"
|
||||||
|
@ -43,18 +31,6 @@
|
||||||
"val": "Unary minus (additive inverse)",
|
"val": "Unary minus (additive inverse)",
|
||||||
"key": "-a"
|
"key": "-a"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"val": "Multiplication",
|
|
||||||
"key": "a * b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"val": "Division",
|
|
||||||
"key": "a / b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"val": "Modulo (integer remainder)",
|
|
||||||
"key": "a % b"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"val": "Increment Prefix",
|
"val": "Increment Prefix",
|
||||||
"key": "++a"
|
"key": "++a"
|
||||||
|
@ -70,6 +46,30 @@
|
||||||
{
|
{
|
||||||
"val": "Decrement Postfix",
|
"val": "Decrement Postfix",
|
||||||
"key": "a--"
|
"key": "a--"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"val": "Multiplication",
|
||||||
|
"key": "a * b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"val": "Division",
|
||||||
|
"key": "a / b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"val": "Modulo (integer remainder)",
|
||||||
|
"key": "a % b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"val": "Addition",
|
||||||
|
"key": "a + b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"val": "Subtraction",
|
||||||
|
"key": "a - b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"val": "Basic assignment",
|
||||||
|
"key": "a = b"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Comparison Operators": [
|
"Comparison Operators": [
|
||||||
|
@ -78,21 +78,21 @@
|
||||||
"key": "a < b"
|
"key": "a < b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"val": "a equal to b",
|
"val": "a less than equal to b",
|
||||||
"key": "a == b"
|
"key": "a <= b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"val": "a greater than b",
|
"val": "a greater than b",
|
||||||
"key": "a > b"
|
"key": "a > b"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"val": "a less than equal to b",
|
|
||||||
"key": "a <= b"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"val": "a greater than equal to b",
|
"val": "a greater than equal to b",
|
||||||
"key": "a >= b"
|
"key": "a >= b"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"val": "a equal to b",
|
||||||
|
"key": "a == b"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"val": "a not equal to b",
|
"val": "a not equal to b",
|
||||||
"key": "a != b"
|
"key": "a != b"
|
||||||
|
@ -117,18 +117,6 @@
|
||||||
"val": "Bitwise NOT / One's Complement",
|
"val": "Bitwise NOT / One's Complement",
|
||||||
"key": "~a"
|
"key": "~a"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"val": "Bitwise AND",
|
|
||||||
"key": "a & b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"val": "Bitwise OR",
|
|
||||||
"key": "a | b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"val": "Bitwise XOR",
|
|
||||||
"key": "a ^ b"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"val": "Bitwise left shift",
|
"val": "Bitwise left shift",
|
||||||
"key": "a << b"
|
"key": "a << b"
|
||||||
|
@ -136,6 +124,18 @@
|
||||||
{
|
{
|
||||||
"val": "Bitwise right shift",
|
"val": "Bitwise right shift",
|
||||||
"key": "a >> b"
|
"key": "a >> b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"val": "Bitwise AND",
|
||||||
|
"key": "a & b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"val": "Bitwise XOR",
|
||||||
|
"key": "a ^ b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"val": "Bitwise OR",
|
||||||
|
"key": "a | b"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Other Operators": [
|
"Other Operators": [
|
||||||
|
@ -275,4 +275,4 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -138,7 +138,7 @@
|
||||||
"val": "Specifies the type of positioning method used for an element",
|
"val": "Specifies the type of positioning method used for an element",
|
||||||
"key": "position:"
|
"key": "position:"
|
||||||
}, {
|
}, {
|
||||||
"val": "Specifies the stack order of an elemen",
|
"val": "Specifies the stack order of an element",
|
||||||
"key": "z-index:"
|
"key": "z-index:"
|
||||||
}],
|
}],
|
||||||
"Background Properties": [{
|
"Background Properties": [{
|
||||||
|
|
|
@ -0,0 +1,192 @@
|
||||||
|
{
|
||||||
|
"id": "emacs_evil_mode_cheat_sheet",
|
||||||
|
"name": "Evil-Mode for Emacs",
|
||||||
|
"description": "Shortcuts for the Evil-mode of the Emacs editor",
|
||||||
|
"metadata": {
|
||||||
|
"sourceName": "GitHub",
|
||||||
|
"sourceUrl": "https://github.com/amirrajan/devbox/wiki/EMACS-Evil-Cheat-Sheet"
|
||||||
|
},
|
||||||
|
"template_type": "keyboard",
|
||||||
|
"aliases": [
|
||||||
|
"evil emacs",
|
||||||
|
"emacs evil-mode",
|
||||||
|
"evil-mode emacs",
|
||||||
|
"evil-mode for emacs",
|
||||||
|
"evil mode for emacs",
|
||||||
|
"evil emacs mode"
|
||||||
|
],
|
||||||
|
"section_order": [
|
||||||
|
"Editing Text",
|
||||||
|
"Window Navigation",
|
||||||
|
"Discovery"
|
||||||
|
],
|
||||||
|
"sections": {
|
||||||
|
"Editing Text": [
|
||||||
|
{
|
||||||
|
"key": "ESC",
|
||||||
|
"val": "Command Mode"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ":w",
|
||||||
|
"val": "save"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ":q",
|
||||||
|
"val": "quit"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ":wq",
|
||||||
|
"val": "save and quit"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ":wqa",
|
||||||
|
"val": "save quit all"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "hjkl",
|
||||||
|
"val": "to navigate"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "w",
|
||||||
|
"val": "to move forward by one word"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "b",
|
||||||
|
"val": "to move back by one word"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "shift+[",
|
||||||
|
"val": "move up by new lines"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "shift+]",
|
||||||
|
"val": "to move down by new lines"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "yy",
|
||||||
|
"val": "copy line"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "dd",
|
||||||
|
"val": "delete line"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "cc",
|
||||||
|
"val": "change line"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Y",
|
||||||
|
"val": "copy till the end of line"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "D",
|
||||||
|
"val": "delete till the end of line"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "C",
|
||||||
|
"val": "change till the end of line"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "yw",
|
||||||
|
"val": "yank word"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "dw",
|
||||||
|
"val": "delete word"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "cw",
|
||||||
|
"val": "change word"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "gg",
|
||||||
|
"val": "go to top of file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "G",
|
||||||
|
"val": "goto bottom of file"
|
||||||
|
}
|
||||||
|
|
||||||
|
],
|
||||||
|
"Window Navigation": [
|
||||||
|
{
|
||||||
|
"key": ",g",
|
||||||
|
"val": "go to file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ",b",
|
||||||
|
"val": "view recently visited files"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ",m",
|
||||||
|
"val": "new vertical split"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ":split",
|
||||||
|
"val": "new horizontal split"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ",.",
|
||||||
|
"val": "open current directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "C-h , C-j ,C-k ,C-l",
|
||||||
|
"val": "navigate between windows"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ",)",
|
||||||
|
"val": "previous buffer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ",(",
|
||||||
|
"val": "next buffer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ":ack ENT",
|
||||||
|
"val": "search across files"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ",f",
|
||||||
|
"val": "next search result"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ",d",
|
||||||
|
"val": "previous search result"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "CTRL+v",
|
||||||
|
"val": "visula block mode"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "While in visual Block Mode shift + i",
|
||||||
|
"val": "Insert Mode to append text to selection from Visual Block Mode"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Discovery": [
|
||||||
|
{
|
||||||
|
"key": ":describe-char",
|
||||||
|
"val": "describes the char underneath the cursor, allows you to change color theme from there"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ":customize-face",
|
||||||
|
"val": "editor for changing all color themes use tab and shift+tab to navigate"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "F1 k KEYSTROKE",
|
||||||
|
"val": "press F1 followed by k, then enter a key stroke to find information about what editor method was invoked"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "F1 f METHODNAME",
|
||||||
|
"val": "gives information about an editor method"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "F1 a SEARCH",
|
||||||
|
"val": "search for an editor method containing the search term"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ":METHODNAME",
|
||||||
|
"val": "invoke editor method"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -120,6 +120,9 @@
|
||||||
}, {
|
}, {
|
||||||
"val": "repeat the expression in query <N>",
|
"val": "repeat the expression in query <N>",
|
||||||
"key": "e(N)."
|
"key": "e(N)."
|
||||||
|
}, {
|
||||||
|
"val": "forget variable binding <N>",
|
||||||
|
"key": "f(N)."
|
||||||
}, {
|
}, {
|
||||||
"val": "forget all variable bindings",
|
"val": "forget all variable bindings",
|
||||||
"key": "f()."
|
"key": "f()."
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
"id": "finnish_cheat_sheet",
|
"id": "finnish_cheat_sheet",
|
||||||
"name": "Finnish Cheat Sheet",
|
"name": "Finnish Cheat Sheet",
|
||||||
"description": "Basic Finnish words and phrases",
|
"description": "Basic Finnish words and phrases",
|
||||||
"aliases": ["english to finnish", "basic finnish"],
|
|
||||||
"template_type": "language",
|
"template_type": "language",
|
||||||
"section_order": ["Basics", "Getting Help", "Travelling", "Etiquette", "Going out for dinner", "Numbers"],
|
"section_order": ["Basics", "Getting Help", "Travelling", "Etiquette", "Going out for dinner", "Numbers"],
|
||||||
"sections": {
|
"sections": {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
"aliases": [
|
"aliases": [
|
||||||
"valyrian", "game of thrones language", "valyrian language"
|
"valyrian"
|
||||||
],
|
],
|
||||||
|
|
||||||
"template_type": "language",
|
"template_type": "language",
|
||||||
|
|
|
@ -8,10 +8,6 @@
|
||||||
"sourceUrl" : "http://www.omniglot.com/language/phrases/kannada.php"
|
"sourceUrl" : "http://www.omniglot.com/language/phrases/kannada.php"
|
||||||
},
|
},
|
||||||
|
|
||||||
"aliases": [
|
|
||||||
"basic kannada"
|
|
||||||
],
|
|
||||||
|
|
||||||
"template_type": "language",
|
"template_type": "language",
|
||||||
|
|
||||||
"section_order": [
|
"section_order": [
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
"aliases": [
|
"aliases": [
|
||||||
"spanish words", "spanish to english", "spanish greetings", "basic spanish", "spanish questions"
|
"spanish words", "spanish greetings", "spanish questions"
|
||||||
],
|
],
|
||||||
|
|
||||||
"template_type": "language",
|
"template_type": "language",
|
||||||
|
@ -330,4 +330,4 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,6 @@
|
||||||
"sourceName":"Wikitravel",
|
"sourceName":"Wikitravel",
|
||||||
"sourceUrl":"http://wikitravel.org/en/Telugu_phrasebook"
|
"sourceUrl":"http://wikitravel.org/en/Telugu_phrasebook"
|
||||||
},
|
},
|
||||||
"aliases":[
|
|
||||||
"english to telugu",
|
|
||||||
"basic telugu"
|
|
||||||
],
|
|
||||||
"template_type":"language",
|
"template_type":"language",
|
||||||
"section_order":[
|
"section_order":[
|
||||||
"Basics",
|
"Basics",
|
||||||
|
@ -269,4 +265,4 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "logarithms_cheat_sheet",
|
"id": "logarithms_cheat_sheet",
|
||||||
"name": "Logarithms",
|
"name": "Logarithms",
|
||||||
"description": "displayed as subtitle of the AnswerBar; optional",
|
"description": "List of logarithmic rules and formulae.",
|
||||||
|
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"sourceName": "SCRIBD",
|
"sourceName": "SCRIBD",
|
||||||
|
@ -9,7 +9,10 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
"aliases": [
|
"aliases": [
|
||||||
"logarithmic identities", "logarithms rules"
|
"logarithmic identities", "logarithms rules",
|
||||||
|
"logarithm identities", "logarithm rules",
|
||||||
|
"log identities", "log rules",
|
||||||
|
"logarithm"
|
||||||
],
|
],
|
||||||
|
|
||||||
"template_type": "reference",
|
"template_type": "reference",
|
||||||
|
|
|
@ -132,7 +132,7 @@
|
||||||
}],
|
}],
|
||||||
"Basic Syntax": [{
|
"Basic Syntax": [{
|
||||||
"val": "Read command line params",
|
"val": "Read command line params",
|
||||||
"key": "($a, $b) = shift(@ARGV);"
|
"key": "($a, $b) = @ARGV;"
|
||||||
}, {
|
}, {
|
||||||
"val": "Define subroutine",
|
"val": "Define subroutine",
|
||||||
"key": "sub p\\{my $var = shift; ...\\}"
|
"key": "sub p\\{my $var = shift; ...\\}"
|
||||||
|
|
|
@ -236,9 +236,6 @@
|
||||||
}, {
|
}, {
|
||||||
"key": "FOREIGN KEY",
|
"key": "FOREIGN KEY",
|
||||||
"val": "Ensure the referential integrity of the data in one table to match values in another table"
|
"val": "Ensure the referential integrity of the data in one table to match values in another table"
|
||||||
}, {
|
|
||||||
"key": "FOREIGN KEY",
|
|
||||||
"val": "Ensure the referential integrity of the data in one table to match values in another table"
|
|
||||||
}, {
|
}, {
|
||||||
"key": "DEFAULT",
|
"key": "DEFAULT",
|
||||||
"val": "Specifies a default value for a column"
|
"val": "Specifies a default value for a column"
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
},
|
},
|
||||||
"template_type": "keyboard",
|
"template_type": "keyboard",
|
||||||
"section_order": [
|
"section_order": [
|
||||||
|
"Exiting",
|
||||||
"Cursor movement",
|
"Cursor movement",
|
||||||
"Insert mode - inserting/appending text",
|
"Insert mode - inserting/appending text",
|
||||||
"Editing",
|
"Editing",
|
||||||
"Marking text (visual mode)",
|
"Marking text (visual mode)",
|
||||||
"Visual commands",
|
"Visual commands",
|
||||||
"Cut and paste",
|
"Cut and paste",
|
||||||
"Exiting",
|
|
||||||
"Search and replace",
|
"Search and replace",
|
||||||
"Working with multiple files",
|
"Working with multiple files",
|
||||||
"Tabs",
|
"Tabs",
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
"sourceName": "Microsoft",
|
"sourceName": "Microsoft",
|
||||||
"sourceUrl": "https://msdn.microsoft.com/en-us/library/da5kh0wa.aspx"
|
"sourceUrl": "https://msdn.microsoft.com/en-us/library/da5kh0wa.aspx"
|
||||||
},
|
},
|
||||||
|
"template_type": "keyboard",
|
||||||
"section_order": ["Edit","Debug","Build","Project"],
|
"section_order": ["Edit","Debug","Build","Project"],
|
||||||
"sections": {
|
"sections": {
|
||||||
"Edit": [{
|
"Edit": [{
|
|
@ -0,0 +1,61 @@
|
||||||
|
{
|
||||||
|
"id": "wget_cheat_sheet",
|
||||||
|
"name": "Wget",
|
||||||
|
"description": "A computer program that retrieves content from web servers via HTTP, HTTPS, and FTP protocols",
|
||||||
|
|
||||||
|
"metadata": {
|
||||||
|
"sourceName": "GNU",
|
||||||
|
"sourceUrl" : "https://www.gnu.org/manual/manual.html"
|
||||||
|
},
|
||||||
|
|
||||||
|
"aliases": [
|
||||||
|
"gnu wget"
|
||||||
|
],
|
||||||
|
|
||||||
|
"template_type": "terminal",
|
||||||
|
|
||||||
|
"section_order": [
|
||||||
|
"Useful Commands"
|
||||||
|
],
|
||||||
|
|
||||||
|
"sections": {
|
||||||
|
"Useful Commands": [
|
||||||
|
{
|
||||||
|
"key": "wget <url>",
|
||||||
|
"val": "Download single file and stores in a current directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "-O (uppercase)",
|
||||||
|
"val": "Download file with different name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "http:// , ftp://",
|
||||||
|
"val": "Download multiple file with http and ftp protocol"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wget -i /wget/tmp.txt",
|
||||||
|
"val": "Read URL’s from a file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wget -c",
|
||||||
|
"val": "Resume uncompleted download"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wget -b",
|
||||||
|
"val": "Download files in background"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wget -c --limit-rate=100k",
|
||||||
|
"val": "Restrict download speed limits"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wget --http-user=narad --http-password=password",
|
||||||
|
"val": "Restricted FTP and HTTP downloads with username and password"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wget --version",
|
||||||
|
"val": "Find wget version"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,110 @@
|
||||||
|
{
|
||||||
|
"id": "youtubedl_cheat_sheet",
|
||||||
|
"name": "Youtube-dl",
|
||||||
|
"description": "Small command-line program to download videos from YouTube.com and other video sites",
|
||||||
|
|
||||||
|
"metadata": {
|
||||||
|
"sourceName": "Github",
|
||||||
|
"sourceUrl": "https://github.com/rg3/youtube-dl/blob/master/README.md#readme"
|
||||||
|
},
|
||||||
|
|
||||||
|
"aliases": [
|
||||||
|
"youtube-dl", "youtube dl"
|
||||||
|
],
|
||||||
|
|
||||||
|
"template_type": "terminal",
|
||||||
|
|
||||||
|
"section_order": [
|
||||||
|
"Network Options",
|
||||||
|
"Video Selection",
|
||||||
|
"Download Options",
|
||||||
|
"Filesystem Options",
|
||||||
|
"Video Format Options"
|
||||||
|
],
|
||||||
|
|
||||||
|
"sections": {
|
||||||
|
"Network Options": [{
|
||||||
|
"key": "--proxy URL",
|
||||||
|
"val": "Use the specified HTTP/HTTPS proxy. Pass in an empty string (--proxy ) for direct connection"
|
||||||
|
}, {
|
||||||
|
"key": "-4, --force-ipv4",
|
||||||
|
"val": " Make all connections via IPv4"
|
||||||
|
}, {
|
||||||
|
"key": "-6, --force-ipv6",
|
||||||
|
"val": " Make all connections via IPv6"
|
||||||
|
}, {
|
||||||
|
"key": "--source-address IP ",
|
||||||
|
"val": "Client-side IP address to bind to"
|
||||||
|
}],
|
||||||
|
"Video Selection": [{
|
||||||
|
"key": "--playlist-start NUMBER",
|
||||||
|
"val": "Playlist video to start at (default is 1)"
|
||||||
|
}, {
|
||||||
|
"key": "--playlist-end NUMBER",
|
||||||
|
"val": "Playlist video to end at (default is last)"
|
||||||
|
}, {
|
||||||
|
"key": "--max-downloads NUMBER",
|
||||||
|
"val": "Abort after downloading NUMBER files"
|
||||||
|
}, {
|
||||||
|
"key": "--include-ads",
|
||||||
|
"val": "Download advertisements as well"
|
||||||
|
}, {
|
||||||
|
"key": "--yes-playlist",
|
||||||
|
"val": "Download the playlist, if the URL refers to a video and a playlist"
|
||||||
|
}],
|
||||||
|
"Download Options": [{
|
||||||
|
"key": "-r, --rate-limit LIMIT",
|
||||||
|
"val": "Maximum download rate in bytes per second"
|
||||||
|
}, {
|
||||||
|
"key": "-R, --retries RETRIES",
|
||||||
|
"val": "Number of retries (default is 10), or infinite"
|
||||||
|
}, {
|
||||||
|
"key": "--buffer-size SIZE",
|
||||||
|
"val": "Size of download buffer (e.g. 1024 or 16K)"
|
||||||
|
}, {
|
||||||
|
"key": "--external-downloader COMMAND",
|
||||||
|
"val": "Use the specified external downloader Currently supports"
|
||||||
|
}, {
|
||||||
|
"key": "--external-downloader-args ARGS",
|
||||||
|
"val": "Give these arguments to the external downloader"
|
||||||
|
}],
|
||||||
|
"Filesystem Options": [{
|
||||||
|
"key": "-a, --batch-file FILE",
|
||||||
|
"val": "File containing URLs to download"
|
||||||
|
}, {
|
||||||
|
"key": "--id",
|
||||||
|
"val": "Use only video ID in file name"
|
||||||
|
}, {
|
||||||
|
"key": "--autonumber-size NUMBER",
|
||||||
|
"val": "Specify the number of digits in %(autonumber)s when it is present in output filename template or --auto-number option is given"
|
||||||
|
}, {
|
||||||
|
"key": "-c, --continue",
|
||||||
|
"val": "Force resume of partially downloaded files. By default, youtube-dl will resume downloads if possible."
|
||||||
|
}, {
|
||||||
|
"key": "--no-continue",
|
||||||
|
"val": "Do not resume partially downloaded files"
|
||||||
|
}, {
|
||||||
|
"key": "--cookies FILE",
|
||||||
|
"val": "File to read cookies from and dump cookie jar in"
|
||||||
|
}],
|
||||||
|
"Video Format Options": [{
|
||||||
|
"key": "-f, --format FORMAT",
|
||||||
|
"val": "Video format code, see the FORMAT SELECTION for all the info"
|
||||||
|
}, {
|
||||||
|
"key": "--all-formats",
|
||||||
|
"val": "Download all available video formats"
|
||||||
|
}, {
|
||||||
|
"key": "--prefer-free-formats",
|
||||||
|
"val": "Prefer free video formats unless a specific one is requested"
|
||||||
|
}, {
|
||||||
|
"key": "-F, --list-formats",
|
||||||
|
"val": "List all available formats of requested videos"
|
||||||
|
}, {
|
||||||
|
"key": "--youtube-skip-dash-manifest",
|
||||||
|
"val": "Do not download the DASH manifests and related data on YouTube videos"
|
||||||
|
}, {
|
||||||
|
"key": "--merge-output-format FORMAT",
|
||||||
|
"val": "If a merge is required (e.g. bestvideo+bestaudio), output to given container format. One of mkv, mp4, ogg, webm, flv. Ignored if no merge is required"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
{
|
||||||
|
"id": "zfs_cheat_sheet",
|
||||||
|
"name": "ZFS",
|
||||||
|
"description": "The combined file system and logical volume manager. Data are important - be careful with it.",
|
||||||
|
"metadata": {
|
||||||
|
"sourceName": "FreeBSD handbook - The Z File System (ZFS)",
|
||||||
|
"sourceUrl": "https://www.freebsd.org/doc/handbook/zfs.html"
|
||||||
|
},
|
||||||
|
"aliases": [
|
||||||
|
"z file system",
|
||||||
|
"zpool"
|
||||||
|
],
|
||||||
|
"template_type": "terminal",
|
||||||
|
"section_order": [
|
||||||
|
"Pools",
|
||||||
|
"Datasets"
|
||||||
|
],
|
||||||
|
"sections": {
|
||||||
|
"Pools": [
|
||||||
|
{
|
||||||
|
"key": "zpool list",
|
||||||
|
"val": "Lists the given pools."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zpool status \\[$POOLNAME\\]",
|
||||||
|
"val": "Displays the detailed health status."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zpool get all $POOLNAME",
|
||||||
|
"val": "Retrieves the all properties for the pool."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zpool set $PROPERTY=$VALUE $POOLNAME",
|
||||||
|
"val": "Sets the given property on the pool."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zpool create \\[$POOLTYPE\\] $POOLNAME $DEVICE1",
|
||||||
|
"val": "Create a pool (Pool types: _ | spare | mirror | raidz)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zpool replace $POOLNAME $DEV_OLD \\[$DEV_NEW\\]",
|
||||||
|
"val": "Replaces the old device with new one."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zpool destroy $POOLNAME",
|
||||||
|
"val": "Destroys the given pool."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zpool remove $POOLNAME $DEVICE",
|
||||||
|
"val": "Remove a physical device from the pool."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zpool online $POOLNAME $DEVICE",
|
||||||
|
"val": "Device is online and functioning."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zpool offline $POOLNAME $DEVICE",
|
||||||
|
"val": "Take device explicitly offline."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zpool scrub $POOLNAME",
|
||||||
|
"val": "Begin to examines all data in the pool to verify that checksums are correctly."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zpool \\[attach|detach\\] $POOLNAME $DEVICE",
|
||||||
|
"val": "Attach or Detaches device from a pool."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zpool iostat \\[$POOLNAME\\]",
|
||||||
|
"val": "Displays I/O statistics for the given pool."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Datasets": [
|
||||||
|
{
|
||||||
|
"key": "zfs list",
|
||||||
|
"val": "Lists the properties for the given datasets."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zfs list -t snapshot /\\[$DATASET\\]",
|
||||||
|
"val": "Display a list of snapshots from /[] directory."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zfs snaphot \\[-r\\] $POOLNAME/$DATASET@$SNAPSHOTNAME",
|
||||||
|
"val": "Takes a [recursiv] snaphot of dataset."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zfs set $OPTION=$VALUE $POOLNAME/$DATASET",
|
||||||
|
"val": "Set the property to the given value for a dataset."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zfs clone $POOLNAME/$DATASET@$SNAPSHOTNAME $POOLNAME/$CLONE",
|
||||||
|
"val": "Creates a clone of the given snapshot."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zfs rollback \\[-rR\\] $POOLNAME/$DATASET@$SNAPSHOTNAME",
|
||||||
|
"val": "Roll back the given dataset to a previous snapshot."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zfs destroy $POOLNAME/$DATASET@$SNAPSHOTNAME",
|
||||||
|
"val": "Destroys the given dataset."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zfs mount $POOLNAME",
|
||||||
|
"val": "Mounts of the ZFS file systems."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "zfs umount $POOLNAME\\[/$MOUNTPOINT\\]",
|
||||||
|
"val": "Unmounts currently mounted ZFS file systems."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -36,6 +36,8 @@ categories:
|
||||||
- "cheat codes"
|
- "cheat codes"
|
||||||
- "cheats"
|
- "cheats"
|
||||||
- "secrets"
|
- "secrets"
|
||||||
|
ignore:
|
||||||
|
- "game"
|
||||||
# Describes or introduces syntax of a programming language.
|
# Describes or introduces syntax of a programming language.
|
||||||
code:
|
code:
|
||||||
startend:
|
startend:
|
||||||
|
@ -61,17 +63,26 @@ categories:
|
||||||
- "keyboard shortcuts"
|
- "keyboard shortcuts"
|
||||||
- "keys"
|
- "keys"
|
||||||
- "shortcuts"
|
- "shortcuts"
|
||||||
|
ignore:
|
||||||
|
- "default"
|
||||||
# Introduces basic translations for a human language.
|
# Introduces basic translations for a human language.
|
||||||
language:
|
language:
|
||||||
startend:
|
startend:
|
||||||
- "phrases"
|
- "phrases"
|
||||||
- "translations"
|
- "translations"
|
||||||
|
ignore:
|
||||||
|
- "basic"
|
||||||
|
- "english to"
|
||||||
|
- "language"
|
||||||
# Shows links to other sites.
|
# Shows links to other sites.
|
||||||
links:
|
links:
|
||||||
startend:
|
startend:
|
||||||
- "links"
|
- "links"
|
||||||
- "sites"
|
- "sites"
|
||||||
- "websites"
|
- "websites"
|
||||||
|
ignore:
|
||||||
|
- "list"
|
||||||
|
- "list of"
|
||||||
# Shows mathematical equations.
|
# Shows mathematical equations.
|
||||||
math:
|
math:
|
||||||
startend:
|
startend:
|
||||||
|
@ -82,8 +93,9 @@ categories:
|
||||||
reference:
|
reference:
|
||||||
startend:
|
startend:
|
||||||
- "help"
|
- "help"
|
||||||
- "quick reference"
|
|
||||||
- "reference"
|
- "reference"
|
||||||
|
ignore:
|
||||||
|
- "quick"
|
||||||
# Describes commands that can be entered at a terminal.
|
# Describes commands that can be entered at a terminal.
|
||||||
terminal:
|
terminal:
|
||||||
startend:
|
startend:
|
||||||
|
|
|
@ -80,16 +80,26 @@ bohr magneton:
|
||||||
html: '9.27400968 × 10<sup>−24</sup> J T<sup>−1</sup>'
|
html: '9.27400968 × 10<sup>−24</sup> J T<sup>−1</sup>'
|
||||||
|
|
||||||
boltzmann constant:
|
boltzmann constant:
|
||||||
name: The Stefan Boltzmann Constant
|
name: The Boltzmann Constant
|
||||||
aliases:
|
aliases:
|
||||||
- stefan boltzmann constant
|
- the boltzmann constant
|
||||||
- the stefan boltzmann constant
|
symbol: k
|
||||||
symbol:
|
|
||||||
wiki:
|
wiki:
|
||||||
value:
|
value:
|
||||||
plain: '1.3806503 × 10^-23 m^2 kg s^-2 K^-1'
|
plain: '1.3806503 × 10^-23 m^2 kg s^-2 K^-1'
|
||||||
html: '1.3806503 × 10<sup>-23</sup> m<sup>2</sup> kg s<sup>-2</sup> K<sup>-1</sup>'
|
html: '1.3806503 × 10<sup>-23</sup> m<sup>2</sup> kg s<sup>-2</sup> K<sup>-1</sup>'
|
||||||
|
|
||||||
|
stefan-boltzmann constant:
|
||||||
|
name: The Stefan-Boltzmann Constant
|
||||||
|
aliases:
|
||||||
|
- the stefan boltzmann constant
|
||||||
|
- stefan boltzmann constant
|
||||||
|
symbol: σ
|
||||||
|
wiki:
|
||||||
|
value:
|
||||||
|
plain: '5.670367 × 10^−8 W m^−2 K^−4'
|
||||||
|
html: '5.670367 × 10<sup>−8</sup> W m<sup>−2</sup> K<sup>−4</sup>'
|
||||||
|
|
||||||
elementary electric charge:
|
elementary electric charge:
|
||||||
name: Elementary Electric Charge
|
name: Elementary Electric Charge
|
||||||
aliases:
|
aliases:
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
||||||
|
<h3 class="c-base__title">{{{content}}}</h3>
|
28
t/ABC.t
28
t/ABC.t
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'choice';
|
zci answer_type => 'choice';
|
||||||
|
@ -12,7 +13,7 @@ sub create_structured_answer
|
||||||
{
|
{
|
||||||
my $data = shift;
|
my $data = shift;
|
||||||
return {
|
return {
|
||||||
data => $data, #'-ANY-',
|
data => $data, #ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
moreAt => 0
|
moreAt => 0
|
||||||
|
@ -30,28 +31,28 @@ ddg_goodie_test(
|
||||||
'choose his or or her house' => undef,
|
'choose his or or her house' => undef,
|
||||||
'choose from products like turkey or venison' => undef,
|
'choose from products like turkey or venison' => undef,
|
||||||
'choose pick or axe' => test_zci(
|
'choose pick or axe' => test_zci(
|
||||||
qr/(pick|axe) \(Random\)/,
|
re(qr/(pick|axe) \(Random\)/),
|
||||||
structured_answer => create_structured_answer('-ANY-')
|
structured_answer => create_structured_answer(ignore())
|
||||||
),
|
),
|
||||||
'choose yes or no' => test_zci(
|
'choose yes or no' => test_zci(
|
||||||
qr/(yes|no) \(Random\)/,
|
re(qr/(yes|no) \(Random\)/),
|
||||||
structured_answer => create_structured_answer('-ANY-')
|
structured_answer => create_structured_answer(ignore())
|
||||||
),
|
),
|
||||||
'choose this or that or none' => test_zci(
|
'choose this or that or none' => test_zci(
|
||||||
qr/(this|that|none) \(Random\)/,
|
re(qr/(this|that|none) \(Random\)/),
|
||||||
structured_answer => create_structured_answer('-ANY-')
|
structured_answer => create_structured_answer(ignore())
|
||||||
),
|
),
|
||||||
'pick this or that or none' => test_zci(
|
'pick this or that or none' => test_zci(
|
||||||
qr/(this|that|none) \(Random\)/,
|
re(qr/(this|that|none) \(Random\)/),
|
||||||
structured_answer => create_structured_answer('-ANY-')
|
structured_answer => create_structured_answer(ignore())
|
||||||
),
|
),
|
||||||
'select heads or tails' => test_zci(
|
'select heads or tails' => test_zci(
|
||||||
qr/(heads|tails) \(Random\)/,
|
re(qr/(heads|tails) \(Random\)/),
|
||||||
structured_answer => create_structured_answer('-ANY-')
|
structured_answer => create_structured_answer(ignore())
|
||||||
),
|
),
|
||||||
'choose heads or tails' => test_zci(
|
'choose heads or tails' => test_zci(
|
||||||
qr/(heads|tails) \(Random\)/,
|
re(qr/(heads|tails) \(Random\)/),
|
||||||
structured_answer => create_structured_answer('-ANY-')
|
structured_answer => create_structured_answer(ignore())
|
||||||
),
|
),
|
||||||
'choose duckduckgo or google or bing or something' => test_zci(
|
'choose duckduckgo or google or bing or something' => test_zci(
|
||||||
'duckduckgo (Non-random)',
|
'duckduckgo (Non-random)',
|
||||||
|
@ -70,4 +71,3 @@ ddg_goodie_test(
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'date_conversion';
|
zci answer_type => 'date_conversion';
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'anagram';
|
zci answer_type => 'anagram';
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'aspect_ratio';
|
zci answer_type => 'aspect_ratio';
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'atbash';
|
zci answer_type => 'atbash';
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'average';
|
zci answer_type => 'average';
|
||||||
|
@ -42,4 +43,3 @@ ddg_goodie_test(
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
||||||
|
|
29
t/BPMToMs.t
29
t/BPMToMs.t
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "bpmto_ms";
|
zci answer_type => "bpmto_ms";
|
||||||
|
@ -30,49 +31,49 @@ ddg_goodie_test(
|
||||||
"120 beats per minute to ms" => test_zci(
|
"120 beats per minute to ms" => test_zci(
|
||||||
$plaintext_120,
|
$plaintext_120,
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
# [
|
# [
|
||||||
# {
|
# {
|
||||||
# note_type => "Whole Note",
|
# note_type => "Whole Note",
|
||||||
# triplet => 1333,
|
# triplet => 1333,
|
||||||
# dotted => 3000,
|
# dotted => 3000,
|
||||||
# milliseconds => 2000,
|
# milliseconds => 2000,
|
||||||
# image => qr/.*/
|
# image => re(qr/.*/)
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# note_type => "Half Note",
|
# note_type => "Half Note",
|
||||||
# triplet => 667,
|
# triplet => 667,
|
||||||
# dotted => 1500,
|
# dotted => 1500,
|
||||||
# milliseconds => 1000,
|
# milliseconds => 1000,
|
||||||
# image => qr/.*/
|
# image => re(qr/.*/)
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# note_type => "Quarter Note",
|
# note_type => "Quarter Note",
|
||||||
# triplet => 333,
|
# triplet => 333,
|
||||||
# dotted => 750,
|
# dotted => 750,
|
||||||
# milliseconds => 500,
|
# milliseconds => 500,
|
||||||
# image => qr/.*/
|
# image => re(qr/.*/)
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# note_type => "1/8 Note",
|
# note_type => "1/8 Note",
|
||||||
# triplet => 167,
|
# triplet => 167,
|
||||||
# dotted => 375,
|
# dotted => 375,
|
||||||
# milliseconds => 250,
|
# milliseconds => 250,
|
||||||
# image => qr/.*/
|
# image => re(qr/.*/)
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# note_type => "1/16 Note",
|
# note_type => "1/16 Note",
|
||||||
# triplet => 83,
|
# triplet => 83,
|
||||||
# dotted => 188,
|
# dotted => 188,
|
||||||
# milliseconds => 125,
|
# milliseconds => 125,
|
||||||
# image => qr/.*/
|
# image => re(qr/.*/)
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# note_type => "1/32 Note",
|
# note_type => "1/32 Note",
|
||||||
# triplet => 42,
|
# triplet => 42,
|
||||||
# dotted => 94,
|
# dotted => 94,
|
||||||
# milliseconds => 63,
|
# milliseconds => 63,
|
||||||
# image => qr/.*/
|
# image => re(qr/.*/)
|
||||||
# }
|
# }
|
||||||
# ],
|
# ],
|
||||||
meta => {
|
meta => {
|
||||||
|
@ -92,49 +93,49 @@ ddg_goodie_test(
|
||||||
"61 beats per minute to ms" => test_zci(
|
"61 beats per minute to ms" => test_zci(
|
||||||
$plaintext_61,
|
$plaintext_61,
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
# [
|
# [
|
||||||
# {
|
# {
|
||||||
# note_type => "Whole Note",
|
# note_type => "Whole Note",
|
||||||
# triplet => 2623,
|
# triplet => 2623,
|
||||||
# dotted => 5902,
|
# dotted => 5902,
|
||||||
# milliseconds => 3934,
|
# milliseconds => 3934,
|
||||||
# image => qr/.*/
|
# image => re(qr/.*/)
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# note_type => "Half Note",
|
# note_type => "Half Note",
|
||||||
# triplet => 1311,
|
# triplet => 1311,
|
||||||
# dotted => 2951,
|
# dotted => 2951,
|
||||||
# milliseconds => 1967,
|
# milliseconds => 1967,
|
||||||
# image => qr/.*/
|
# image => re(qr/.*/)
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# note_type => "Quarter Note",
|
# note_type => "Quarter Note",
|
||||||
# triplet => 656,
|
# triplet => 656,
|
||||||
# dotted => 1475,
|
# dotted => 1475,
|
||||||
# milliseconds => 984,
|
# milliseconds => 984,
|
||||||
# image => qr/.*/
|
# image => re(qr/.*/)
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# note_type => "1/8 Note",
|
# note_type => "1/8 Note",
|
||||||
# triplet => 328,
|
# triplet => 328,
|
||||||
# dotted => 738,
|
# dotted => 738,
|
||||||
# milliseconds => 492,
|
# milliseconds => 492,
|
||||||
# image => qr/.*/
|
# image => re(qr/.*/)
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# note_type => "1/16 Note",
|
# note_type => "1/16 Note",
|
||||||
# triplet => 164,
|
# triplet => 164,
|
||||||
# dotted => 369,
|
# dotted => 369,
|
||||||
# milliseconds => 246,
|
# milliseconds => 246,
|
||||||
# image => qr/.*/
|
# image => re(qr/.*/)
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# note_type => "1/32 Note",
|
# note_type => "1/32 Note",
|
||||||
# triplet => 82,
|
# triplet => 82,
|
||||||
# dotted => 184,
|
# dotted => 184,
|
||||||
# milliseconds => 123,
|
# milliseconds => 123,
|
||||||
# image => qr/.*/
|
# image => re(qr/.*/)
|
||||||
# }
|
# }
|
||||||
# ],
|
# ],
|
||||||
meta => {
|
meta => {
|
||||||
|
|
1
t/BRT.t
1
t/BRT.t
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "brt";
|
zci answer_type => "brt";
|
||||||
|
|
2
t/Base.t
2
t/Base.t
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'conversion';
|
zci answer_type => 'conversion';
|
||||||
|
@ -39,4 +40,3 @@ ddg_goodie_test(
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'base64_conversion';
|
zci answer_type => 'base64_conversion';
|
||||||
|
|
|
@ -2,6 +2,7 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'expression_description';
|
zci answer_type => 'expression_description';
|
||||||
|
@ -12,7 +13,7 @@ ddg_goodie_test(
|
||||||
'DDG::Goodie::BashPrimaryExpressions'
|
'DDG::Goodie::BashPrimaryExpressions'
|
||||||
],
|
],
|
||||||
"bash [ -a b ]" => test_zci(
|
"bash [ -a b ]" => test_zci(
|
||||||
qr/.+ true if b exists./,
|
re(qr/.+ true if b exists./),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => {
|
data => {
|
||||||
intro => "[ -a b ]",
|
intro => "[ -a b ]",
|
||||||
|
@ -39,9 +40,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'bash [[ "abc" < "cba" ]]' => test_zci(
|
'bash [[ "abc" < "cba" ]]' => test_zci(
|
||||||
qr/.+ true if "abc" string-sorts before "cba" in the current locale./,
|
re(qr/.+ true if "abc" string-sorts before "cba" in the current locale./),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -52,9 +53,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'bash [ 2 -gt 1 ]' => test_zci(
|
'bash [ 2 -gt 1 ]' => test_zci(
|
||||||
qr/.+ true if 2 is numerically greater than 1./,
|
re(qr/.+ true if 2 is numerically greater than 1./),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -65,9 +66,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'bash [ ! hello == world ]' => test_zci(
|
'bash [ ! hello == world ]' => test_zci(
|
||||||
qr/.+ false if the strings hello and world are equal./,
|
re(qr/.+ false if the strings hello and world are equal./),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -78,9 +79,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'bash [[ /tmp/hello -nt /etc/test ]]' => test_zci (
|
'bash [[ /tmp/hello -nt /etc/test ]]' => test_zci (
|
||||||
qr#.+ true if /tmp/hello has been changed more recently than /etc/test or if /tmp/hello exists and /etc/test does not.#,
|
re(qr#.+ true if /tmp/hello has been changed more recently than /etc/test or if /tmp/hello exists and /etc/test does not.#),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -91,9 +92,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'bash [ -z hello ]' => test_zci(
|
'bash [ -z hello ]' => test_zci(
|
||||||
qr/.+ true if the length of 'hello' is zero./,
|
re(qr/.+ true if the length of 'hello' is zero./),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -104,9 +105,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'bash if [[ "abc" -lt "cba" ]]' => test_zci(
|
'bash if [[ "abc" -lt "cba" ]]' => test_zci(
|
||||||
qr/.+ true if "abc" is numerically less than "cba"./,
|
re(qr/.+ true if "abc" is numerically less than "cba"./),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "beam_me_up_scotty";
|
zci answer_type => "beam_me_up_scotty";
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
use utf8;
|
use utf8;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'binary_conversion';
|
zci answer_type => 'binary_conversion';
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
use utf8;
|
use utf8;
|
||||||
|
|
||||||
|
|
|
@ -3,53 +3,37 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "birth_stone";
|
zci answer_type => "birth_stone";
|
||||||
zci is_cached => 1;
|
zci is_cached => 1;
|
||||||
|
|
||||||
|
sub get_structured_answer {
|
||||||
|
my($month, $birthstone) = @_;
|
||||||
|
return $month . " birthstone: $birthstone",
|
||||||
|
structured_answer => {
|
||||||
|
data => {
|
||||||
|
title => $birthstone,
|
||||||
|
subtitle => 'Birthstone for '.$month
|
||||||
|
},
|
||||||
|
templates => {
|
||||||
|
group => "text",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub build_test {
|
||||||
|
test_zci(get_structured_answer(@_));
|
||||||
|
}
|
||||||
|
|
||||||
ddg_goodie_test(
|
ddg_goodie_test(
|
||||||
[qw( DDG::Goodie::BirthStone )],
|
[qw( DDG::Goodie::BirthStone )],
|
||||||
'april birth stone' => test_zci(
|
'april birth stone' => build_test('April', 'Diamond'),
|
||||||
'April birthstone: Diamond',
|
'birthstone JUNE' => build_test('June', 'Pearl'),
|
||||||
structured_answer => {
|
'DecEmber birthstone' => build_test('December', 'Turquoise'),
|
||||||
input => ['April'],
|
'birthstone april' => build_test('April', 'Diamond'),
|
||||||
operation => 'Birthstone',
|
'may birth stone' => build_test('May', 'Emerald')
|
||||||
result => 'Diamond'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'birthstone JUNE' => test_zci(
|
|
||||||
'June birthstone: Pearl',
|
|
||||||
structured_answer => {
|
|
||||||
input => ['June'],
|
|
||||||
operation => 'Birthstone',
|
|
||||||
result => 'Pearl'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'DecEmber birthstone' => test_zci(
|
|
||||||
'December birthstone: Turquoise',
|
|
||||||
structured_answer => {
|
|
||||||
input => ['December'],
|
|
||||||
operation => 'Birthstone',
|
|
||||||
result => 'Turquoise'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'birthstone april' => test_zci(
|
|
||||||
'April birthstone: Diamond',
|
|
||||||
structured_answer => {
|
|
||||||
input => ['April'],
|
|
||||||
operation => 'Birthstone',
|
|
||||||
result => 'Diamond'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'may birth stone' => test_zci(
|
|
||||||
'May birthstone: Emerald',
|
|
||||||
structured_answer => {
|
|
||||||
input => ['May'],
|
|
||||||
operation => 'Birthstone',
|
|
||||||
result => 'Emerald'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "bitsum";
|
zci answer_type => "bitsum";
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "blood_donor";
|
zci answer_type => "blood_donor";
|
||||||
|
|
84
t/Braille.t
84
t/Braille.t
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
use Convert::Braille;
|
use Convert::Braille;
|
||||||
use utf8;
|
use utf8;
|
||||||
|
@ -10,62 +11,37 @@ use utf8;
|
||||||
zci answer_type => 'braille';
|
zci answer_type => 'braille';
|
||||||
zci is_cached => 1;
|
zci is_cached => 1;
|
||||||
|
|
||||||
|
sub build_structured_answer {
|
||||||
|
my ($query, $response) = @_;
|
||||||
|
return $response,
|
||||||
|
structured_answer => {
|
||||||
|
data => {
|
||||||
|
title => $response,
|
||||||
|
subtitle => 'Braille translation: ' . $query,
|
||||||
|
},
|
||||||
|
templates => {
|
||||||
|
group => 'text',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
sub build_test { test_zci(build_structured_answer(@_)) }
|
||||||
|
|
||||||
ddg_goodie_test(
|
ddg_goodie_test(
|
||||||
[qw( DDG::Goodie::Braille)],
|
[qw( DDG::Goodie::Braille)],
|
||||||
'hello in braille' => test_zci(
|
# Ascii/Unicode -> Braille
|
||||||
"⠓⠑⠇⠇⠕ (Braille)",
|
'hello in braille' => build_test('hello', '⠓⠑⠇⠇⠕'),
|
||||||
structured_answer => {
|
'hello to braille' => build_test('hello', '⠓⠑⠇⠇⠕'),
|
||||||
input => ['hello'],
|
'translate to braille to braille' => build_test('translate to braille', '⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑'),
|
||||||
operation => 'Braille translation',
|
'braille: asdf k' => build_test('asdf k', '⠁⠎⠙⠋⠀⠅'),
|
||||||
result => '⠓⠑⠇⠇⠕'
|
# Braille -> Ascii/Unicode
|
||||||
}
|
'⠓⠑⠀⠇⠇⠕' => build_test('⠓⠑⠀⠇⠇⠕', 'he llo'),
|
||||||
),
|
'⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑' => build_test('⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑', 'translate to braille'),
|
||||||
'⠓⠑⠇⠇⠕' => test_zci(
|
'⠁⠎⠙⠋⠀⠅' => build_test('⠁⠎⠙⠋⠀⠅', 'asdf k'),
|
||||||
"hello (Braille)",
|
# Invalid Queries
|
||||||
structured_answer => {
|
'braille asdf k' => undef,
|
||||||
input => ['⠓⠑⠇⠇⠕'],
|
'how long to learn braille' => undef,
|
||||||
operation => 'Braille translation',
|
'braille to braille is good' => undef,
|
||||||
result => 'hello'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'translate to braille translate to braille' => test_zci(
|
|
||||||
"⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑ (Braille)",
|
|
||||||
structured_answer => {
|
|
||||||
input => ['translate to braille'],
|
|
||||||
operation => 'Braille translation',
|
|
||||||
result =>
|
|
||||||
'⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑' => test_zci(
|
|
||||||
"translate to braille (Braille)",
|
|
||||||
structured_answer => {
|
|
||||||
input => [
|
|
||||||
'⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑'
|
|
||||||
],
|
|
||||||
operation => 'Braille translation',
|
|
||||||
result => 'translate to braille'
|
|
||||||
}
|
|
||||||
|
|
||||||
),
|
|
||||||
'braille asdf k' => test_zci(
|
|
||||||
"⠁⠎⠙⠋⠀⠅ (Braille)",
|
|
||||||
structured_answer => {
|
|
||||||
input => ['asdf k'],
|
|
||||||
operation => 'Braille translation',
|
|
||||||
result => '⠁⠎⠙⠋⠀⠅'
|
|
||||||
}
|
|
||||||
|
|
||||||
),
|
|
||||||
'⠁⠎⠙⠋⠀⠅' => test_zci(
|
|
||||||
"asdf k (Braille)",
|
|
||||||
structured_answer => {
|
|
||||||
input => ['⠁⠎⠙⠋⠀⠅'],
|
|
||||||
operation => 'Braille translation',
|
|
||||||
result => 'asdf k'
|
|
||||||
}
|
|
||||||
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
|
@ -3,13 +3,14 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'caesar_cipher';
|
zci answer_type => 'caesar_cipher';
|
||||||
zci is_cached => 1;
|
zci is_cached => 1;
|
||||||
|
|
||||||
my $decode_response = {
|
my $decode_response = {
|
||||||
data => '-ANY-', # We only need to check it is the right template.
|
data => ignore(), # We only need to check it is the right template.
|
||||||
meta => {
|
meta => {
|
||||||
sourceUrl => 'https://en.wikipedia.org/wiki/Caesar_cipher',
|
sourceUrl => 'https://en.wikipedia.org/wiki/Caesar_cipher',
|
||||||
sourceName => 'Wikipedia',
|
sourceName => 'Wikipedia',
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'root';
|
zci answer_type => 'root';
|
||||||
|
|
183
t/Calculator.t
183
t/Calculator.t
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
use DDG::Goodie::Calculator; # For function subtests.
|
use DDG::Goodie::Calculator; # For function subtests.
|
||||||
use utf8;
|
use utf8;
|
||||||
|
@ -18,7 +19,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2 - 2'],
|
input => ['2 - 2'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>0</
|
result => re(qr/>0</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'solve 2+2' => test_zci(
|
'solve 2+2' => test_zci(
|
||||||
|
@ -27,7 +28,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2 + 2'],
|
input => ['2 + 2'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>4</
|
result => re(qr/>4</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'2^8' => test_zci(
|
'2^8' => test_zci(
|
||||||
|
@ -36,7 +37,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2 ^ 8'],
|
input => ['2 ^ 8'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>256</
|
result => re(qr/>256</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'2 *7' => test_zci(
|
'2 *7' => test_zci(
|
||||||
|
@ -45,7 +46,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2 * 7'],
|
input => ['2 * 7'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>14</
|
result => re(qr/>14</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'4 ∙ 5' => test_zci(
|
'4 ∙ 5' => test_zci(
|
||||||
|
@ -54,7 +55,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['4 * 5'],
|
input => ['4 * 5'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>20</
|
result => re(qr/>20</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'6 ⋅ 7' => test_zci(
|
'6 ⋅ 7' => test_zci(
|
||||||
|
@ -63,7 +64,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['6 * 7'],
|
input => ['6 * 7'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>42</
|
result => re(qr/>42</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'3 × dozen' => test_zci(
|
'3 × dozen' => test_zci(
|
||||||
|
@ -72,7 +73,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['3 * dozen'],
|
input => ['3 * dozen'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>36</
|
result => re(qr/>36</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'dozen ÷ 4' => test_zci(
|
'dozen ÷ 4' => test_zci(
|
||||||
|
@ -81,7 +82,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['dozen / 4'],
|
input => ['dozen / 4'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>3</
|
result => re(qr/>3</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'1 dozen * 2' => test_zci(
|
'1 dozen * 2' => test_zci(
|
||||||
|
@ -90,7 +91,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['1 dozen * 2'],
|
input => ['1 dozen * 2'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>24</
|
result => re(qr/>24</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'dozen + dozen' => test_zci(
|
'dozen + dozen' => test_zci(
|
||||||
|
@ -99,7 +100,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['dozen + dozen'],
|
input => ['dozen + dozen'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>24</
|
result => re(qr/>24</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'2divided by 4' => test_zci(
|
'2divided by 4' => test_zci(
|
||||||
|
@ -108,7 +109,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2 divided by 4'],
|
input => ['2 divided by 4'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>0.5</
|
result => re(qr/>0.5</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'2^2' => test_zci(
|
'2^2' => test_zci(
|
||||||
|
@ -117,7 +118,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2 ^ 2'],
|
input => ['2 ^ 2'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>4</
|
result => re(qr/>4</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'2^0.2' => test_zci(
|
'2^0.2' => test_zci(
|
||||||
|
@ -126,7 +127,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2 ^ 0.2'],
|
input => ['2 ^ 0.2'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1\.14869835499704</
|
result => re(qr/>1\.14869835499704</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'cos(0)' => test_zci(
|
'cos(0)' => test_zci(
|
||||||
|
@ -135,7 +136,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['cos(0)'],
|
input => ['cos(0)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1</
|
result => re(qr/>1</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'tan(1)' => test_zci(
|
'tan(1)' => test_zci(
|
||||||
|
@ -144,7 +145,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['tan(1)'],
|
input => ['tan(1)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1\.5574077246549</
|
result => re(qr/>1\.5574077246549</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'tanh(1)' => test_zci(
|
'tanh(1)' => test_zci(
|
||||||
|
@ -153,7 +154,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['tanh(1)'],
|
input => ['tanh(1)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>0\.761594155955765</
|
result => re(qr/>0\.761594155955765</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'cotan(1)' => test_zci(
|
'cotan(1)' => test_zci(
|
||||||
|
@ -162,7 +163,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['cotan(1)'],
|
input => ['cotan(1)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>0\.642092615934331</
|
result => re(qr/>0\.642092615934331</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'sin(1)' => test_zci(
|
'sin(1)' => test_zci(
|
||||||
|
@ -171,7 +172,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['sin(1)'],
|
input => ['sin(1)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>0\.841470984807897</
|
result => re(qr/>0\.841470984807897</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'csc(1)' => test_zci(
|
'csc(1)' => test_zci(
|
||||||
|
@ -180,7 +181,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['csc(1)'],
|
input => ['csc(1)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1\.18839510577812</
|
result => re(qr/>1\.18839510577812</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'sec(1)' => test_zci(
|
'sec(1)' => test_zci(
|
||||||
|
@ -189,7 +190,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['sec(1)'],
|
input => ['sec(1)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1\.85081571768093</
|
result => re(qr/>1\.85081571768093</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'log(3)' => test_zci(
|
'log(3)' => test_zci(
|
||||||
|
@ -198,7 +199,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['log(3)'],
|
input => ['log(3)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1\.09861228866811</
|
result => re(qr/>1\.09861228866811</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'ln(3)' => test_zci(
|
'ln(3)' => test_zci(
|
||||||
|
@ -207,7 +208,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['log(3)'],
|
input => ['log(3)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1\.09861228866811</
|
result => re(qr/>1\.09861228866811</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'log10(100.00)' => test_zci(
|
'log10(100.00)' => test_zci(
|
||||||
|
@ -216,7 +217,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['log10(100.00)'],
|
input => ['log10(100.00)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>2</
|
result => re(qr/>2</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'log_10(100.00)' => test_zci(
|
'log_10(100.00)' => test_zci(
|
||||||
|
@ -225,7 +226,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['log_10(100.00)'],
|
input => ['log_10(100.00)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>2</
|
result => re(qr/>2</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'log_2(16)' => test_zci(
|
'log_2(16)' => test_zci(
|
||||||
|
@ -234,7 +235,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['log_2(16)'],
|
input => ['log_2(16)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>4</
|
result => re(qr/>4</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'log_23(25)' => test_zci(
|
'log_23(25)' => test_zci(
|
||||||
|
@ -243,7 +244,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['log_23(25)'],
|
input => ['log_23(25)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1\.0265928122321</
|
result => re(qr/>1\.0265928122321</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'log23(25)' => test_zci(
|
'log23(25)' => test_zci(
|
||||||
|
@ -252,7 +253,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['log23(25)'],
|
input => ['log23(25)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1\.0265928122321</
|
result => re(qr/>1\.0265928122321</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'$3.43+$34.45' => test_zci(
|
'$3.43+$34.45' => test_zci(
|
||||||
|
@ -261,7 +262,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['$3.43 + $34.45'],
|
input => ['$3.43 + $34.45'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>\$37\.88</
|
result => re(qr/>\$37\.88</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'$3.45+$34.45' => test_zci(
|
'$3.45+$34.45' => test_zci(
|
||||||
|
@ -270,7 +271,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['$3.45 + $34.45'],
|
input => ['$3.45 + $34.45'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>\$37\.90</
|
result => re(qr/>\$37\.90</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'$3+$34' => test_zci(
|
'$3+$34' => test_zci(
|
||||||
|
@ -279,7 +280,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['$3 + $34'],
|
input => ['$3 + $34'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>\$37\.00</
|
result => re(qr/>\$37\.00</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'$3,4+$34,4' => test_zci(
|
'$3,4+$34,4' => test_zci(
|
||||||
|
@ -288,7 +289,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['$3,4 + $34,4'],
|
input => ['$3,4 + $34,4'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>\$37,80</
|
result => re(qr/>\$37,80</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'64*343' => test_zci(
|
'64*343' => test_zci(
|
||||||
|
@ -297,7 +298,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['64 * 343'],
|
input => ['64 * 343'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>21,952</
|
result => re(qr/>21,952</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'1E2 + 1' => test_zci(
|
'1E2 + 1' => test_zci(
|
||||||
|
@ -306,7 +307,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['(1 * 10 ^ 2) + 1'],
|
input => ['(1 * 10 ^ 2) + 1'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>101</
|
result => re(qr/>101</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'1 + 1E2' => test_zci(
|
'1 + 1E2' => test_zci(
|
||||||
|
@ -315,7 +316,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['1 + (1 * 10 ^ 2)'],
|
input => ['1 + (1 * 10 ^ 2)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>101</
|
result => re(qr/>101</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'2 * 3 + 1E2' => test_zci(
|
'2 * 3 + 1E2' => test_zci(
|
||||||
|
@ -324,7 +325,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2 * 3 + (1 * 10 ^ 2)'],
|
input => ['2 * 3 + (1 * 10 ^ 2)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>106</
|
result => re(qr/>106</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'1E2 + 2 * 3' => test_zci(
|
'1E2 + 2 * 3' => test_zci(
|
||||||
|
@ -333,7 +334,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['(1 * 10 ^ 2) + 2 * 3'],
|
input => ['(1 * 10 ^ 2) + 2 * 3'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>106</
|
result => re(qr/>106</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'1E2 / 2' => test_zci(
|
'1E2 / 2' => test_zci(
|
||||||
|
@ -342,7 +343,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['(1 * 10 ^ 2) / 2'],
|
input => ['(1 * 10 ^ 2) / 2'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>50</
|
result => re(qr/>50</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'2 / 1E2' => test_zci(
|
'2 / 1E2' => test_zci(
|
||||||
|
@ -351,7 +352,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2 / (1 * 10 ^ 2)'],
|
input => ['2 / (1 * 10 ^ 2)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>0\.02</
|
result => re(qr/>0\.02</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'424334+2253828' => test_zci(
|
'424334+2253828' => test_zci(
|
||||||
|
@ -360,7 +361,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['424334 + 2253828'],
|
input => ['424334 + 2253828'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>2,678,162</
|
result => re(qr/>2,678,162</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'4.243,34+22.538,28' => test_zci(
|
'4.243,34+22.538,28' => test_zci(
|
||||||
|
@ -369,7 +370,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['4.243,34 + 22.538,28'],
|
input => ['4.243,34 + 22.538,28'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>26\.781,62</
|
result => re(qr/>26\.781,62</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'sin(1,0) + 1,05' => test_zci(
|
'sin(1,0) + 1,05' => test_zci(
|
||||||
|
@ -378,7 +379,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['sin(1,0) + 1,05'],
|
input => ['sin(1,0) + 1,05'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1,8914709848079</
|
result => re(qr/>1,8914709848079</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'21 + 15 x 0 + 5' => test_zci(
|
'21 + 15 x 0 + 5' => test_zci(
|
||||||
|
@ -387,7 +388,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['21 + 15 * 0 + 5'],
|
input => ['21 + 15 * 0 + 5'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>26</
|
result => re(qr/>26</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'0.8158 - 0.8157' => test_zci(
|
'0.8158 - 0.8157' => test_zci(
|
||||||
|
@ -396,7 +397,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['0.8158 - 0.8157'],
|
input => ['0.8158 - 0.8157'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>0\.0001</
|
result => re(qr/>0\.0001</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'2,90 + 4,6' => test_zci(
|
'2,90 + 4,6' => test_zci(
|
||||||
|
@ -405,7 +406,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2,90 + 4,6'],
|
input => ['2,90 + 4,6'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>7,50</
|
result => re(qr/>7,50</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'2,90 + sec(4,6)' => test_zci(
|
'2,90 + sec(4,6)' => test_zci(
|
||||||
|
@ -414,7 +415,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2,90 + sec(4,6)'],
|
input => ['2,90 + sec(4,6)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>-6,01642861135959</
|
result => re(qr/>-6,01642861135959</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'100 - 96.54' => test_zci(
|
'100 - 96.54' => test_zci(
|
||||||
|
@ -423,7 +424,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['100 - 96.54'],
|
input => ['100 - 96.54'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>3\.46</
|
result => re(qr/>3\.46</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'1. + 1.' => test_zci(
|
'1. + 1.' => test_zci(
|
||||||
|
@ -432,7 +433,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['1. + 1.'],
|
input => ['1. + 1.'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>2</
|
result => re(qr/>2</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'1 + sin(pi)' => test_zci(
|
'1 + sin(pi)' => test_zci(
|
||||||
|
@ -441,7 +442,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['1 + sin(pi)'],
|
input => ['1 + sin(pi)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1</
|
result => re(qr/>1</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'1 - 1' => test_zci(
|
'1 - 1' => test_zci(
|
||||||
|
@ -450,7 +451,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['1 - 1'],
|
input => ['1 - 1'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>0</
|
result => re(qr/>0</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'sin(pi/2)' => test_zci(
|
'sin(pi/2)' => test_zci(
|
||||||
|
@ -459,7 +460,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['sin(pi / 2)'],
|
input => ['sin(pi / 2)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1</
|
result => re(qr/>1</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'sin(pi)' => test_zci(
|
'sin(pi)' => test_zci(
|
||||||
|
@ -468,7 +469,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['sin(pi)'],
|
input => ['sin(pi)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>0</
|
result => re(qr/>0</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'cos(2pi)' => test_zci(
|
'cos(2pi)' => test_zci(
|
||||||
|
@ -477,7 +478,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['cos(2 pi)'],
|
input => ['cos(2 pi)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1</
|
result => re(qr/>1</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'5 squared' => test_zci(
|
'5 squared' => test_zci(
|
||||||
|
@ -486,7 +487,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['5 ^ 2'],
|
input => ['5 ^ 2'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>25</
|
result => re(qr/>25</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'sqrt(4)' => test_zci(
|
'sqrt(4)' => test_zci(
|
||||||
|
@ -495,7 +496,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['sqrt(4)'],
|
input => ['sqrt(4)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>2</
|
result => re(qr/>2</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'1.0 + 5 squared' => test_zci(
|
'1.0 + 5 squared' => test_zci(
|
||||||
|
@ -504,7 +505,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['1.0 + 5 ^ 2'],
|
input => ['1.0 + 5 ^ 2'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>26</
|
result => re(qr/>26</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'3 squared + 4 squared' => test_zci(
|
'3 squared + 4 squared' => test_zci(
|
||||||
|
@ -513,7 +514,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['3 ^ 2 + 4 ^ 2'],
|
input => ['3 ^ 2 + 4 ^ 2'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>25</
|
result => re(qr/>25</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'2,2 squared' => test_zci(
|
'2,2 squared' => test_zci(
|
||||||
|
@ -522,7 +523,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2,2 ^ 2'],
|
input => ['2,2 ^ 2'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>4,84</
|
result => re(qr/>4,84</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'0.8^2 + 0.6^2' => test_zci(
|
'0.8^2 + 0.6^2' => test_zci(
|
||||||
|
@ -531,7 +532,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['0.8 ^ 2 + 0.6 ^ 2'],
|
input => ['0.8 ^ 2 + 0.6 ^ 2'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1</,
|
result => re(qr/>1</),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'2 squared ^ 3' => test_zci(
|
'2 squared ^ 3' => test_zci(
|
||||||
|
@ -540,7 +541,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2 ^ 2 ^ 3'],
|
input => ['2 ^ 2 ^ 3'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>256</
|
result => re(qr/>256</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'2 squared ^ 3.06' => test_zci(
|
'2 squared ^ 3.06' => test_zci(
|
||||||
|
@ -549,7 +550,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2 ^ 2 ^ 3.06'],
|
input => ['2 ^ 2 ^ 3.06'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>323\.972172143725</
|
result => re(qr/>323\.972172143725</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'2^3 squared' => test_zci(
|
'2^3 squared' => test_zci(
|
||||||
|
@ -558,7 +559,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2 ^ 3 ^ 2'],
|
input => ['2 ^ 3 ^ 2'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>512</
|
result => re(qr/>512</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'sqrt(2)' => test_zci(
|
'sqrt(2)' => test_zci(
|
||||||
|
@ -567,7 +568,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['sqrt(2)'],
|
input => ['sqrt(2)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1\.4142135623731</
|
result => re(qr/>1\.4142135623731</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'sqrt(3 pi / 4 + 1) + 1' => test_zci(
|
'sqrt(3 pi / 4 + 1) + 1' => test_zci(
|
||||||
|
@ -576,7 +577,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['sqrt(3 pi / 4 + 1) + 1'],
|
input => ['sqrt(3 pi / 4 + 1) + 1'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>2\.83199194599549</
|
result => re(qr/>2\.83199194599549</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'4 score + 7' => test_zci(
|
'4 score + 7' => test_zci(
|
||||||
|
@ -585,7 +586,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['4 score + 7'],
|
input => ['4 score + 7'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>87</
|
result => re(qr/>87</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'418.1 / 2' => test_zci(
|
'418.1 / 2' => test_zci(
|
||||||
|
@ -594,7 +595,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['418.1 / 2'],
|
input => ['418.1 / 2'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>209\.05</
|
result => re(qr/>209\.05</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'418.005 / 8' => test_zci(
|
'418.005 / 8' => test_zci(
|
||||||
|
@ -603,7 +604,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['418.005 / 8'],
|
input => ['418.005 / 8'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>52\.250625</
|
result => re(qr/>52\.250625</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'(pi^4+pi^5)^(1/6)' => test_zci(
|
'(pi^4+pi^5)^(1/6)' => test_zci(
|
||||||
|
@ -612,7 +613,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['(pi ^ 4 + pi ^ 5) ^ (1 / 6)'],
|
input => ['(pi ^ 4 + pi ^ 5) ^ (1 / 6)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>2\.71828180861191</
|
result => re(qr/>2\.71828180861191</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'(pi^4+pi^5)^(1/6)+1' => test_zci(
|
'(pi^4+pi^5)^(1/6)+1' => test_zci(
|
||||||
|
@ -621,7 +622,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['(pi ^ 4 + pi ^ 5) ^ (1 / 6) + 1'],
|
input => ['(pi ^ 4 + pi ^ 5) ^ (1 / 6) + 1'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>3\.71828180861191</
|
result => re(qr/>3\.71828180861191</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'5^4^(3-2)^1' => test_zci(
|
'5^4^(3-2)^1' => test_zci(
|
||||||
|
@ -630,7 +631,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['5 ^ 4 ^ (3 - 2) ^ 1'],
|
input => ['5 ^ 4 ^ (3 - 2) ^ 1'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>625</
|
result => re(qr/>625</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'(5-4)^(3-2)^1' => test_zci(
|
'(5-4)^(3-2)^1' => test_zci(
|
||||||
|
@ -639,7 +640,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['(5 - 4) ^ (3 - 2) ^ 1'],
|
input => ['(5 - 4) ^ (3 - 2) ^ 1'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1</
|
result => re(qr/>1</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'(5+4-3)^(2-1)' => test_zci(
|
'(5+4-3)^(2-1)' => test_zci(
|
||||||
|
@ -648,7 +649,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['(5 + 4 - 3) ^ (2 - 1)'],
|
input => ['(5 + 4 - 3) ^ (2 - 1)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>6</
|
result => re(qr/>6</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'5^((4-3)*(2+1))+6' => test_zci(
|
'5^((4-3)*(2+1))+6' => test_zci(
|
||||||
|
@ -657,7 +658,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['5 ^ ((4 - 3) * (2 + 1)) + 6'],
|
input => ['5 ^ ((4 - 3) * (2 + 1)) + 6'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>131</
|
result => re(qr/>131</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'20x07' => test_zci(
|
'20x07' => test_zci(
|
||||||
|
@ -666,7 +667,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['20 * 07'],
|
input => ['20 * 07'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>140</
|
result => re(qr/>140</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'83.166.167.160/33' => test_zci(
|
'83.166.167.160/33' => test_zci(
|
||||||
|
@ -675,7 +676,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['83.166.167.160 / 33'],
|
input => ['83.166.167.160 / 33'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>2\.520\.186\.883,63636</
|
result => re(qr/>2\.520\.186\.883,63636</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'123.123.123.123/255.255.255.256' => test_zci(
|
'123.123.123.123/255.255.255.256' => test_zci(
|
||||||
|
@ -684,7 +685,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['123.123.123.123 / 255.255.255.256'],
|
input => ['123.123.123.123 / 255.255.255.256'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>0,482352941174581</
|
result => re(qr/>0,482352941174581</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'4E5 +1 ' => test_zci(
|
'4E5 +1 ' => test_zci(
|
||||||
|
@ -693,7 +694,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['(4 * 10 ^ 5) + 1'],
|
input => ['(4 * 10 ^ 5) + 1'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>400,001</
|
result => re(qr/>400,001</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'4e5 +1 ' => test_zci(
|
'4e5 +1 ' => test_zci(
|
||||||
|
@ -702,7 +703,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['(4 * 10 ^ 5) + 1'],
|
input => ['(4 * 10 ^ 5) + 1'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>400,001</
|
result => re(qr/>400,001</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'3e-2* 9 ' => test_zci(
|
'3e-2* 9 ' => test_zci(
|
||||||
|
@ -711,7 +712,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['(3 * 10 ^- 2) * 9'],
|
input => ['(3 * 10 ^- 2) * 9'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>0.27</
|
result => re(qr/>0.27</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'7e-4 *8' => test_zci(
|
'7e-4 *8' => test_zci(
|
||||||
|
@ -720,7 +721,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['(7 * 10 ^- 4) * 8'],
|
input => ['(7 * 10 ^- 4) * 8'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>0.0056</
|
result => re(qr/>0.0056</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'6 * 2e-11' => test_zci(
|
'6 * 2e-11' => test_zci(
|
||||||
|
@ -729,7 +730,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['6 * (2 * 10 ^- 11)'],
|
input => ['6 * (2 * 10 ^- 11)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>1\.2 \* 10<sup>-10<\/sup></
|
result => re(qr/>1\.2 \* 10<sup>-10<\/sup></)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'7 + 7e-7' => test_zci(
|
'7 + 7e-7' => test_zci(
|
||||||
|
@ -738,7 +739,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['7 + (7 * 10 ^- 7)'],
|
input => ['7 + (7 * 10 ^- 7)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>7.0000007</
|
result => re(qr/>7.0000007</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'1 * 7 + e-7' => test_zci(
|
'1 * 7 + e-7' => test_zci(
|
||||||
|
@ -747,7 +748,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['1 * 7 + e - 7'],
|
input => ['1 * 7 + e - 7'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>2.71828182845905</
|
result => re(qr/>2.71828182845905</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'7 * e- 5' => test_zci(
|
'7 * e- 5' => test_zci(
|
||||||
|
@ -756,7 +757,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['7 * e - 5'],
|
input => ['7 * e - 5'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>14.0279727992134</
|
result => re(qr/>14.0279727992134</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'pi/1e9' => test_zci(
|
'pi/1e9' => test_zci(
|
||||||
|
@ -765,7 +766,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['pi / (1 * 10 ^ 9)'],
|
input => ['pi / (1 * 10 ^ 9)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>3\.14159265358979 \* 10<sup>-9<\/sup></
|
result => re(qr/>3\.14159265358979 \* 10<sup>-9<\/sup></)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'pi*1e9' => test_zci(
|
'pi*1e9' => test_zci(
|
||||||
|
@ -774,7 +775,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['pi * (1 * 10 ^ 9)'],
|
input => ['pi * (1 * 10 ^ 9)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>3,141,592,653\.58979</
|
result => re(qr/>3,141,592,653\.58979</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'1 234 + 5 432' => test_zci(
|
'1 234 + 5 432' => test_zci(
|
||||||
|
@ -783,7 +784,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['1234 + 5432'],
|
input => ['1234 + 5432'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/6,666/
|
result => re(qr/6,666/)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'1_234 + 5_432' => test_zci(
|
'1_234 + 5_432' => test_zci(
|
||||||
|
@ -792,7 +793,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['1234 + 5432'],
|
input => ['1234 + 5432'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/6,666/
|
result => re(qr/6,666/)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'(0.4e^(0))*cos(0)' => test_zci(
|
'(0.4e^(0))*cos(0)' => test_zci(
|
||||||
|
@ -801,7 +802,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['(0.4e ^ (0)) * cos(0)'],
|
input => ['(0.4e ^ (0)) * cos(0)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr'0.4'
|
result => re(qr'0.4')
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'2pi' => test_zci(
|
'2pi' => test_zci(
|
||||||
|
@ -810,7 +811,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['2 pi'],
|
input => ['2 pi'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr"6.28318530717958"
|
result => re(qr"6.28318530717958")
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'fact(3)' => test_zci(
|
'fact(3)' => test_zci(
|
||||||
|
@ -819,7 +820,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['fact(3)'],
|
input => ['fact(3)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>6</
|
result => re(qr/>6</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'factorial(3)' => test_zci(
|
'factorial(3)' => test_zci(
|
||||||
|
@ -828,7 +829,7 @@ ddg_goodie_test(
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['fact(3)'],
|
input => ['fact(3)'],
|
||||||
operation => 'Calculate',
|
operation => 'Calculate',
|
||||||
result => qr/>6</
|
result => re(qr/>6</)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'123.123.123.123/255.255.255.255' => undef,
|
'123.123.123.123/255.255.255.255' => undef,
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'calendar_conversion';
|
zci answer_type => 'calendar_conversion';
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
use Test::MockTime qw( :all );
|
use Test::MockTime qw( :all );
|
||||||
|
|
||||||
|
@ -14,9 +15,9 @@ ddg_goodie_test(
|
||||||
DDG::Goodie::CalendarToday
|
DDG::Goodie::CalendarToday
|
||||||
)],
|
)],
|
||||||
'calendar' => test_zci(
|
'calendar' => test_zci(
|
||||||
qr/\nS M T W T F S[ ]+[A-Za-z]+ [0-9]{4}\n.+/,
|
re(qr/\nS M T W T F S[ ]+[A-Za-z]+ [0-9]{4}\n.+/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -27,9 +28,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'calendar november' => test_zci(
|
'calendar november' => test_zci(
|
||||||
qr/\nS M T W T F S November [0-9]{4}\n.+/,
|
re(qr/\nS M T W T F S November [0-9]{4}\n.+/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -40,9 +41,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'calendar november 12th' => test_zci(
|
'calendar november 12th' => test_zci(
|
||||||
qr/\nS M T W T F S November [0-9]{4}\n.+/,
|
re(qr/\nS M T W T F S November [0-9]{4}\n.+/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -53,9 +54,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'calendar last november' => test_zci(
|
'calendar last november' => test_zci(
|
||||||
qr/\nS M T W T F S November [0-9]{4}\n.+/,
|
re(qr/\nS M T W T F S November [0-9]{4}\n.+/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -66,9 +67,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'calendar next november' => test_zci(
|
'calendar next november' => test_zci(
|
||||||
qr/\nS M T W T F S November [0-9]{4}\n.+/,
|
re(qr/\nS M T W T F S November [0-9]{4}\n.+/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -217,7 +218,7 @@ S M T W T F S November 2009
|
||||||
29 30
|
29 30
|
||||||
",
|
",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -236,7 +237,7 @@ S M T W T F S November 2015
|
||||||
|29| 30
|
|29| 30
|
||||||
",
|
",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -255,7 +256,7 @@ S M T W T F S November 2015
|
||||||
|29| 30
|
|29| 30
|
||||||
",
|
",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -275,7 +276,7 @@ S M T W T F S November 1980
|
||||||
30
|
30
|
||||||
",
|
",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -294,7 +295,7 @@ S M T W T F S November 2009
|
||||||
29 30
|
29 30
|
||||||
",
|
",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -305,9 +306,9 @@ S M T W T F S November 2009
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'next november on a calendar' => test_zci(
|
'next november on a calendar' => test_zci(
|
||||||
qr/\nS M T W T F S November [0-9]{4}\n.+/,
|
re(qr/\nS M T W T F S November [0-9]{4}\n.+/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -318,9 +319,9 @@ S M T W T F S November 2009
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'calendar for november' => test_zci(
|
'calendar for november' => test_zci(
|
||||||
qr/\nS M T W T F S November [0-9]{4}\n.+/,
|
re(qr/\nS M T W T F S November [0-9]{4}\n.+/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -339,7 +340,7 @@ S M T W T F S November 2009
|
||||||
29 30
|
29 30
|
||||||
",
|
",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -351,9 +352,9 @@ S M T W T F S November 2009
|
||||||
),
|
),
|
||||||
'22/8/2003 to the hijri calendar' => undef,
|
'22/8/2003 to the hijri calendar' => undef,
|
||||||
"today's calendar" => test_zci(
|
"today's calendar" => test_zci(
|
||||||
qr/\nS M T W T F S [A-Z][a-z]+ [0-9]{4}\n.+/,
|
re(qr/\nS M T W T F S [A-Z][a-z]+ [0-9]{4}\n.+/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -364,9 +365,9 @@ S M T W T F S November 2009
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"november's calendar" => test_zci(
|
"november's calendar" => test_zci(
|
||||||
qr/\nS M T W T F S November [0-9]{4}\n.+/,
|
re(qr/\nS M T W T F S November [0-9]{4}\n.+/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -379,14 +380,14 @@ S M T W T F S November 2009
|
||||||
);
|
);
|
||||||
|
|
||||||
# Special focus on relative dates, examining the "today" circle
|
# Special focus on relative dates, examining the "today" circle
|
||||||
my $test_location_tz = qr/\(EDT, UTC-4\)/;
|
my $test_location_tz = re(qr/\(EDT, UTC-4\)/);
|
||||||
set_fixed_time("2014-06-11T09:45:56");
|
set_fixed_time("2014-06-11T09:45:56");
|
||||||
ddg_goodie_test(
|
ddg_goodie_test(
|
||||||
[qw(
|
[qw(
|
||||||
DDG::Goodie::CalendarToday
|
DDG::Goodie::CalendarToday
|
||||||
)],
|
)],
|
||||||
"calendar yesterday" => test_zci(
|
"calendar yesterday" => test_zci(
|
||||||
qr/June 2014.*\|10\|/s,
|
re(qr/June 2014.*\|10\|/s),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => {
|
data => {
|
||||||
month_year => "June 2014",
|
month_year => "June 2014",
|
||||||
|
@ -445,7 +446,7 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"calendar today" => test_zci(
|
"calendar today" => test_zci(
|
||||||
qr/June 2014.*\|11\|/s,
|
re(qr/June 2014.*\|11\|/s),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => {
|
data => {
|
||||||
month_year => "June 2014",
|
month_year => "June 2014",
|
||||||
|
@ -504,7 +505,7 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"calendar tomorrow" => test_zci(
|
"calendar tomorrow" => test_zci(
|
||||||
qr/June 2014.*\|12\|/s,
|
re(qr/June 2014.*\|12\|/s),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => {
|
data => {
|
||||||
month_year => "June 2014",
|
month_year => "June 2014",
|
||||||
|
@ -563,7 +564,7 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"calendar 20 days ago" => test_zci(
|
"calendar 20 days ago" => test_zci(
|
||||||
qr/May 2014.*\|22\|/s,
|
re(qr/May 2014.*\|22\|/s),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => {
|
data => {
|
||||||
month_year => "May 2014",
|
month_year => "May 2014",
|
||||||
|
@ -627,7 +628,7 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"calendar in 20 days" => test_zci(
|
"calendar in 20 days" => test_zci(
|
||||||
qr/July 2014.*\| 1\|/s,
|
re(qr/July 2014.*\| 1\|/s),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => {
|
data => {
|
||||||
month_year => "July 2014",
|
month_year => "July 2014",
|
||||||
|
@ -689,7 +690,7 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"calendar last week" => test_zci(
|
"calendar last week" => test_zci(
|
||||||
qr/June 2014.*\| 4\|/s,
|
re(qr/June 2014.*\| 4\|/s),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => {
|
data => {
|
||||||
month_year => "June 2014",
|
month_year => "June 2014",
|
||||||
|
@ -748,7 +749,7 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"calendar next week" =>
|
"calendar next week" =>
|
||||||
test_zci(qr/June 2014.*\|18\|/s,
|
test_zci(re(qr/June 2014.*\|18\|/s),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => {
|
data => {
|
||||||
month_year => "June 2014",
|
month_year => "June 2014",
|
||||||
|
@ -807,7 +808,7 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"calendar last year" =>
|
"calendar last year" =>
|
||||||
test_zci(qr/June 2013.*\|11\|/s,
|
test_zci(re(qr/June 2013.*\|11\|/s),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => {
|
data => {
|
||||||
month_year => "June 2013",
|
month_year => "June 2013",
|
||||||
|
@ -874,7 +875,7 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"calendar next year" =>
|
"calendar next year" =>
|
||||||
test_zci(qr/June 2015.*\|11\|/s,
|
test_zci(re(qr/June 2015.*\|11\|/s),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => {
|
data => {
|
||||||
month_year => "June 2015",
|
month_year => "June 2015",
|
||||||
|
@ -937,4 +938,3 @@ ddg_goodie_test(
|
||||||
restore_time();
|
restore_time();
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "calling_codes";
|
zci answer_type => "calling_codes";
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "camel_case";
|
zci answer_type => "camel_case";
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'chars';
|
zci answer_type => 'chars';
|
||||||
|
@ -103,4 +104,3 @@ ddg_goodie_test(
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ use IO::All;
|
||||||
use List::Util qw(first none all any max);
|
use List::Util qw(first none all any max);
|
||||||
use YAML::XS qw(LoadFile);
|
use YAML::XS qw(LoadFile);
|
||||||
use File::Find::Rule;
|
use File::Find::Rule;
|
||||||
|
use DDG::Meta::Data;
|
||||||
|
|
||||||
my $json_dir = "share/goodie/cheat_sheets/json";
|
my $json_dir = "share/goodie/cheat_sheets/json";
|
||||||
|
|
||||||
|
@ -40,6 +41,7 @@ sub id_to_file_name {
|
||||||
sub check_aliases_for_triggers {
|
sub check_aliases_for_triggers {
|
||||||
my ($aliases, $trigger_types) = @_;
|
my ($aliases, $trigger_types) = @_;
|
||||||
my @aliases = @$aliases;
|
my @aliases = @$aliases;
|
||||||
|
my %bad_aliases;
|
||||||
while (my ($trigger_type, $triggers) = each %{$trigger_types}) {
|
while (my ($trigger_type, $triggers) = each %{$trigger_types}) {
|
||||||
my @triggers = @$triggers;
|
my @triggers = @$triggers;
|
||||||
foreach my $alias (@aliases) {
|
foreach my $alias (@aliases) {
|
||||||
|
@ -50,11 +52,32 @@ sub check_aliases_for_triggers {
|
||||||
|| ($trigger_type =~ /end$/
|
|| ($trigger_type =~ /end$/
|
||||||
&& ($trigger = first { $alias =~ /$_$/ } @triggers))
|
&& ($trigger = first { $alias =~ /$_$/ } @triggers))
|
||||||
) {
|
) {
|
||||||
return ($alias, $trigger);
|
$bad_aliases{$alias} = $trigger;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return %bad_aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_aliases_for_ignore {
|
||||||
|
my ($aliases, $ignore) = @_;
|
||||||
|
my @ignore = @$ignore;
|
||||||
|
my %bad_aliases;
|
||||||
|
foreach my $alias (@$aliases) {
|
||||||
|
if (my $contained_ignore = first { $alias =~ $_ } @ignore) {
|
||||||
|
$bad_aliases{$alias} = $ignore;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return %bad_aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub verify_meta {
|
||||||
|
my $json = shift;
|
||||||
|
my @tests;
|
||||||
|
my $id = $json->{id};
|
||||||
|
my $meta = DDG::Meta::Data->get_ia(id => $id);
|
||||||
|
push(@tests, {msg => "No Instant Answer page found with ID '$id'", critical => 1, pass => defined $meta});
|
||||||
|
return @tests;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @fnames = @ARGV ? map { "$_.json" } @ARGV : ("*.json");
|
my @fnames = @ARGV ? map { "$_.json" } @ARGV : ("*.json");
|
||||||
|
@ -62,8 +85,16 @@ my @test_paths = File::Find::Rule->file()->name(@fnames)->in($json_dir);
|
||||||
|
|
||||||
my $max_name_len = max map { $_ =~ /.+\/(.+)\.json$/; length $1 } @test_paths;
|
my $max_name_len = max map { $_ =~ /.+\/(.+)\.json$/; length $1 } @test_paths;
|
||||||
|
|
||||||
|
sub cmp_base {
|
||||||
|
$a =~ qr{/([^/]+)$};
|
||||||
|
my $base1 = $1;
|
||||||
|
$b =~ qr{/([^/]+)$};
|
||||||
|
my $base2 = $1;
|
||||||
|
return $base1 cmp $base2;
|
||||||
|
}
|
||||||
|
|
||||||
# Iterate over all Cheat Sheet JSON files...
|
# Iterate over all Cheat Sheet JSON files...
|
||||||
foreach my $path (@test_paths) {
|
foreach my $path (sort { cmp_base } @test_paths) {
|
||||||
|
|
||||||
my ($file_name) = $path =~ /$json_dir\/(.+)/;
|
my ($file_name) = $path =~ /$json_dir\/(.+)/;
|
||||||
my ($name) = $path =~ /.+\/(.+)\.json$/;
|
my ($name) = $path =~ /.+\/(.+)\.json$/;
|
||||||
|
@ -136,13 +167,22 @@ foreach my $path (@test_paths) {
|
||||||
# Make sure aliases don't contain any category triggers.
|
# Make sure aliases don't contain any category triggers.
|
||||||
while (my ($category, $trigger_types) = each %{$triggers_yaml->{categories}}) {
|
while (my ($category, $trigger_types) = each %{$triggers_yaml->{categories}}) {
|
||||||
my $critical = $categories{$category};
|
my $critical = $categories{$category};
|
||||||
if (my ($alias, $trigger) = check_aliases_for_triggers(\@aliases, $trigger_types)) {
|
my %bad_aliases = check_aliases_for_triggers(\@aliases, $trigger_types);
|
||||||
|
while (my ($alias, $trigger) = each %bad_aliases) {
|
||||||
push(@tests, {msg => "Alias ($alias) contains a trigger ($trigger) defined in the '$category' category", critical => $critical});
|
push(@tests, {msg => "Alias ($alias) contains a trigger ($trigger) defined in the '$category' category", critical => $critical});
|
||||||
}
|
}
|
||||||
|
# Critical if they have aliases that contain ignored phrases.
|
||||||
|
if ($critical and my $ignored = $trigger_types->{ignore}) {
|
||||||
|
my %bad_aliases = check_aliases_for_ignore(\@aliases, $ignored);
|
||||||
|
while (my ($alias, $ignore) = each %bad_aliases) {
|
||||||
|
push (@tests, {msg => "Alias ($alias) contains a phrase ($ignore) that is ignored and may be omitted", critical => 1});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
# Make sure aliases don't contain any custom triggers for the cheat sheet.
|
# Make sure aliases don't contain any custom triggers for the cheat sheet.
|
||||||
if (my $custom = $triggers_yaml->{custom_triggers}{$cheat_id}) {
|
if (my $custom = $triggers_yaml->{custom_triggers}{$cheat_id}) {
|
||||||
if (my ($alias, $trigger) = check_aliases_for_triggers(\@aliases, $custom)) {
|
my %bad_aliases = check_aliases_for_triggers(\@aliases, $custom);
|
||||||
|
while (my ($alias, $trigger) = each %bad_aliases) {
|
||||||
push(@tests, {msg => "Alias ($alias) contains a custom trigger ($trigger)", critical => 1});
|
push(@tests, {msg => "Alias ($alias) contains a custom trigger ($trigger)", critical => 1});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,6 +264,8 @@ foreach my $path (@test_paths) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
push @tests, verify_meta($json);
|
||||||
|
|
||||||
PRINT_RESULTS:
|
PRINT_RESULTS:
|
||||||
|
|
||||||
my $result = print_results($name, \@tests);
|
my $result = print_results($name, \@tests);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'chess960_position';
|
zci answer_type => 'chess960_position';
|
||||||
|
@ -15,7 +16,7 @@ ddg_goodie_test(
|
||||||
'chess960 random' => test_zci(
|
'chess960 random' => test_zci(
|
||||||
'Chess 960',
|
'Chess 960',
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => "text",
|
group => "text",
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -28,4 +29,3 @@ ddg_goodie_test(
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::MockTime qw( :all );
|
use Test::MockTime qw( :all );
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
use utf8;
|
use utf8;
|
||||||
|
|
||||||
|
@ -132,4 +133,3 @@ ddg_goodie_test(
|
||||||
restore_time();
|
restore_time();
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "coffee_to_water_ratio";
|
zci answer_type => "coffee_to_water_ratio";
|
||||||
|
|
41
t/Coin.t
41
t/Coin.t
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'coin';
|
zci answer_type => 'coin';
|
||||||
|
@ -11,83 +12,83 @@ zci is_cached => 0;
|
||||||
ddg_goodie_test(
|
ddg_goodie_test(
|
||||||
[qw( DDG::Goodie::Coin )],
|
[qw( DDG::Goodie::Coin )],
|
||||||
'flip a coin' => test_zci(
|
'flip a coin' => test_zci(
|
||||||
qr/(heads|tails) \(random\)/,
|
re(qr/(heads|tails) \(random\)/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [1],
|
input => [1],
|
||||||
operation => 'Flip coin',
|
operation => 'Flip coin',
|
||||||
result => qr/^(heads|tails)$/
|
result => re(qr/^(heads|tails)$/)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'flip coin' => test_zci(
|
'flip coin' => test_zci(
|
||||||
qr/(heads|tails) \(random\)/,
|
re(qr/(heads|tails) \(random\)/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [1],
|
input => [1],
|
||||||
operation => 'Flip coin',
|
operation => 'Flip coin',
|
||||||
result => qr/^(heads|tails)$/
|
result => re(qr/^(heads|tails)$/)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'flip 1 coin' => test_zci(
|
'flip 1 coin' => test_zci(
|
||||||
qr/(heads|tails) \(random\)/,
|
re(qr/(heads|tails) \(random\)/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [1],
|
input => [1],
|
||||||
operation => 'Flip coin',
|
operation => 'Flip coin',
|
||||||
result => qr/^(heads|tails)$/
|
result => re(qr/^(heads|tails)$/)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'flip 2 coins' => test_zci(
|
'flip 2 coins' => test_zci(
|
||||||
qr/(heads|tails), (heads|tails) \(random\)/,
|
re(qr/(heads|tails), (heads|tails) \(random\)/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [2],
|
input => [2],
|
||||||
operation => 'Flip coin',
|
operation => 'Flip coin',
|
||||||
result => qr/(heads|tails), /
|
result => re(qr/(heads|tails), /)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'toss a coin' => test_zci(
|
'toss a coin' => test_zci(
|
||||||
qr/(heads|tails) \(random\)/,
|
re(qr/(heads|tails) \(random\)/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [1],
|
input => [1],
|
||||||
operation => 'Flip coin',
|
operation => 'Flip coin',
|
||||||
result => qr/^(heads|tails)$/
|
result => re(qr/^(heads|tails)$/)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'toss 1 coin' => test_zci(
|
'toss 1 coin' => test_zci(
|
||||||
qr/(heads|tails) \(random\)/,
|
re(qr/(heads|tails) \(random\)/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [1],
|
input => [1],
|
||||||
operation => 'Flip coin',
|
operation => 'Flip coin',
|
||||||
result => qr/^(heads|tails)$/
|
result => re(qr/^(heads|tails)$/)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'toss 2 coins' => test_zci(
|
'toss 2 coins' => test_zci(
|
||||||
qr/(heads|tails), (heads|tails) \(random\)/,
|
re(qr/(heads|tails), (heads|tails) \(random\)/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [2],
|
input => [2],
|
||||||
operation => 'Flip coin',
|
operation => 'Flip coin',
|
||||||
result => qr/(heads|tails), /
|
result => re(qr/(heads|tails), /)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'heads or tails' => test_zci(
|
'heads or tails' => test_zci(
|
||||||
qr/(heads|tails) \(random\)/,
|
re(qr/(heads|tails) \(random\)/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [1],
|
input => [1],
|
||||||
operation => 'Flip coin',
|
operation => 'Flip coin',
|
||||||
result => qr/^(heads|tails)$/
|
result => re(qr/^(heads|tails)$/)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'heads or tails?' => test_zci(
|
'heads or tails?' => test_zci(
|
||||||
qr/(heads|tails) \(random\)/,
|
re(qr/(heads|tails) \(random\)/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [1],
|
input => [1],
|
||||||
operation => 'Flip coin',
|
operation => 'Flip coin',
|
||||||
result => qr/^(heads|tails)$/
|
result => re(qr/^(heads|tails)$/)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'flip 4 coins' => test_zci(
|
'flip 4 coins' => test_zci(
|
||||||
qr/((heads|tails),? ){4}\(random\)/,
|
re(qr/((heads|tails),? ){4}\(random\)/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => [4],
|
input => [4],
|
||||||
operation => 'Flip coin',
|
operation => 'Flip coin',
|
||||||
result => qr/(heads|tails),? /
|
result => re(qr/(heads|tails),? /)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'color_code';
|
zci answer_type => 'color_code';
|
||||||
|
@ -13,7 +14,7 @@ my $green_answer = 'Hex: #00FF00 ~ RGBA(0, 255, 0, 1) ~ RGB(0%, 100%, 0%) ~ HSL(
|
||||||
|
|
||||||
my %basic_answer = (
|
my %basic_answer = (
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
item => 0,
|
item => 0,
|
||||||
|
@ -110,4 +111,4 @@ ddg_goodie_test(
|
||||||
'wield color' => undef,
|
'wield color' => undef,
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
|
@ -3,55 +3,35 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "combination";
|
zci answer_type => "combination";
|
||||||
zci is_cached => 1;
|
zci is_cached => 1;
|
||||||
|
|
||||||
|
sub build_test
|
||||||
|
{
|
||||||
|
my ($answer, $question) = @_;
|
||||||
|
return test_zci(
|
||||||
|
$answer, structured_answer => {
|
||||||
|
data => {
|
||||||
|
title => $answer,
|
||||||
|
subtitle => $question
|
||||||
|
},
|
||||||
|
templates => {
|
||||||
|
group => 'text'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
ddg_goodie_test(
|
ddg_goodie_test(
|
||||||
[qw( DDG::Goodie::Combination )],
|
[qw( DDG::Goodie::Combination )],
|
||||||
'10 choose 3' => test_zci('120',
|
'10 choose 3' => build_test('120', '10 choose 3'),
|
||||||
structured_answer => {
|
'10 nCr 3' => build_test('120', '10 choose 3'),
|
||||||
input => ['10 choose 3'],
|
'25 permute 16' => build_test('4.27447366714368 * 10^19', '25 permute 16'),
|
||||||
operation => 'Calculate',
|
'16 permutation 3' => build_test('3,360', '16 permute 3'),
|
||||||
result => '120',
|
'15 permutation 0' => build_test('1', '15 permute 0'),
|
||||||
}
|
'1,000 choose 2' => build_test('499,500', '1,000 choose 2'),
|
||||||
),
|
|
||||||
'10 nCr 3' => test_zci('120',
|
|
||||||
structured_answer => {
|
|
||||||
input => ['10 choose 3'],
|
|
||||||
operation => 'Calculate',
|
|
||||||
result => '120',
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'25 permute 16' => test_zci('4.27447366714368 * 10^19',
|
|
||||||
structured_answer => {
|
|
||||||
input => ['25 permute 16'],
|
|
||||||
operation => 'Calculate',
|
|
||||||
result => '4.27447366714368 * 10^19'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'16 permutation 3' => test_zci('3,360',
|
|
||||||
structured_answer => {
|
|
||||||
input => ['16 permute 3'],
|
|
||||||
operation => 'Calculate',
|
|
||||||
result => '3,360'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'15 permutation 0' => test_zci('1',
|
|
||||||
structured_answer => {
|
|
||||||
input => ['15 permute 0'],
|
|
||||||
operation => 'Calculate',
|
|
||||||
result => '1'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'1,000 choose 2' => test_zci('499,500',
|
|
||||||
structured_answer => {
|
|
||||||
input => ['1,000 choose 2'],
|
|
||||||
operation => 'Calculate',
|
|
||||||
result => '499,500'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'0 choose 100' => undef,
|
'0 choose 100' => undef,
|
||||||
'10 choose 100' => undef,
|
'10 choose 100' => undef,
|
||||||
'10.5 choose 1' => undef,
|
'10.5 choose 1' => undef,
|
||||||
|
|
|
@ -4,6 +4,7 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use utf8;
|
use utf8;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "constants";
|
zci answer_type => "constants";
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
use utf8;
|
use utf8;
|
||||||
zci answer_type => 'conversions';
|
zci answer_type => 'conversions';
|
||||||
|
@ -359,6 +360,18 @@ ddg_goodie_test(
|
||||||
physical_quantity => 'pressure'
|
physical_quantity => 'pressure'
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
'0.01933677566613741911668448550544 psi in mmHg' => test_zci(
|
||||||
|
'0.01933677566613741911668448550544 pounds per square inch = 1 mmHg',
|
||||||
|
structured_answer => make_answer({
|
||||||
|
markup_input => '0.01933677566613741911668448550544',
|
||||||
|
raw_input => '0.01933677566613741911668448550544',
|
||||||
|
from_unit => 'pounds per square inch',
|
||||||
|
styled_output => '1',
|
||||||
|
raw_answer => '1',
|
||||||
|
to_unit => 'mmHg',
|
||||||
|
physical_quantity => 'pressure'
|
||||||
|
})
|
||||||
|
),
|
||||||
'2 thou to mm' => test_zci(
|
'2 thou to mm' => test_zci(
|
||||||
'2 thousandths of an inch = 0.051 millimeters',
|
'2 thousandths of an inch = 0.051 millimeters',
|
||||||
structured_answer => make_answer({
|
structured_answer => make_answer({
|
||||||
|
@ -599,6 +612,18 @@ ddg_goodie_test(
|
||||||
physical_quantity => 'energy'
|
physical_quantity => 'energy'
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
'1000000 kcal in tons of tnt' => test_zci(
|
||||||
|
'1,000,000 large calories = 1 ton of TNT',
|
||||||
|
structured_answer => make_answer({
|
||||||
|
markup_input => '1,000,000',
|
||||||
|
raw_input => '1000000',
|
||||||
|
from_unit => 'large calories',
|
||||||
|
styled_output => '1',
|
||||||
|
raw_answer => '1',
|
||||||
|
to_unit => 'ton of TNT',
|
||||||
|
physical_quantity => 'energy'
|
||||||
|
})
|
||||||
|
),
|
||||||
'90 ps in watts' => test_zci(
|
'90 ps in watts' => test_zci(
|
||||||
'90 metric horsepower = 66,194.888 watts',
|
'90 metric horsepower = 66,194.888 watts',
|
||||||
structured_answer => make_answer({
|
structured_answer => make_answer({
|
||||||
|
@ -984,14 +1009,14 @@ ddg_goodie_test(
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
'ml in gallons' => test_zci(
|
'ml in gallons' => test_zci(
|
||||||
'1 millilitre = 0.000264 us gallons',
|
'1 us gallon = 3,785.412 millilitres',,
|
||||||
structured_answer => make_answer({
|
structured_answer => make_answer({
|
||||||
markup_input => '1',
|
markup_input => '1',
|
||||||
raw_input => '1',
|
raw_input => '1',
|
||||||
from_unit => 'millilitre',
|
from_unit => 'us gallon',
|
||||||
styled_output => '0.000264',
|
styled_output => '3,785.412',
|
||||||
raw_answer => '0.000264',
|
raw_answer => '3785.412',
|
||||||
to_unit => 'us gallons',
|
to_unit => 'millilitres',
|
||||||
physical_quantity => 'volume'
|
physical_quantity => 'volume'
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
@ -1431,14 +1456,14 @@ ddg_goodie_test(
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
'how many cm in metres?' => test_zci(
|
'how many cm in metres?' => test_zci(
|
||||||
'1 centimeter = 0.010 meters',
|
'1 meter = 100 centimeters',
|
||||||
structured_answer => make_answer({
|
structured_answer => make_answer({
|
||||||
markup_input => '1',
|
markup_input => '1',
|
||||||
raw_input => '1',
|
raw_input => '1',
|
||||||
from_unit => 'centimeter',
|
from_unit => 'meter',
|
||||||
styled_output => '0.010',
|
styled_output => '100',
|
||||||
raw_answer => '0.010',
|
raw_answer => '100',
|
||||||
to_unit => 'meters',
|
to_unit => 'centimeters',
|
||||||
physical_quantity => 'length'
|
physical_quantity => 'length'
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
@ -2755,7 +2780,18 @@ ddg_goodie_test(
|
||||||
physical_quantity => 'speed'
|
physical_quantity => 'speed'
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
'acre square feet' => test_zci(
|
||||||
|
'1 acre = 43,560.173 square feet',
|
||||||
|
structured_answer => make_answer({
|
||||||
|
markup_input => '1',
|
||||||
|
raw_input => '1',
|
||||||
|
from_unit => 'acre',
|
||||||
|
styled_output => '43,560.173',
|
||||||
|
raw_answer => '43560.173',
|
||||||
|
to_unit => 'square feet',
|
||||||
|
physical_quantity => 'area'
|
||||||
|
})
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
# Intentionally untriggered
|
# Intentionally untriggered
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
use utf8;
|
use utf8;
|
||||||
|
|
||||||
|
@ -102,14 +103,14 @@ ddg_goodie_test(
|
||||||
'convert 39.75 degrees to farenheit' => undef,
|
'convert 39.75 degrees to farenheit' => undef,
|
||||||
|
|
||||||
#Check for to-format name
|
#Check for to-format name
|
||||||
'16.5° S, 68.15° W dms' => test_zci(qr/./,
|
'16.5° S, 68.15° W dms' => test_zci(re(qr/./),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ["16.5° S", "68.15° W"],
|
input => ["16.5° S", "68.15° W"],
|
||||||
operation => "Convert to DMS",
|
operation => "Convert to DMS",
|
||||||
result => "16° 30′ S, 68° 9′ W",
|
result => "16° 30′ S, 68° 9′ W",
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'16° 30′ S, 68° 9′ W decimal' => test_zci(qr/./,
|
'16° 30′ S, 68° 9′ W decimal' => test_zci(re(qr/./),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ["16° 30′ S", "68° 9′ W"],
|
input => ["16° 30′ S", "68° 9′ W"],
|
||||||
operation => "Convert to decimal",
|
operation => "Convert to decimal",
|
||||||
|
@ -119,4 +120,3 @@ ddg_goodie_test(
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
||||||
|
|
138
t/CountryCodes.t
138
t/CountryCodes.t
|
@ -4,121 +4,45 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "country_codes";
|
zci answer_type => "country_codes";
|
||||||
zci is_cached => 1;
|
zci is_cached => 1;
|
||||||
|
|
||||||
my $text = '</div><div class="zci__subheader">ISO 3166 Country code for';
|
sub build_structured_answer{
|
||||||
|
my ($country, $response) = @_;
|
||||||
|
return 'ISO 3166: '. ucfirst $country .' - '. $response,
|
||||||
|
structured_answer => {
|
||||||
|
data => {
|
||||||
|
title => $response,
|
||||||
|
subtitle => "ISO 3166 Country code: " . ucfirst ($country),
|
||||||
|
},
|
||||||
|
templates => {
|
||||||
|
group => "text",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
sub build_test { test_zci(build_structured_answer(@_)) }
|
||||||
|
|
||||||
ddg_goodie_test(
|
ddg_goodie_test(
|
||||||
[ 'DDG::Goodie::CountryCodes' ],
|
[ 'DDG::Goodie::CountryCodes' ],
|
||||||
"country code Japan" => test_zci(
|
"country code Japan" => build_test("Japan","jp"),
|
||||||
qq(ISO 3166: Japan - jp),
|
"3 letter country code Japan" => build_test("Japan","jpn"),
|
||||||
structured_answer => {
|
"3 letter country code of China" => build_test("China","chn"),
|
||||||
input => ['Japan'],
|
"Japan 3 letter country code" => build_test("Japan","jpn"),
|
||||||
operation => 'ISO 3166 Country code',
|
"Russia two letter country code" => build_test("Russia","ru"),
|
||||||
result => 'jp'
|
"two letter country code Japan" => build_test("Japan","jp"),
|
||||||
}
|
"three letter country code for Japan" => build_test("Japan","jpn"),
|
||||||
),
|
"numerical iso code japan" => build_test("Japan",392),
|
||||||
"3 letter country code Japan" => test_zci(
|
"iso code for spain" => build_test("Spain","es"),
|
||||||
qq(ISO 3166: Japan - jpn),
|
"country code jp" => build_test("Japan","jp"),
|
||||||
structured_answer => {
|
"japan numerical iso 3166" => build_test("Japan",392),
|
||||||
input => ['Japan'],
|
"united states of america iso code" => build_test("United states of america","us"),
|
||||||
operation => 'ISO 3166 Country code',
|
"3 letter iso code isle of man" => build_test("Isle of man","imn"),
|
||||||
result => 'jpn'
|
'country code for gelgamek' => undef,
|
||||||
}
|
'iso code for english' => undef,
|
||||||
),
|
|
||||||
"3 letter country code of China" => test_zci(
|
|
||||||
qq(ISO 3166: China - chn),
|
|
||||||
structured_answer => {
|
|
||||||
input => ['China'],
|
|
||||||
operation => 'ISO 3166 Country code',
|
|
||||||
result => 'chn'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"Japan 3 letter country code" => test_zci(
|
|
||||||
qq(ISO 3166: Japan - jpn),
|
|
||||||
structured_answer => {
|
|
||||||
input => ['Japan'],
|
|
||||||
operation => 'ISO 3166 Country code',
|
|
||||||
result => 'jpn'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"Russia two letter country code" => test_zci(
|
|
||||||
qq(ISO 3166: Russia - ru),
|
|
||||||
structured_answer => {
|
|
||||||
input => ['Russia'],
|
|
||||||
operation => 'ISO 3166 Country code',
|
|
||||||
result => 'ru'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"two letter country code Japan" => test_zci(
|
|
||||||
qq(ISO 3166: Japan - jp),
|
|
||||||
structured_answer => {
|
|
||||||
input => ['Japan'],
|
|
||||||
operation => 'ISO 3166 Country code',
|
|
||||||
result => 'jp'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"three letter country code for Japan" => test_zci(
|
|
||||||
qq(ISO 3166: Japan - jpn),
|
|
||||||
structured_answer => {
|
|
||||||
input => ['Japan'],
|
|
||||||
operation => 'ISO 3166 Country code',
|
|
||||||
result => 'jpn'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"numerical iso code japan" => test_zci(
|
|
||||||
qq(ISO 3166: Japan - 392),
|
|
||||||
structured_answer => {
|
|
||||||
input => ['Japan'],
|
|
||||||
operation => 'ISO 3166 Country code',
|
|
||||||
result => '392'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"iso code for spain" => test_zci(
|
|
||||||
qq(ISO 3166: Spain - es),
|
|
||||||
structured_answer => {
|
|
||||||
input => ['Spain'],
|
|
||||||
operation => 'ISO 3166 Country code',
|
|
||||||
result => 'es'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"country code jp" => test_zci(
|
|
||||||
qq(ISO 3166: Japan - jp),
|
|
||||||
structured_answer => {
|
|
||||||
input => ['Japan'],
|
|
||||||
operation => 'ISO 3166 Country code',
|
|
||||||
result => 'jp'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"japan numerical iso 3166" => test_zci(
|
|
||||||
qq(ISO 3166: Japan - 392),
|
|
||||||
structured_answer => {
|
|
||||||
input => ['Japan'],
|
|
||||||
operation => 'ISO 3166 Country code',
|
|
||||||
result => '392'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"united states of america iso code" => test_zci(
|
|
||||||
qq(ISO 3166: United states of america - us),
|
|
||||||
structured_answer => {
|
|
||||||
input => ['United states of america'],
|
|
||||||
operation => 'ISO 3166 Country code',
|
|
||||||
result => 'us'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"3 letter iso code isle of man" => test_zci(
|
|
||||||
qq(ISO 3166: Isle of man - imn),
|
|
||||||
structured_answer => {
|
|
||||||
input => ['Isle of man'],
|
|
||||||
operation => 'ISO 3166 Country code',
|
|
||||||
result => 'imn'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'country code for gelgamek' => undef,
|
|
||||||
'iso code for english' => undef,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'crypthashcheck';
|
zci answer_type => 'crypthashcheck';
|
||||||
|
@ -171,4 +172,3 @@ ddg_goodie_test(
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'currency_in';
|
zci answer_type => 'currency_in';
|
||||||
|
|
60
t/Cusip.t
60
t/Cusip.t
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "cusip";
|
zci answer_type => "cusip";
|
||||||
|
@ -56,7 +57,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip check 037833100' => test_zci("037833100 is a properly formatted CUSIP number.",
|
'cusip check 037833100' => test_zci("037833100 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -64,7 +65,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip 844741108' => test_zci("844741108 is a properly formatted CUSIP number.",
|
'cusip 844741108' => test_zci("844741108 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -72,7 +73,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'037833100 cusip' => test_zci("037833100 is a properly formatted CUSIP number.",
|
'037833100 cusip' => test_zci("037833100 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -80,7 +81,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'037833100 cusip check' => test_zci("037833100 is a properly formatted CUSIP number.",
|
'037833100 cusip check' => test_zci("037833100 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -90,7 +91,7 @@ ddg_goodie_test(
|
||||||
# starting white space should be stripped
|
# starting white space should be stripped
|
||||||
'cusip 037833100' => test_zci("037833100 is a properly formatted CUSIP number.",
|
'cusip 037833100' => test_zci("037833100 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -100,7 +101,7 @@ ddg_goodie_test(
|
||||||
# ending white space should be stripped
|
# ending white space should be stripped
|
||||||
'cusip 037833100 ' => test_zci("037833100 is a properly formatted CUSIP number.",
|
'cusip 037833100 ' => test_zci("037833100 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -110,7 +111,7 @@ ddg_goodie_test(
|
||||||
# starting and ending white space should be stripped
|
# starting and ending white space should be stripped
|
||||||
'cusip 037833100 ' => test_zci("037833100 is a properly formatted CUSIP number.",
|
'cusip 037833100 ' => test_zci("037833100 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -120,7 +121,7 @@ ddg_goodie_test(
|
||||||
# same AAPL queries with an incorrect check digit
|
# same AAPL queries with an incorrect check digit
|
||||||
'cusip 03783310A' => test_zci("03783310A is not a properly formatted CUSIP number.",
|
'cusip 03783310A' => test_zci("03783310A is not a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -128,7 +129,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip 03783310A' => test_zci("03783310A is not a properly formatted CUSIP number.",
|
'cusip 03783310A' => test_zci("03783310A is not a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -136,7 +137,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip 03783310A ' => test_zci("03783310A is not a properly formatted CUSIP number.",
|
'cusip 03783310A ' => test_zci("03783310A is not a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -144,7 +145,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip 03783310A ' => test_zci("03783310A is not a properly formatted CUSIP number.",
|
'cusip 03783310A ' => test_zci("03783310A is not a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -154,7 +155,7 @@ ddg_goodie_test(
|
||||||
# check CUSIP IDs with capital letters (these are for GOOG and Blackberry)
|
# check CUSIP IDs with capital letters (these are for GOOG and Blackberry)
|
||||||
'cusip 38259P706' => test_zci("38259P706 is a properly formatted CUSIP number.",
|
'cusip 38259P706' => test_zci("38259P706 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -162,7 +163,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip 38259P508' => test_zci("38259P508 is a properly formatted CUSIP number.",
|
'cusip 38259P508' => test_zci("38259P508 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -170,7 +171,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip 09228F103' => test_zci("09228F103 is a properly formatted CUSIP number.",
|
'cusip 09228F103' => test_zci("09228F103 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -180,7 +181,7 @@ ddg_goodie_test(
|
||||||
# check the same CUSIP IDs with lower case letters
|
# check the same CUSIP IDs with lower case letters
|
||||||
'cusip 38259p706' => test_zci("38259P706 is a properly formatted CUSIP number.",
|
'cusip 38259p706' => test_zci("38259P706 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -188,7 +189,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip 38259p508' => test_zci("38259P508 is a properly formatted CUSIP number.",
|
'cusip 38259p508' => test_zci("38259P508 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -196,7 +197,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip 09228f103' => test_zci("09228F103 is a properly formatted CUSIP number.",
|
'cusip 09228f103' => test_zci("09228F103 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -208,7 +209,7 @@ ddg_goodie_test(
|
||||||
# if possible, these tests should be replaced with verified CUSIP IDs
|
# if possible, these tests should be replaced with verified CUSIP IDs
|
||||||
'cusip 037833*00' => test_zci("037833*00 is not a properly formatted CUSIP number.",
|
'cusip 037833*00' => test_zci("037833*00 is not a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -216,7 +217,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip 037833*02' => test_zci("037833*02 is a properly formatted CUSIP number.",
|
'cusip 037833*02' => test_zci("037833*02 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -224,7 +225,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip 0378331#0' => test_zci("0378331#0 is not a properly formatted CUSIP number.",
|
'cusip 0378331#0' => test_zci("0378331#0 is not a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -232,7 +233,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip 0378331#7' => test_zci("0378331#7 is a properly formatted CUSIP number.",
|
'cusip 0378331#7' => test_zci("0378331#7 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -240,7 +241,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip 037833@00' => test_zci("037833\@00 is not a properly formatted CUSIP number.",
|
'cusip 037833@00' => test_zci("037833\@00 is not a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -248,7 +249,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip 037833@01' => test_zci("037833\@01 is a properly formatted CUSIP number.",
|
'cusip 037833@01' => test_zci("037833\@01 is a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -259,7 +260,7 @@ ddg_goodie_test(
|
||||||
# even though they are always invalid IDs
|
# even though they are always invalid IDs
|
||||||
'cusip 03783310*' => test_zci("03783310* is not a properly formatted CUSIP number.",
|
'cusip 03783310*' => test_zci("03783310* is not a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -267,7 +268,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip 03783310#' => test_zci("03783310# is not a properly formatted CUSIP number.",
|
'cusip 03783310#' => test_zci("03783310# is not a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -275,7 +276,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip 03783310@' => test_zci("03783310\@ is not a properly formatted CUSIP number.",
|
'cusip 03783310@' => test_zci("03783310\@ is not a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -285,7 +286,7 @@ ddg_goodie_test(
|
||||||
# Odd CUSIP IDs should not break the IA
|
# Odd CUSIP IDs should not break the IA
|
||||||
'cusip ********8' => test_zci("********8 is not a properly formatted CUSIP number.",
|
'cusip ********8' => test_zci("********8 is not a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -293,7 +294,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip ########9' => test_zci("########9 is not a properly formatted CUSIP number.",
|
'cusip ########9' => test_zci("########9 is not a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -301,7 +302,7 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
'cusip @#*@#*@#*' => test_zci("\@#*\@#*\@#* is not a properly formatted CUSIP number.",
|
'cusip @#*@#*@#*' => test_zci("\@#*\@#*\@#* is not a properly formatted CUSIP number.",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
}
|
}
|
||||||
|
@ -310,4 +311,3 @@ ddg_goodie_test(
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
||||||
|
|
2
t/DHL.t
2
t/DHL.t
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'dhl';
|
zci answer_type => 'dhl';
|
||||||
|
@ -28,4 +29,3 @@ ddg_goodie_test(
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use Test::MockTime qw( :all );
|
use Test::MockTime qw( :all );
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
use DDG::Test::Location;
|
use DDG::Test::Location;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
use Test::MockTime qw( :all );
|
use Test::MockTime qw( :all );
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
use Test::MockTime qw( :all );
|
use Test::MockTime qw( :all );
|
||||||
|
|
||||||
|
@ -76,57 +77,57 @@ ddg_goodie_test(
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
'days between jan 1 and jan 15 inclusive' => test_zci(
|
'days between jan 1 and jan 15 inclusive' => test_zci(
|
||||||
qr/^There are 15 days between.+inclusive\.$/,
|
re(qr/^There are 15 days between.+inclusive\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => '-ANY-',
|
input => ignore(),
|
||||||
operation => 'Days between, inclusive',
|
operation => 'Days between, inclusive',
|
||||||
result => 15
|
result => 15
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
'days between jan 1 and 15th feb' => test_zci(
|
'days between jan 1 and 15th feb' => test_zci(
|
||||||
qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/,
|
re(qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => '-ANY-',
|
input => ignore(),
|
||||||
operation => 'Days between',
|
operation => 'Days between',
|
||||||
result => 45
|
result => 45
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
'number of days between jan 1 and 15th feb' => test_zci(
|
'number of days between jan 1 and 15th feb' => test_zci(
|
||||||
qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/,
|
re(qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => '-ANY-',
|
input => ignore(),
|
||||||
operation => 'Days between',
|
operation => 'Days between',
|
||||||
result => 45
|
result => 45
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
'number of days from jan 1 and 15th feb' => test_zci(
|
'number of days from jan 1 and 15th feb' => test_zci(
|
||||||
qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/,
|
re(qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => '-ANY-',
|
input => ignore(),
|
||||||
operation => 'Days between',
|
operation => 'Days between',
|
||||||
result => 45
|
result => 45
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
'days from jan 1 and 15th feb' => test_zci(
|
'days from jan 1 and 15th feb' => test_zci(
|
||||||
qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/,
|
re(qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => '-ANY-',
|
input => ignore(),
|
||||||
operation => 'Days between',
|
operation => 'Days between',
|
||||||
result => 45
|
result => 45
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
'days between today and tomorrow' => test_zci(
|
'days between today and tomorrow' => test_zci(
|
||||||
qr/^There are 1 days between.+ and.+\.$/,
|
re(qr/^There are 1 days between.+ and.+\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => '-ANY-',
|
input => ignore(),
|
||||||
operation => 'Days between',
|
operation => 'Days between',
|
||||||
result => 1
|
result => 1
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
'how many days between feb 2 and feb 17' => test_zci(
|
'how many days between feb 2 and feb 17' => test_zci(
|
||||||
qr/^There are 15 days between.+ and.+\.$/,
|
re(qr/^There are 15 days between.+ and.+\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => '-ANY-',
|
input => ignore(),
|
||||||
operation => 'Days between',
|
operation => 'Days between',
|
||||||
result => 15
|
result => 15
|
||||||
},
|
},
|
||||||
|
|
37
t/Dessert.t
37
t/Dessert.t
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'dessert';
|
zci answer_type => 'dessert';
|
||||||
|
@ -13,81 +14,81 @@ ddg_goodie_test(
|
||||||
'DDG::Goodie::Dessert'
|
'DDG::Goodie::Dessert'
|
||||||
],
|
],
|
||||||
'desserts beginning with a' => test_zci(
|
'desserts beginning with a' => test_zci(
|
||||||
qr/(.*?) is a dessert that begins with 'a'\.$/,
|
re(qr/(.*?) is a dessert that begins with 'a'\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'info',
|
group => 'info',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'desserts beginning with A' => test_zci(
|
'desserts beginning with A' => test_zci(
|
||||||
qr/(.*?) is a dessert that begins with 'A'\.$/,
|
re(qr/(.*?) is a dessert that begins with 'A'\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'info',
|
group => 'info',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'dessert start with a' => test_zci(
|
'dessert start with a' => test_zci(
|
||||||
qr/(.*?) is a dessert that begins with 'a'\.$/,
|
re(qr/(.*?) is a dessert that begins with 'a'\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'info',
|
group => 'info',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'desserts starting with a' => test_zci(
|
'desserts starting with a' => test_zci(
|
||||||
qr/(.*?) is a dessert that begins with 'a'\.$/,
|
re(qr/(.*?) is a dessert that begins with 'a'\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'info',
|
group => 'info',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'dessert starts with a' => test_zci(
|
'dessert starts with a' => test_zci(
|
||||||
qr/(.*?) is a dessert that begins with 'a'\.$/,
|
re(qr/(.*?) is a dessert that begins with 'a'\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'info',
|
group => 'info',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'desserts beginning with z' => test_zci(
|
'desserts beginning with z' => test_zci(
|
||||||
qr/(.*?) is a dessert that begins with 'z'\.$/,
|
re(qr/(.*?) is a dessert that begins with 'z'\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'info',
|
group => 'info',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'a dessert that begins with a' => test_zci(
|
'a dessert that begins with a' => test_zci(
|
||||||
qr/(.*?) is a dessert that begins with 'a'\.$/,
|
re(qr/(.*?) is a dessert that begins with 'a'\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'info',
|
group => 'info',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'a dessert that starts with the letter a' => test_zci(
|
'a dessert that starts with the letter a' => test_zci(
|
||||||
qr/(.*?) is a dessert that begins with 'a'\.$/,
|
re(qr/(.*?) is a dessert that begins with 'a'\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'info',
|
group => 'info',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'dessert that begins with the letter z' => test_zci(
|
'dessert that begins with the letter z' => test_zci(
|
||||||
qr/(.*?) is a dessert that begins with 'z'\.$/,
|
re(qr/(.*?) is a dessert that begins with 'z'\.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'info',
|
group => 'info',
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'dewey_decimal';
|
zci answer_type => 'dewey_decimal';
|
||||||
|
@ -17,7 +18,7 @@ ddg_goodie_test(
|
||||||
'dewey decimal system 640s' => test_zci("", html => '<table cellpadding=1><tr><td>641</td><td> <a href="/?q=Food">Food</a> & <a href="/?q=drink">drink</a></td></tr><tr><td>642</td><td> <a href="/?q=Meal">Meal</a>s & table service</td></tr><tr><td>643</td><td> <a href="/?q=House">Housing</a> & household equipment</td></tr><tr><td>644</td><td> <a href="/?q=Household">Household</a> utilities</td></tr><tr><td>645</td><td> <a href="/?q=Furniture">Household furnishings</a></td></tr><tr><td>646</td><td> <a href="/?q=Sewing">Sewing</a>, <a href="/?q=clothing">clothing</a>, personal living</td></tr><tr><td>647</td><td> <a href="/?q=Household management">Management of public household</a>s</td></tr><tr><td>648</td><td> <a href="/?q=Household chore">Housekeeping</a></td></tr><tr><td>649</td><td> <a href="/?q=Child rearing">Child rearing</a> & <a href="/?q=home care">home care</a> of sick</td></tr></table>'),
|
'dewey decimal system 640s' => test_zci("", html => '<table cellpadding=1><tr><td>641</td><td> <a href="/?q=Food">Food</a> & <a href="/?q=drink">drink</a></td></tr><tr><td>642</td><td> <a href="/?q=Meal">Meal</a>s & table service</td></tr><tr><td>643</td><td> <a href="/?q=House">Housing</a> & household equipment</td></tr><tr><td>644</td><td> <a href="/?q=Household">Household</a> utilities</td></tr><tr><td>645</td><td> <a href="/?q=Furniture">Household furnishings</a></td></tr><tr><td>646</td><td> <a href="/?q=Sewing">Sewing</a>, <a href="/?q=clothing">clothing</a>, personal living</td></tr><tr><td>647</td><td> <a href="/?q=Household management">Management of public household</a>s</td></tr><tr><td>648</td><td> <a href="/?q=Household chore">Housekeeping</a></td></tr><tr><td>649</td><td> <a href="/?q=Child rearing">Child rearing</a> & <a href="/?q=home care">home care</a> of sick</td></tr></table>'),
|
||||||
'#1 in the dewey decimal system' => test_zci("001 is knowledge in the Dewey Decimal System.", html => '001 is <a href="/?q=outline of knowledge">knowledge</a> in the Dewey Decimal System.'),
|
'#1 in the dewey decimal system' => test_zci("001 is knowledge in the Dewey Decimal System.", html => '001 is <a href="/?q=outline of knowledge">knowledge</a> in the Dewey Decimal System.'),
|
||||||
'dewey decimal system naturalism' => test_zci("146 is naturalism and related systems in the Dewey Decimal System.", html => '146 is <a href="/?q=naturalism (philosophy)">naturalism</a> and related systems in the Dewey Decimal System.'),
|
'dewey decimal system naturalism' => test_zci("146 is naturalism and related systems in the Dewey Decimal System.", html => '146 is <a href="/?q=naturalism (philosophy)">naturalism</a> and related systems in the Dewey Decimal System.'),
|
||||||
'etymology in the dewey decimal system' => test_zci("", html => qr{^<table cellpadding=1>.*</table>$}),
|
'etymology in the dewey decimal system' => test_zci("", html => re(qr{^<table cellpadding=1>.*</table>$})),
|
||||||
'dewey 644' => test_zci('644 is household utilities in the Dewey Decimal System.', html => '644 is <a href="/?q=household">household</a> utilities in the Dewey Decimal System.'),
|
'dewey 644' => test_zci('644 is household utilities in the Dewey Decimal System.', html => '644 is <a href="/?q=household">household</a> utilities in the Dewey Decimal System.'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
109
t/Dice.t
109
t/Dice.t
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'dice_roll';
|
zci answer_type => 'dice_roll';
|
||||||
|
@ -17,9 +18,9 @@ ddg_goodie_test(
|
||||||
|
|
||||||
# Check trigger kicks in.
|
# Check trigger kicks in.
|
||||||
'throw dice' => test_zci(
|
'throw dice' => test_zci(
|
||||||
qr/^., .$/,
|
re(qr/^., .$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -29,9 +30,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'throw dices' => test_zci(
|
'throw dices' => test_zci(
|
||||||
qr/^., .$/,
|
re(qr/^., .$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -41,9 +42,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'roll dice' => test_zci(
|
'roll dice' => test_zci(
|
||||||
qr/^., .$/,
|
re(qr/^., .$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -53,9 +54,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'throw die' => test_zci(
|
'throw die' => test_zci(
|
||||||
qr/^.$/,
|
re(qr/^.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -68,9 +69,9 @@ ddg_goodie_test(
|
||||||
|
|
||||||
# Simple "dice" query
|
# Simple "dice" query
|
||||||
"roll 5 dice" => test_zci(
|
"roll 5 dice" => test_zci(
|
||||||
qr/., ., ., ., .$/,
|
re(qr/., ., ., ., .$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -82,9 +83,9 @@ ddg_goodie_test(
|
||||||
|
|
||||||
# Simple shorthand query
|
# Simple shorthand query
|
||||||
"roll 2d6" => test_zci(
|
"roll 2d6" => test_zci(
|
||||||
qr/^\d (\+|-) \d$/,
|
re(qr/^\d (\+|-) \d$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -96,9 +97,9 @@ ddg_goodie_test(
|
||||||
|
|
||||||
# Query with numbers as words
|
# Query with numbers as words
|
||||||
"roll five dice" => test_zci(
|
"roll five dice" => test_zci(
|
||||||
qr/., ., ., ., .$/,
|
re(qr/., ., ., ., .$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -108,9 +109,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"roll twenty five dice" => test_zci(
|
"roll twenty five dice" => test_zci(
|
||||||
qr/., ., ., ., .$/,
|
re(qr/., ., ., ., .$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -120,9 +121,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"roll fifty-four dice" => test_zci(
|
"roll fifty-four dice" => test_zci(
|
||||||
qr/., ., ., ., .$/,
|
re(qr/., ., ., ., .$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -132,9 +133,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"roll seven dices" => test_zci(
|
"roll seven dices" => test_zci(
|
||||||
qr/., ., ., ., .$/,
|
re(qr/., ., ., ., .$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -147,9 +148,9 @@ ddg_goodie_test(
|
||||||
"roll foo dice" => undef,
|
"roll foo dice" => undef,
|
||||||
|
|
||||||
"throw 1d20" => test_zci(
|
"throw 1d20" => test_zci(
|
||||||
qr/^\d{1,2}$/,
|
re(qr/^\d{1,2}$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -159,9 +160,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"roll d20" => test_zci(
|
"roll d20" => test_zci(
|
||||||
qr/^\d{1,2}$/,
|
re(qr/^\d{1,2}$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -173,9 +174,9 @@ ddg_goodie_test(
|
||||||
|
|
||||||
# Simple shorthand queries with +-
|
# Simple shorthand queries with +-
|
||||||
"roll 3d12 + 4" => test_zci(
|
"roll 3d12 + 4" => test_zci(
|
||||||
qr/^\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2}$/,
|
re(qr/^\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2}$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -185,9 +186,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"roll 3d8 - 8" => test_zci(
|
"roll 3d8 - 8" => test_zci(
|
||||||
qr/^\d (\+|-) \d (\+|-) \d (\+|-) \d$/,
|
re(qr/^\d (\+|-) \d (\+|-) \d (\+|-) \d$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -197,9 +198,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"roll 4d6-l" => test_zci(
|
"roll 4d6-l" => test_zci(
|
||||||
qr/^([1-6] \+ ){3}[1-6] - [1-6]$/,
|
re(qr/^([1-6] \+ ){3}[1-6] - [1-6]$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -211,9 +212,9 @@ ddg_goodie_test(
|
||||||
|
|
||||||
# Simple conjunctive "dice" query
|
# Simple conjunctive "dice" query
|
||||||
"throw 2 dice and 3 dice" => test_zci(
|
"throw 2 dice and 3 dice" => test_zci(
|
||||||
qr/., .., ., .Total: \d+$/,
|
re(qr/., .., ., .Total: \d+$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'list',
|
group => 'list',
|
||||||
options => {
|
options => {
|
||||||
|
@ -225,9 +226,9 @@ ddg_goodie_test(
|
||||||
|
|
||||||
# Shorthand conjunctive query
|
# Shorthand conjunctive query
|
||||||
"roll 2w6 and d20" => test_zci(
|
"roll 2w6 and d20" => test_zci(
|
||||||
qr/^\d (\+|-) \d = \d+\d+Total: \d+$/,
|
re(qr/^\d (\+|-) \d = \d+\d+Total: \d+$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'list',
|
group => 'list',
|
||||||
options => {
|
options => {
|
||||||
|
@ -239,9 +240,9 @@ ddg_goodie_test(
|
||||||
|
|
||||||
# Shorthand conjunctive queries with +-
|
# Shorthand conjunctive queries with +-
|
||||||
"roll 2d6 and 3d12 + 4" => test_zci(
|
"roll 2d6 and 3d12 + 4" => test_zci(
|
||||||
qr/^\d (\+|-) \d = \d+\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = \d+Total: \d+$/,
|
re(qr/^\d (\+|-) \d = \d+\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = \d+Total: \d+$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'list',
|
group => 'list',
|
||||||
options => {
|
options => {
|
||||||
|
@ -251,9 +252,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"roll 2d6 and 3d12 - 4" => test_zci(
|
"roll 2d6 and 3d12 - 4" => test_zci(
|
||||||
qr/^\d (\+|-) \d = \d+\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = -?\d+Total: \d+$/,
|
re(qr/^\d (\+|-) \d = \d+\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = -?\d+Total: \d+$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'list',
|
group => 'list',
|
||||||
options => {
|
options => {
|
||||||
|
@ -263,9 +264,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"throw 3d12 - 4 and 2d6" => test_zci(
|
"throw 3d12 - 4 and 2d6" => test_zci(
|
||||||
qr/^\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = -?\d{1,2}\d (\+|-) \d = \d+Total: \d+$/,
|
re(qr/^\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = -?\d{1,2}\d (\+|-) \d = \d+Total: \d+$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'list',
|
group => 'list',
|
||||||
options => {
|
options => {
|
||||||
|
@ -275,9 +276,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"throw 2d6 and 3d12 + 4" => test_zci(
|
"throw 2d6 and 3d12 + 4" => test_zci(
|
||||||
qr/^\d (\+|-) \d = \d+\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = \d+Total: \d+$/,
|
re(qr/^\d (\+|-) \d = \d+\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = \d+Total: \d+$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'list',
|
group => 'list',
|
||||||
options => {
|
options => {
|
||||||
|
@ -287,9 +288,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"roll 2d6 and 4w6-l" => test_zci(
|
"roll 2d6 and 4w6-l" => test_zci(
|
||||||
qr/^\d (\+|-) \d = \d+([1-6] \+ ){3}[1-6] - [1-6] = \d{1,2}Total: \d+$/,
|
re(qr/^\d (\+|-) \d = \d+([1-6] \+ ){3}[1-6] - [1-6] = \d{1,2}Total: \d+$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'list',
|
group => 'list',
|
||||||
options => {
|
options => {
|
||||||
|
@ -299,9 +300,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"roll 2 dice and 3d5 + 4" => test_zci(
|
"roll 2 dice and 3d5 + 4" => test_zci(
|
||||||
qr/^., .\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = \d+Total: \d+$/,
|
re(qr/^., .\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = \d+Total: \d+$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'list',
|
group => 'list',
|
||||||
options => {
|
options => {
|
||||||
|
@ -325,9 +326,9 @@ ddg_goodie_test(
|
||||||
"roll 2d3 and 2d4-a" => undef,
|
"roll 2d3 and 2d4-a" => undef,
|
||||||
|
|
||||||
"throw die" => test_zci(
|
"throw die" => test_zci(
|
||||||
qr/^.$/,
|
re(qr/^.$/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -338,9 +339,9 @@ ddg_goodie_test(
|
||||||
),
|
),
|
||||||
|
|
||||||
'roll 3d12' => test_zci(
|
'roll 3d12' => test_zci(
|
||||||
qr/\d{1,2} \+ \d{1,2} \+ \d{1,2}/,
|
re(qr/\d{1,2} \+ \d{1,2} \+ \d{1,2}/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
options => {
|
||||||
|
@ -350,9 +351,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'roll 3d12 and 2d4' => test_zci(
|
'roll 3d12 and 2d4' => test_zci(
|
||||||
qr/\d{1,2} \+ \d{1,2} \+ \d{1,2} = \d+[1-4]+ \+ [1-4]+ = \dTotal: \d+/,
|
re(qr/\d{1,2} \+ \d{1,2} \+ \d{1,2} = \d+[1-4]+ \+ [1-4]+ = \dTotal: \d+/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'list',
|
group => 'list',
|
||||||
options => {
|
options => {
|
||||||
|
@ -362,9 +363,9 @@ ddg_goodie_test(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'roll 2 dice and 3d5' => test_zci(
|
'roll 2 dice and 3d5' => test_zci(
|
||||||
qr/[1-5]+ \+ [1-5]+ \+ [1-5]+ = \d+Total: \d+/,
|
re(qr/[1-5]+ \+ [1-5]+ \+ [1-5]+ = \d+Total: \d+/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
templates => {
|
templates => {
|
||||||
group => 'list',
|
group => 'list',
|
||||||
options => {
|
options => {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'duckduckgo';
|
zci answer_type => 'duckduckgo';
|
||||||
|
@ -174,4 +175,3 @@ ddg_goodie_test(
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'conversion';
|
zci answer_type => 'conversion';
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'email_validation';
|
zci answer_type => 'email_validation';
|
||||||
|
@ -11,60 +12,60 @@ zci is_cached => 1;
|
||||||
ddg_goodie_test(
|
ddg_goodie_test(
|
||||||
['DDG::Goodie::EmailValidator'],
|
['DDG::Goodie::EmailValidator'],
|
||||||
'validate my email foo@example.com' => test_zci(
|
'validate my email foo@example.com' => test_zci(
|
||||||
qr/appears to be valid/,
|
re(qr/appears to be valid/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['foo@example.com'],
|
input => ['foo@example.com'],
|
||||||
operation => 'Email address validation',
|
operation => 'Email address validation',
|
||||||
result => qr/appears to be valid/
|
result => re(qr/appears to be valid/)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'validate my email foo+abc@example.com' => test_zci(
|
'validate my email foo+abc@example.com' => test_zci(
|
||||||
qr/appears to be valid/,
|
re(qr/appears to be valid/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['foo+abc@example.com'],
|
input => ['foo+abc@example.com'],
|
||||||
operation => 'Email address validation',
|
operation => 'Email address validation',
|
||||||
result => qr/appears to be valid/
|
result => re(qr/appears to be valid/)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'validate my email foo.bar@example.com' => test_zci(
|
'validate my email foo.bar@example.com' => test_zci(
|
||||||
qr/appears to be valid/,
|
re(qr/appears to be valid/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['foo.bar@example.com'],
|
input => ['foo.bar@example.com'],
|
||||||
operation => 'Email address validation',
|
operation => 'Email address validation',
|
||||||
result => qr/appears to be valid/
|
result => re(qr/appears to be valid/)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'validate user@exampleaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com'
|
'validate user@exampleaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com'
|
||||||
=> test_zci(
|
=> test_zci(
|
||||||
qr/Please check the address/,
|
re(qr/Please check the address/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => '-ANY-',
|
input => ignore(),
|
||||||
operation => 'Email address validation',
|
operation => 'Email address validation',
|
||||||
result => qr/Please check the address/,
|
result => re(qr/Please check the address/),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'validate foo@example.com' => test_zci(
|
'validate foo@example.com' => test_zci(
|
||||||
qr/appears to be valid/,
|
re(qr/appears to be valid/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['foo@example.com'],
|
input => ['foo@example.com'],
|
||||||
operation => 'Email address validation',
|
operation => 'Email address validation',
|
||||||
result => qr/appears to be valid/
|
result => re(qr/appears to be valid/)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'validate foo@!!!.com' => test_zci(
|
'validate foo@!!!.com' => test_zci(
|
||||||
qr/Please check the fully qualified domain name/,
|
re(qr/Please check the fully qualified domain name/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['foo@!!!.com'],
|
input => ['foo@!!!.com'],
|
||||||
operation => 'Email address validation',
|
operation => 'Email address validation',
|
||||||
result => qr/Please check the fully qualified domain name/,
|
result => re(qr/Please check the fully qualified domain name/),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'validate foo@example.lmnop' => test_zci(
|
'validate foo@example.lmnop' => test_zci(
|
||||||
qr/Please check the top-level domain/,
|
re(qr/Please check the top-level domain/),
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
input => ['foo@example.lmnop'],
|
input => ['foo@example.lmnop'],
|
||||||
operation => 'Email address validation',
|
operation => 'Email address validation',
|
||||||
result => qr/Please check the top-level domain/,
|
result => re(qr/Please check the top-level domain/),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'validate foo' => undef,
|
'validate foo' => undef,
|
||||||
|
|
|
@ -4,6 +4,7 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'figlet';
|
zci answer_type => 'figlet';
|
||||||
|
|
|
@ -3,45 +3,32 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "factors";
|
zci answer_type => "factors";
|
||||||
zci is_cached => 1;
|
zci is_cached => 1;
|
||||||
|
|
||||||
|
sub build_test
|
||||||
|
{
|
||||||
|
my ($text_answer, $input, $answer) = @_;
|
||||||
|
return test_zci($text_answer, structured_answer =>{
|
||||||
|
data => {
|
||||||
|
title => $answer,
|
||||||
|
subtitle => "Factors of: $input"
|
||||||
|
},
|
||||||
|
templates => {
|
||||||
|
group => 'text'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ddg_goodie_test(
|
ddg_goodie_test(
|
||||||
[qw( DDG::Goodie::Factors)],
|
[qw( DDG::Goodie::Factors)],
|
||||||
'30 factors' => test_zci(
|
'30 factors' => build_test('Factors of 30: 1, 2, 3, 5, 6, 10, 15, 30', '30', '1, 2, 3, 5, 6, 10, 15, 30'),
|
||||||
'Factors of 30: 1, 2, 3, 5, 6, 10, 15, 30',
|
'factors of 72' => build_test('Factors of 72: 1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72', '72', '1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72'),
|
||||||
structured_answer => {
|
'factors of 30' => build_test('Factors of 30: 1, 2, 3, 5, 6, 10, 15, 30', '30', '1, 2, 3, 5, 6, 10, 15, 30'),
|
||||||
input => ['30'],
|
'72 factors' => build_test('Factors of 72: 1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72', '72', '1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72'),
|
||||||
operation => 'Factors',
|
|
||||||
result => '1, 2, 3, 5, 6, 10, 15, 30'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'factors of 72' => test_zci(
|
|
||||||
'Factors of 72: 1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72',
|
|
||||||
structured_answer => {
|
|
||||||
input => ['72'],
|
|
||||||
operation => 'Factors',
|
|
||||||
result => '1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'factors of 30' => test_zci(
|
|
||||||
'Factors of 30: 1, 2, 3, 5, 6, 10, 15, 30',
|
|
||||||
structured_answer => {
|
|
||||||
input => ['30'],
|
|
||||||
operation => 'Factors',
|
|
||||||
result => '1, 2, 3, 5, 6, 10, 15, 30'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'72 factors' => test_zci(
|
|
||||||
'Factors of 72: 1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72',
|
|
||||||
structured_answer => {
|
|
||||||
input => ['72'],
|
|
||||||
operation => 'Factors',
|
|
||||||
result => '1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'fedex';
|
zci answer_type => 'fedex';
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "fen_viewer";
|
zci answer_type => "fen_viewer";
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'fibonacci';
|
zci answer_type => 'fibonacci';
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => "firefoxos";
|
zci answer_type => "firefoxos";
|
||||||
|
@ -10,7 +11,7 @@ zci is_cached => 1;
|
||||||
|
|
||||||
#Structured answer template data
|
#Structured answer template data
|
||||||
my $templateData = {
|
my $templateData = {
|
||||||
data => '-ANY-',
|
data => ignore(),
|
||||||
meta => {
|
meta => {
|
||||||
sourceName => "Mozilla Developer Network",
|
sourceName => "Mozilla Developer Network",
|
||||||
sourceUrl => "https://developer.mozilla.org/en-US/Apps/Reference/Firefox_OS_device_APIs"
|
sourceUrl => "https://developer.mozilla.org/en-US/Apps/Reference/Firefox_OS_device_APIs"
|
||||||
|
|
58
t/FlipText.t
58
t/FlipText.t
|
@ -4,45 +4,39 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use utf8;
|
use utf8;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
use DDG::Test::Goodie;
|
use DDG::Test::Goodie;
|
||||||
|
|
||||||
zci answer_type => 'flip_text';
|
zci answer_type => 'flip_text';
|
||||||
zci is_cached => 1;
|
zci is_cached => 1;
|
||||||
|
|
||||||
|
sub build_structured_answer{
|
||||||
|
my ($input,$result) = @_;
|
||||||
|
return $result,
|
||||||
|
structured_answer => {
|
||||||
|
data => {
|
||||||
|
title => $result,
|
||||||
|
subtitle => "Flip text $input"
|
||||||
|
},
|
||||||
|
templates => {
|
||||||
|
group => 'text',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub build_test{ test_zci(build_structured_answer(@_)) }
|
||||||
|
|
||||||
ddg_goodie_test(
|
ddg_goodie_test(
|
||||||
[qw( DDG::Goodie::FlipText)],
|
[qw( DDG::Goodie::FlipText)],
|
||||||
'flip text test' => test_zci(
|
'flip text test' => build_test('test','ʇsǝʇ'),
|
||||||
"\x{0287}\x{0073}\x{01DD}\x{0287}",
|
'mirror text test' => build_test('test','ʇsǝʇ'),
|
||||||
structured_answer => {
|
'flip text my sentence' => build_test('my sentence','ǝɔuǝʇuǝs ʎɯ'),
|
||||||
input => ['test'],
|
'mirror text text' => build_test('text','ʇxǝʇ'),
|
||||||
operation => 'Flip text',
|
'flip text <hello-world>' => build_test('<hello-world>','<pʃɹoʍ-oʃʃǝɥ>'),
|
||||||
result => 'ʇsǝʇ'
|
'rotate text "hello world"' => build_test('"hello world"','„pʃɹoʍ oʃʃǝɥ„'),
|
||||||
}
|
'spin text ;hello world;' => build_test(';hello world;','؛pʃɹoʍ oʃʃǝɥ؛'),
|
||||||
),
|
'spin text [\'hello\']' => build_test('[\'hello\']','[,oʃʃǝɥ,]'),
|
||||||
'mirror text test' => test_zci(
|
'spin text <<"hello\' % & * () = + . #@!^(/world">>' => build_test('<<"hello\' % & * () = + . #@!^(/world">>','<<„pʃɹoʍ/)∨¡@# ˙ + = () ⁎ ⅋ % ,oʃʃǝɥ„>>'),
|
||||||
"\x{0287}\x{0073}\x{01DD}\x{0287}",
|
|
||||||
structured_answer => {
|
|
||||||
input => ['test'],
|
|
||||||
operation => 'Flip text',
|
|
||||||
result => 'ʇsǝʇ'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'flip text my sentence' => test_zci(
|
|
||||||
'ǝɔuǝʇuǝs ʎɯ',
|
|
||||||
structured_answer => {
|
|
||||||
input => ['my sentence'],
|
|
||||||
operation => 'Flip text',
|
|
||||||
result => 'ǝɔuǝʇuǝs ʎɯ'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'mirror text text' => test_zci(
|
|
||||||
'ʇxǝʇ',
|
|
||||||
structured_answer => {
|
|
||||||
input => ['text'],
|
|
||||||
operation => 'Flip text',
|
|
||||||
result => 'ʇxǝʇ'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue