forked from duckduckgo/zeroclickinfo-goodies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBPMToMs.t
160 lines (151 loc) · 5.2 KB
/
BPMToMs.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Deep;
use DDG::Test::Goodie;
zci answer_type => "bpmto_ms";
zci is_cached => 1;
my $plaintext_120 = "120 bpm in milliseconds:";
$plaintext_120 .= "\nWhole Note: 2000, Triplet: 1333, Dotted: 3000";
$plaintext_120 .= "\nHalf Note: 1000, Triplet: 667, Dotted: 1500";
$plaintext_120 .= "\nQuarter Note: 500, Triplet: 333, Dotted: 750";
$plaintext_120 .= "\n1/8 Note: 250, Triplet: 167, Dotted: 375";
$plaintext_120 .= "\n1/16 Note: 125, Triplet: 83, Dotted: 188";
$plaintext_120 .= "\n1/32 Note: 63, Triplet: 42, Dotted: 94";
my $plaintext_61 = "61 bpm in milliseconds:";
$plaintext_61 .= "\nWhole Note: 3934, Triplet: 2623, Dotted: 5902";
$plaintext_61 .= "\nHalf Note: 1967, Triplet: 1311, Dotted: 2951";
$plaintext_61 .= "\nQuarter Note: 984, Triplet: 656, Dotted: 1475";
$plaintext_61 .= "\n1/8 Note: 492, Triplet: 328, Dotted: 738";
$plaintext_61 .= "\n1/16 Note: 246, Triplet: 164, Dotted: 369";
$plaintext_61 .= "\n1/32 Note: 123, Triplet: 82, Dotted: 184";
ddg_goodie_test(
[qw( DDG::Goodie::BPMToMs)],
"120 beats per minute to ms" => test_zci(
$plaintext_120,
structured_answer => {
data => ignore(),
# [
# {
# note_type => "Whole Note",
# triplet => 1333,
# dotted => 3000,
# milliseconds => 2000,
# image => re(qr/.*/)
# },
# {
# note_type => "Half Note",
# triplet => 667,
# dotted => 1500,
# milliseconds => 1000,
# image => re(qr/.*/)
# },
# {
# note_type => "Quarter Note",
# triplet => 333,
# dotted => 750,
# milliseconds => 500,
# image => re(qr/.*/)
# },
# {
# note_type => "1/8 Note",
# triplet => 167,
# dotted => 375,
# milliseconds => 250,
# image => re(qr/.*/)
# },
# {
# note_type => "1/16 Note",
# triplet => 83,
# dotted => 188,
# milliseconds => 125,
# image => re(qr/.*/)
# },
# {
# note_type => "1/32 Note",
# triplet => 42,
# dotted => 94,
# milliseconds => 63,
# image => re(qr/.*/)
# }
# ],
meta => {
sourceUrl => "https://wikipedia.org/wiki/Tempo#Beats_per_minute",
sourceName => "Wikipedia"
},
templates => {
group => "base",
detail => 0,
options => {
content => "DDH.bpmto_ms.content"
}
}
}
),
"61 beats per minute to ms" => test_zci(
$plaintext_61,
structured_answer => {
data => ignore(),
# [
# {
# note_type => "Whole Note",
# triplet => 2623,
# dotted => 5902,
# milliseconds => 3934,
# image => re(qr/.*/)
# },
# {
# note_type => "Half Note",
# triplet => 1311,
# dotted => 2951,
# milliseconds => 1967,
# image => re(qr/.*/)
# },
# {
# note_type => "Quarter Note",
# triplet => 656,
# dotted => 1475,
# milliseconds => 984,
# image => re(qr/.*/)
# },
# {
# note_type => "1/8 Note",
# triplet => 328,
# dotted => 738,
# milliseconds => 492,
# image => re(qr/.*/)
# },
# {
# note_type => "1/16 Note",
# triplet => 164,
# dotted => 369,
# milliseconds => 246,
# image => re(qr/.*/)
# },
# {
# note_type => "1/32 Note",
# triplet => 82,
# dotted => 184,
# milliseconds => 123,
# image => re(qr/.*/)
# }
# ],
meta => {
sourceUrl => "https://wikipedia.org/wiki/Tempo#Beats_per_minute",
sourceName => "Wikipedia"
},
templates => {
group => "base",
detail => 0,
options => {
content => "DDH.bpmto_ms.content"
}
}
}
),
'-1 bpm to ms' => undef,
'some bpm to ms' => undef,
'bpm' => undef,
);
done_testing;