-
Notifications
You must be signed in to change notification settings - Fork 50
/
jtab-unittest.html
580 lines (460 loc) · 22.9 KB
/
jtab-unittest.html
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>jTab - Unit Tests</title>
<script src="unit_test_assets/jsunittest.js" type="text/javascript"></script>
<link rel="stylesheet" href="unit_test_assets/unittest.css" type="text/css" />
<!-- START: for jtab -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<link type="text/css" rel="stylesheet" href="css/jtab-helper.css"/>
<script src="javascripts/jquery.js" type="text/javascript"></script>
<script src="javascripts/raphael.js" type="text/javascript"></script>
<script src="javascripts/jtab.js" type="text/javascript"></script>
<!-- END: for jtab -->
</head>
<body>
<div id="content">
<div id="header">
<h1>jTab - Unit Tests</h1>
<p>
This file tests the core algirithms in <strong>jtab.js</strong>.
</p>
</div>
<!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
<div id="testlog"></div>
<!-- Put sample/test html here -->
<div id="sample">
</div>
</div>
<script type="text/javascript">
// <![CDATA[
new Test.Unit.Runner({
setup: function() {
},
teardown: function() {
},
testUnitTestFrameworkOperational: function() { with(this) {
assert(true);
}},
testRaphaelGetStringNumber: function() { with(this) {
var token = "$1"; var expected = 1;
assertEqual( expected, Raphael.fn.get_string_number(token), "incorrect string number for: '" + token + "'" );
token = "$2"; expected = 2;
assertEqual( expected, Raphael.fn.get_string_number(token), "incorrect string number for: '" + token + "'" );
token = "$3"; expected = 3;
assertEqual( expected, Raphael.fn.get_string_number(token), "incorrect string number for: '" + token + "'" );
token = "$4"; expected = 4;
assertEqual( expected, Raphael.fn.get_string_number(token), "incorrect string number for: '" + token + "'" );
token = "$5"; expected = 5;
assertEqual( expected, Raphael.fn.get_string_number(token), "incorrect string number for: '" + token + "'" );
token = "$6"; expected = 6;
assertEqual( expected, Raphael.fn.get_string_number(token), "incorrect string number for: '" + token + "'" );
token = "$e"; expected = 1;
assertEqual( expected, Raphael.fn.get_string_number(token), "incorrect string number for: '" + token + "'" );
token = "$B"; expected = 2;
assertEqual( expected, Raphael.fn.get_string_number(token), "incorrect string number for: '" + token + "'" );
token = "$G"; expected = 3;
assertEqual( expected, Raphael.fn.get_string_number(token), "incorrect string number for: '" + token + "'" );
token = "$D"; expected = 4;
assertEqual( expected, Raphael.fn.get_string_number(token), "incorrect string number for: '" + token + "'" );
token = "$A"; expected = 5;
assertEqual( expected, Raphael.fn.get_string_number(token), "incorrect string number for: '" + token + "'" );
token = "$E"; expected = 6;
assertEqual( expected, Raphael.fn.get_string_number(token), "incorrect string number for: '" + token + "'" );
}},
testRecognizeChordAndTabNotation: function() { with(this) {
var notation = "Bm $3 4 4h5p3h4 5 $2 3 5 7 7h8p7 5/7 | A $4 7 9 $3 7 6 $5 9 $4 7h9 7 $5 9\7 5/7 | ";
var tabtype = jtab.characterize( notation );
assertEqual( 1, tabtype, "not recognised as chord and tab notation: '" + notation + "'" );
notation = "A7 $e 2 3 $B.3.$e.2";
tabtype = jtab.characterize( notation );
assertEqual( 1, tabtype, "not recognised as chord and tab notation: '" + notation + "'" );
notation = "Bm $3 4 4h5p3h4 5 $2 3 5 7 7h8p7 5/7 ";
tabtype = jtab.characterize( notation );
assertEqual( 1, tabtype, "not recognised as chord and tab notation: '" + notation + "'" );
}},
testRecognizeChordOnlyNotation: function() { with(this) {
var notation = "A B C D E F G / | Ab Bb Db Eb Gb | A# C# D# F# G# || Am A6 Am6 A69 A7 Am7 Amaj7 A7b5 A7#5 Am7b5 A7b9 A9 Am9 Amaj9 Aadd9 A13 Asus2 Asus4 Adim Adim7 Aaug";
var tabtype = jtab.characterize( notation );
assertEqual( 2, tabtype, "not recognised as chord-only notation: '" + notation + "'" );
}},
testRecognizeCustomChordOnlyNotation: function() { with(this) {
// let's try a C chord
var notation = "%X/X.4/3.2/2.0/0.1/1.0/0[C]";
var tabtype = jtab.characterize( notation );
assertEqual( 2, tabtype, "not recognised as custom-chord-only notation: '" + notation + "'" );
}},
testRecognizeCustomChordNoNameNotation: function() { with(this) {
// let's try a C chord, but don't include the name
var notation = "%X/X.4/3.2/2.0/0.1/1.0/0";
var tabtype = jtab.characterize( notation );
assertEqual( 2, tabtype, "not recognised as custom-chord-only notation: '" + notation + "'" );
}},
testRecognizeTabOnlyNotation: function() { with(this) {
var notation = "$1 2 3 $2.3.$1.2";
var tabtype = jtab.characterize( notation );
assertEqual( 3, tabtype, "not recognised as tab-only notation: '" + notation + "'" );
notation = "$e 2 3 $B.3.$e.2";
tabtype = jtab.characterize( notation );
assertEqual( 3, tabtype, "not recognised as tab-only notation: '" + notation + "'" );
notation = "X02220 8.10.10.9.8.8";
tabtype = jtab.characterize( notation );
assertEqual( 3, tabtype, "not recognised as tab-only notation: '" + notation + "'" );
}},
/*
The western scale is commonly found in 'western pop' music.
It consists of 12 notes that are 1 intervals apart to form an octave.
Eg. C, C#, D, Eb, E, F, F#, G, G#, A, Bb, C
Other notable scales such as the Pentatonic scale which consists of only 5 notes and
the Indian scale which has 24 notes.
We need to normalize the notes available to our western scale into base notes because
the following pairs are equivalent.
C# = Db
D# = Eb
F# = Gb
G# = Ab
A# = Bb
It is just a matter of convention when we favoured C#, Eb, F#, G#, Bb over their
equivalents in rendering our base notes.
*/
testWesternScale: function() { with(this) {
var scale = jtab.WesternScale;
assertNotUndefined( scale, "jtab.WesternScale should be valid" );
}},
testWesternScaleBaseNotes: function() { with(this) {
var baseNotes = jtab.WesternScale.BaseNotes;
assertNotUndefined( baseNotes, "jtab.WesternScale.BaseNotes should be valid" );
var validBaseNotes = {
'C' : [ 'C' , 'C', 0 ],
'C#': [ 'C#', 'C', 1 ],
'Db': [ 'C#', 'C', 1 ],
'D' : [ 'D' , 'D', 0 ],
'D#': [ 'Eb', 'D', 1 ],
'Eb': [ 'Eb', 'D', 1 ],
'E' : [ 'E' , 'E', 0 ],
'F' : [ 'F' , 'E', 1 ],
'F#': [ 'F#', 'E', 2 ],
'Gb': [ 'F#', 'E', 2 ],
'G' : [ 'G' , 'G', 0 ],
'G#': [ 'G#', 'G', 1 ],
'Ab': [ 'G#', 'G', 1 ],
'A' : [ 'A' , 'A', 0 ],
'A#': [ 'Bb', 'A', 1 ],
'Bb': [ 'Bb', 'A', 1 ],
'B' : [ 'B' , 'A', 2 ]
};
assertHashEqual( validBaseNotes, baseNotes, "jtab.WesternScale.BaseNotes should have correct mappings" );
}},
testWesternScaleBaseIntervals: function() { with(this) {
var baseIntervals = jtab.WesternScale.BaseIntervals;
assertNotUndefined( baseIntervals, "jtab.WesternScale.BaseIntervals should be valid" );
var validBaseIntervals = ['C', 'C#', 'D', 'Eb', 'E', 'F', 'F#', 'G', 'G#', 'A', 'Bb', 'B'];
assertHashEqual( validBaseIntervals, baseIntervals, "jtab.WesternScale.BaseIntervals should have correct 12 notes" );
}},
testChordsAreBasedOnWesternScale: function() { with(this) {
var msg = "Chords should be based on the western scale";
var chord = new jtabChord('C');
assertEqual( jtab.WesternScale, chord.scale, msg );
assertEqual( jtab.WesternScale.BaseNotes, chord.baseNotes, msg );
}},
testChordListIsAvailable: function() { with(this) {
var msg = "jtab.ChordLists should be an array of all chord names";
var chordList = jtab.ChordList();
assertInstanceOf( Array, chordList, msg );
}},
testChordListContainsValidChords: function() { with(this) {
var msg = "jtab.ChordLists should only contain valid chord names";
var chordList = jtab.ChordList();
for (var key = 0; key < chordList.length; key++) {
var token = chordList[key];
assertEqual( "string", typeof(token), token + " expect a String" );
var chord = new jtabChord(token);
assert( chord.isValid, "jtabChord('" + token + "') should be valid" );
}
}},
/*
In our CAGED system, we'll be using positions as defined in the following matrix
C = position 1
A = position 2
G = position 3
E = position 4
D = position 5
As such position 1 can also be called the 'C shape' position, position 2 the
'A shape' position, etc.
Playing different chord voicings then becomes nothing more than just shifting the
appropriate shapes around to coincide the shape's root note with the desired chord's
root note on the fretboard.
Eg.
Fret 0 X_R_______O
|_|_|_|_|_|
|_|_1_2_3_|
Fret 3 |_|_|_|_|_|
|_|_|_|_|_|
An 'A shaped' A major where its root note is at 'R'
Fret 0 X__________
|_|_|_|_|_|
|_R_|_|_|_1
Fret 3 |_|_|_|_|_|
|_|_2_3_4_|
An 'A shaped' B major with root of A shape over B note on 5th string
Position/shape can be defined in our chord token,
Eg. C:1, Cmaj7:3, etc.
where the numbers 1-5 after the ':' in token reflects the desired position/shape.
If in the absence of specified position/shape in token, we'll use the most playable
shape as the desired chord's position/shape. In general,
- Chords with root note within C, A, G, E, D will take the shape of it's root note except
* major 7ths
* minor chords
* dominants above 7ths, eg. C9, C11, etc.
* augmented chords
* diminished chords
- E & A shapes (good for barred chords) will be considered for exceptions above
- Chords with root note that falls within B, Bb, C#, Eb will use A shape
- Chords with root note that falls within F, F#, G# will take E shape
*/
testRecognizingRootNoteOfChordFromToken: function() { with(this) {
var msg = "Root note of chord should be correct";
var chord = new jtabChord('C');
assertEqual( 'C', chord.rootNote, msg );
chord = new jtabChord('C#');
assertEqual( 'C#', chord.rootNote, msg );
chord = new jtabChord('C#m');
assertEqual( 'C#', chord.rootNote, msg );
chord = new jtabChord('C#maj7');
assertEqual( 'C#', chord.rootNote, msg );
chord = new jtabChord('C#maj7:1');
assertEqual( 'C#', chord.rootNote, msg );
chord = new jtabChord('Db');
assertEqual( 'Db', chord.rootNote, msg );
chord = new jtabChord('Dbmaj7');
assertEqual( 'Db', chord.rootNote, msg );
chord = new jtabChord('Dbmaj7:2');
assertEqual( 'Db', chord.rootNote, msg );
}},
testSettingCagedPositionFromToken: function() { with(this) {
var msg = "Caged position should follow position found in token";
var chord = new jtabChord('C:1');
var cagedPos = chord.cagedPos;
assertNotUndefined( cagedPos );
assertEqual( 1, cagedPos, msg );
chord = new jtabChord('C:2');
cagedPos = chord.cagedPos;
assertEqual( 2, cagedPos, msg );
chord = new jtabChord('C:3');
cagedPos = chord.cagedPos;
assertEqual( 3, cagedPos, msg );
chord = new jtabChord('C:4');
cagedPos = chord.cagedPos;
assertEqual( 4, cagedPos, msg );
}},
testSettingCagedBaseFromToken: function() { with(this) {
var msg = "Caged base fret position should derived from root note";
var chord = new jtabChord('C');
var cagedBaseShape = chord.cagedBaseShape;
assertNotUndefined( cagedBaseShape );
assertEqual( 'C', cagedBaseShape, msg );
chord = new jtabChord('C#');
cagedBaseShape = chord.cagedBaseShape;
assertEqual( 'C', cagedBaseShape, msg);
chord = new jtabChord('D');
cagedBaseShape = chord.cagedBaseShape;
assertEqual( 'D', cagedBaseShape, msg);
chord = new jtabChord('D#');
cagedBaseShape = chord.cagedBaseShape;
assertEqual( 'D', cagedBaseShape, msg);
chord = new jtabChord('E');
cagedBaseShape = chord.cagedBaseShape;
assertEqual( 'E', cagedBaseShape, msg);
chord = new jtabChord('Eb');
cagedBaseShape = chord.cagedBaseShape;
assertEqual( 'D', cagedBaseShape, msg);
chord = new jtabChord('F');
cagedBaseShape = chord.cagedBaseShape;
assertEqual( 'E', cagedBaseShape, msg);
chord = new jtabChord('F#');
cagedBaseShape = chord.cagedBaseShape;
assertEqual( 'E', cagedBaseShape, msg);
chord = new jtabChord('G');
cagedBaseShape = chord.cagedBaseShape;
assertEqual( 'G', cagedBaseShape, msg);
chord = new jtabChord('G#');
cagedBaseShape = chord.cagedBaseShape;
assertEqual( 'G', cagedBaseShape, msg);
chord = new jtabChord('A');
cagedBaseShape = chord.cagedBaseShape;
assertEqual( 'A', cagedBaseShape, msg);
chord = new jtabChord('A#');
cagedBaseShape = chord.cagedBaseShape;
assertEqual( 'A', cagedBaseShape, msg);
chord = new jtabChord('Bb');
cagedBaseShape = chord.cagedBaseShape;
assertEqual( 'A', cagedBaseShape, msg);
chord = new jtabChord('B');
cagedBaseShape = chord.cagedBaseShape;
assertEqual( 'A', cagedBaseShape, msg);
}},
testChord_C_fingering: function() { with(this) {
var token = 'C';
var modelChordArray = [ 0, [-1 ], [3,3], [2,2], [0 ], [1,1], [0 ] ];
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( ! c.isCaged, "jtabChord('" + token + "') should not be CAGED" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testCustomChord_Bm7b5_fingering: function() { with(this) {
var token = "%7/2.X/X.7/3.7/4.6/1.X/X[Bm7b5]";
var modelChordArray = [ 5, [7,2], [-1 ], [7,3], [7,4], [6,1], [-1 ]]
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( c.isCustom, "jtabChord('" + token + "') should be custom chord" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testCustomChord_F_fingering: function() { with(this) {
var token = "%8/2.X/X.7/1.10/4.X/X.X/X[F]";
var modelChordArray = [ 6, [8,2], [-1 ], [7,1], [10,4], [-1 ], [-1 ]]
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( c.isCustom, "jtabChord('" + token + "') should be custom chord" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testCustomChord_No_Name: function() { with(this) {
var token = "%0/0.2/2.3/2.1/1.0/0.0/0";
var modelChordArray = [ 0, [0,0], [2,2], [3,2], [1,1], [0,0], [0,0]]
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( c.isCustom, "jtabChord('" + token + "') should be custom chord" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testCustomChord_E_fingering: function() { with(this) {
var token = "%0/0.2/2.3/2.1/1.0/0.0/0[E]";
var modelChordArray = [ 0, [0,0], [2,2], [3,2], [1,1], [0,0], [0,0]]
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( c.isCustom, "jtabChord('" + token + "') should be custom chord" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testChord_C1_fingering: function() { with(this) {
var token = 'C:1';
var modelChordArray = [ 0, [-1 ], [3,3], [2,2], [0 ], [1,1], [0 ] ];
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( c.isCaged, "jtabChord('" + token + "') should be CAGED" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testChord_C2_fingering: function() { with(this) {
var token = 'C:2';
var modelChordArray = [ 2, [-1,-1 ], [3,1], [5,2], [5,3], [5,4], [3,1] ];
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( c.isCaged, "jtabChord('" + token + "') should be CAGED" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testChord_Cm_fingering: function() { with(this) {
var token = 'Cm';
var modelChordArray = [ 0, [-1 ], [3,4], [1,2], [0 ], [1,1], [-1 ] ];
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( ! c.isCaged, "jtabChord('" + token + "') should not be CAGED" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testChord_Cm1_fingering: function() { with(this) {
var token = 'Cm:1';
var modelChordArray = [ 0, [-1 ], [3,4], [1,2], [0 ], [1,1], [-1 ] ];
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( c.isCaged, "jtabChord('" + token + "') should be CAGED" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testChord_Cm2_fingering: function() { with(this) {
var token = 'Cm:2';
var modelChordArray = [ 2, [-1,-1 ], [3,1], [5,3], [5,4], [4,2], [3,1] ];
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( c.isCaged, "jtabChord('" + token + "') should be CAGED" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testChord_A_fingering: function() { with(this) {
var token = 'A';
var modelChordArray = [ 0, [-1], [0 ], [2,2], [2,1], [2,3], [0 ] ];
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( ! c.isCaged, "jtabChord('" + token + "') should not be CAGED" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testChord_A1_fingering: function() { with(this) {
var token = 'A:1';
var modelChordArray = [ 0, [-1], [0 ], [2,2], [2,1], [2,3], [0 ] ];
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( c.isCaged, "jtabChord('" + token + "') should be CAGED" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testChord_A2_fingering: function() { with(this) {
var token = 'A:2';
var modelChordArray = [ 1, [5,3], [4,2], [2,1], [2,1], [2,1], [5,4 ] ];
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( c.isCaged, "jtabChord('" + token + "') should be CAGED" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testChord_A3_fingering: function() { with(this) {
var token = 'A:3';
var modelChordArray = [ 4, [5,1], [7,3], [7,4], [6,2], [5,1], [5,1 ] ];
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( c.isCaged, "jtabChord('" + token + "') should be CAGED" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testChord_Dm7b5_fingering: function() { with(this) {
var token = 'Dm7b5';
var modelChordArray = [ 0, [-1 ], [-1 ], [0 ], [1,1], [1,1], [1,1] ];
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( ! c.isCaged, "jtabChord('" + token + "') should not be CAGED" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testChord_Dm7b5p2_fingering: function() { with(this) {
var token = 'Dm7b5:2';
var modelChordArray = [ 1, [-1, null], [5,1 ], [6,3], [5,2], [6,4], [-1, null] ];
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( c.isCaged, "jtabChord('" + token + "') should be CAGED" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testChord_AddChord_insert: function() { with(this) {
var token = 'ATest';
var modelChordArrayNew = [ 0, [-1], [0 ], [2,3], [2,2], [2,1], [0 ] ];
var c = new jtabChord(token);
assert( !c.isValid, "jtabChord('" + token + "') should not initially be valid" );
jtab.AddChord(token, [modelChordArrayNew]);
c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid after insert" );
assertHashEqual( modelChordArrayNew, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},
testChord_AddChord_update: function() { with(this) {
var token = 'A';
var modelChordArray = [ 0, [-1], [0 ], [2,2], [2,1], [2,3], [0 ] ];
var modelChordArrayNew = [ 0, [-1], [0 ], [2,2], [2,2], [2,3], [0 ] ];
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should initially be valid" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray before update" );
jtab.AddChord(token, [modelChordArrayNew]);
c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid after update" );
assertHashEqual( modelChordArrayNew, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray after update" );
}},
testChord_Csharpm_fingering: function() { with(this) {
var token = 'C#m';
var modelChordArray = [ 0, [-1 ], [-1], [2,2], [1,1], [2,3], [0] ];
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( ! c.isCaged, "jtabChord('" + token + "') should not be CAGED" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}}
});
// ]]>
</script>
</body>
</html>