Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
npm test now does... something somewhat useful. now to write a bunch of tests.
- Loading branch information
Showing
5 changed files
with
116 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
{ | ||
"name": "jsxm", | ||
"version": "1", | ||
"version": "1.0.0", | ||
"description": "WebAudio FastTracker 2 .XM module player", | ||
"keywords": "fasttracker xm webaudio", | ||
"uri": "http://www.a1k0n.net/code/jsxm/", | ||
"repository": "a1k0n/jsxm", | ||
"author": "Andy Sloane <andy@a1k0n.net> (http://www.a1k0n.net/)", | ||
|
||
"main": "index.html", | ||
"window": { | ||
"frame": true, | ||
"toolbar": false, | ||
"position": "center", | ||
"resizable": true | ||
} | ||
}, | ||
"scripts": { "test": "node test/all.js" }, | ||
"devDependencies": { "test": ">=0.0.5" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
window = {}; | ||
|
||
require('../xm.js', window); | ||
require('../xmeffects.js', window); | ||
|
||
var XMPlayer = window.XMPlayer; | ||
|
||
// set up basic blank single-channel, single-pattern XM | ||
function ResetXMData() { | ||
var xm = {}; | ||
window.XMPlayer.xm = xm; | ||
xm.channelinfo = []; | ||
xm.songname = "test song"; | ||
xm.song_looppos = 0; | ||
xm.nchan = 1; | ||
xm.flags = 1; | ||
xm.tempo = 3; | ||
xm.bpm = 125; | ||
xm.channelinfo.push({ | ||
number: 0, | ||
filterstate: new Float32Array(3), | ||
vol: 0, | ||
pan: 128, | ||
period: 1920 - 48*16, | ||
vL: 0, vR: 0, | ||
vLprev: 0, vRprev: 0, | ||
mute: 0, | ||
volE: 0, panE: 0, | ||
retrig: 0, | ||
vibratodepth: 1, | ||
vibratospeed: 1, | ||
}); | ||
xm.songpats = [0]; | ||
// 1 channel, 2 row blank pattern | ||
xm.patterns = [ | ||
[[[-1, -1, -1, 0, 0]]], | ||
[[[-1, -1, -1, 0, 0]]]]; | ||
xm.instruments = []; | ||
xm.instruments.push({ | ||
'name': "test instrument", | ||
'number': 0, | ||
'samples': [ | ||
{ 'len': 256, 'loop': 0, | ||
'looplen': 256, 'note': 0, 'fine': 0, | ||
'pan': 128, 'type': 0, 'vol': 64, | ||
'sampledata': new Float32Array(256) | ||
} | ||
], | ||
'samplemap': new Uint8Array(96), | ||
'env_vol': new XMPlayer.Envelope([0, 64, 1, 0], 2, 0, 0, 0), | ||
'env_pan': new XMPlayer.Envelope([0, 32], 0, 0, 0, 0) | ||
}); | ||
// reset song position | ||
XMPlayer.cur_songpos = -1; | ||
XMPlayer.cur_pat = -1; | ||
XMPlayer.cur_tick = xm.tempo; | ||
return xm; | ||
} | ||
|
||
// using assert passed to the test function that just logs failures | ||
exports['test XM startup'] = function(assert) { | ||
ResetXMData(); | ||
XMPlayer.nextTick(); | ||
assert.equal(XMPlayer.cur_songpos, 0, 'advance to initial song position'); | ||
assert.equal(XMPlayer.cur_pat, 0, 'advance to pattern 0'); | ||
assert.equal(XMPlayer.cur_tick, 0, 'advance to tick 0'); | ||
assert.equal(XMPlayer.cur_row, 1, 'advance to row 1'); | ||
}; | ||
|
||
exports['test note on'] = function(assert) { | ||
var xm = ResetXMData(); | ||
// [row][column][channel] | ||
xm.patterns[0][0][0] = [48, 1, 0x10 + 33, 0, 0]; // C-4 1 40 000 | ||
XMPlayer.nextTick(); | ||
var ch = xm.channelinfo[0]; | ||
assert.equal(ch.note, 48, 'set note'); | ||
assert.equal(ch.period, 1152, 'channel period'); | ||
assert.equal(ch.vol, 33, 'channel volume'); | ||
assert.equal(ch.samp, xm.instruments[0].samples[0], 'set sample'); | ||
}; | ||
|
||
if (module == require.main) require('test').run(exports); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters