Merge pull request #1071 from thofmann/opcode/inspect
Add inspect method to Opcode.
This commit is contained in:
commit
aec60ad78c
|
@ -233,4 +233,13 @@ Opcode.isSmallIntOp = function(opcode) {
|
|||
((opcode >= Opcode.map.OP_1) && (opcode <= Opcode.map.OP_16)));
|
||||
};
|
||||
|
||||
/**
|
||||
* Will return a string formatted for the console
|
||||
*
|
||||
* @returns {String} Script opcode
|
||||
*/
|
||||
Opcode.prototype.inspect = function() {
|
||||
return '<Opcode: ' + this.toString() + ', hex: '+this.toHex()+', decimal: '+this.num+'>';
|
||||
};
|
||||
|
||||
module.exports = Opcode;
|
||||
|
|
|
@ -143,5 +143,10 @@ describe('Opcode', function() {
|
|||
|
||||
});
|
||||
|
||||
describe('#inspect', function() {
|
||||
it('should output opcode by name, hex, and decimal', function() {
|
||||
Opcode.fromString('OP_NOP').inspect().should.equal('<Opcode: OP_NOP, hex: 61, decimal: 97>');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue