Marko Stanković 2016-06-07 23:20:25 +02:00
parent 2339800cb0
commit 9944b4b427
1 changed files with 30 additions and 138 deletions

View File

@ -10,148 +10,40 @@ use utf8;
zci is_cached => 1;
zci answer_type => 'ohms';
sub build_structured_answer {
my ($exp_result, $exp_input) = @_;
return "A $exp_input resistor has a resistance of $exp_result.", structured_answer => {
data => {
title => "$exp_result",
subtitle => "Resistance of $exp_input resistor"
},
meta => {
sourceName => "Wikipedia",
sourceUrl => "https://en.wikipedia.org/wiki/Electronic_color_code"
},
templates => {
group => 'text',
moreAt => 1
}
};
}
sub build_test { test_zci(build_structured_answer(@_)) }
ddg_goodie_test(
[qw(
DDG::Goodie::ReverseResistorColours
)],
'black green red resistor' => test_zci(
'A black green red resistor has a resistance of 500 Ω ± 20%.',
structured_answer => {
data => {
title => '500 Ω ± 20%',
subtitle => 'Resistance of black green red resistor'
},
meta => {
sourceName => "Wikipedia",
sourceUrl => "https://en.wikipedia.org/wiki/Electronic_color_code",
},
templates => {
group => 'text',
options => {
moreAt => 1,
}
}
}
),
'red orange yellow gold resistor' => test_zci(
'A red orange yellow gold resistor has a resistance of 230 kΩ ± 5%.',
structured_answer => {
data => {
title => '230 kΩ ± 5%',
subtitle => 'Resistance of red orange yellow gold resistor'
},
meta => {
sourceName => "Wikipedia",
sourceUrl => "https://en.wikipedia.org/wiki/Electronic_color_code",
},
templates => {
group => 'text',
options => {
moreAt => 1,
}
}
}
),
'resistor yellow blue purple'=> test_zci(
'A yellow blue violet resistor has a resistance of 460 MΩ ± 20%.',
structured_answer => {
data => {
title => '460 MΩ ± 20%',
subtitle => 'Resistance of yellow blue violet resistor'
},
meta => {
sourceName => "Wikipedia",
sourceUrl => "https://en.wikipedia.org/wiki/Electronic_color_code",
},
templates => {
group => 'text',
options => {
moreAt => 1,
}
}
}
),
'resistor yellow green' => undef,
'resistor red orange blue red green' => undef,
'resistor red banana orangutan' => undef,
'red yellow white gold resistor' => test_zci(
'A red yellow white gold resistor has a resistance of 24 GΩ ± 5%.',
structured_answer => {
data => {
title => '24 GΩ ± 5%',
subtitle => 'Resistance of red yellow white gold resistor'
},
meta => {
sourceName => "Wikipedia",
sourceUrl => "https://en.wikipedia.org/wiki/Electronic_color_code",
},
templates => {
group => 'text',
options => {
moreAt => 1,
}
}
}
),
'resistor red yellow white' => test_zci(
'A red yellow white resistor has a resistance of 24 GΩ ± 20%.',
structured_answer => {
data => {
title => '24 GΩ ± 20%',
subtitle => 'Resistance of red yellow white resistor'
},
meta => {
sourceName => "Wikipedia",
sourceUrl => "https://en.wikipedia.org/wiki/Electronic_color_code",
},
templates => {
group => 'text',
options => {
moreAt => 1,
}
}
}
),
'brown black gold silver resistor' => test_zci(
'A brown black gold silver resistor has a resistance of 1 Ω ± 10%.',
structured_answer => {
data => {
title => '1 Ω ± 10%',
subtitle => 'Resistance of brown black gold silver resistor'
},
meta => {
sourceName => "Wikipedia",
sourceUrl => "https://en.wikipedia.org/wiki/Electronic_color_code",
},
templates => {
group => 'text',
options => {
moreAt => 1,
}
}
}
),
'brown black silver gold resistor' => test_zci(
'A brown black silver gold resistor has a resistance of 0.1 Ω ± 5%.',
structured_answer => {
data => {
title => '0.1 Ω ± 5%',
subtitle => 'Resistance of brown black silver gold resistor'
},
meta => {
sourceName => "Wikipedia",
sourceUrl => "https://en.wikipedia.org/wiki/Electronic_color_code",
},
templates => {
group => 'text',
options => {
moreAt => 1,
}
}
}
)
'black green red resistor' => build_test('black green red', '500 Ω ± 20%'),
'red orange yellow gold resistor' => build_test('red orange yellow gold', '230 kΩ ± 5%'),
'yellow blue purple resistor' => build_test('yellow blue violet', '460 MΩ ± 20%'),
'resistor yellow green' => undef,
'resistor red orange blue red green' => undef,
'resistor red banana orangutan' => undef,
'red yellow white gold resistor' => build_test('red yellow white gold', '24 GΩ ± 5%'),
'resistor red yellow white' => build_test('red yellow white', '24 GΩ ± 20%'),
'brown black gold silver resistor' => build_test('brown black gold silver', '1 Ω ± 10%'),
'brown black silver gold resistor' => build_test('brown black silver gold', '0.1 Ω ± 5%')
);
done_testing;