public
Last active

test code from ansi control character code

  • Download Gist
vows_unit_tests_for_ansi_code.js
JavaScript
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
var batch_util = {
'utility functions': {
'starts_sequence' : {
'can detect a simple sequence': function() {
assert.ok(ansi.util.starts_sequence('\u001b[foobar'));
},
'rejects something obviously not a sequence': function() {
assert.ok(!ansi.util.starts_sequence('foobar'));
},
'rejects a truncated sequence': function() {
assert.ok(!ansi.util.starts_sequence('\u001b['));
},
'groks undefined': function() {
assert.ok(!ansi.util.starts_sequence());
}
},
 
'take_first_number': {
'groks undefined': function() {
assert.ok(isNaN(ansi.util.take_first_number()));
}
},
 
'tokenize_sequence': {
'groks undefined': function() {
var ret = ansi.util.tokenize_sequence();
assert.ok(!ret.sequence);
assert.ok(ret.octets_consumed === 0);
},
'rejects crap': function() {
var ret = ansi.util.tokenize_sequence('abc');
assert.ok(!ret.sequence);
assert.ok(ret.octets_consumed === 0);
},
'handles a simple CUU': function() {
var ret = ansi.util.tokenize_sequence('\u001b[0A');
assert.equal(ret.sequence.opcode, 'A');
assert.equal(ret.sequence.name, 'Cursor Up');
assert.equal(ret.octets_consumed, 4);
assert.equal(ret.sequence.n, 0);
}
}
}
};

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.