parent
8a2a9cb4e7
commit
d2b790fef9
@ -6,6 +6,9 @@ var network = require('./network');
|
|||||||
|
|
||||||
var Script = function(data) {
|
var Script = function(data) {
|
||||||
this.buffer = data || [];
|
this.buffer = data || [];
|
||||||
|
if(!Array.isArray(data)) {
|
||||||
|
throw new Error('expect Script to be initialized with Array, but got ' + data)
|
||||||
|
}
|
||||||
this.parse();
|
this.parse();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
17
test/script.js
Normal file
17
test/script.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
var Script = require('../src/script.js')
|
||||||
|
var assert = require('assert')
|
||||||
|
|
||||||
|
describe('Script', function() {
|
||||||
|
describe('constructor', function() {
|
||||||
|
it('works for a byte array', function() {
|
||||||
|
assert.ok(new Script([]))
|
||||||
|
})
|
||||||
|
|
||||||
|
it('throws an error when input is not an array', function() {
|
||||||
|
assert.throws(function(){
|
||||||
|
new Script({})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
Loading…
Reference in New Issue
Block a user