2019-10-23 19:42:17 -07:00

102 lines
1.9 KiB
JavaScript

'use strict';
const expect = require('chai').expect;
const lib = require('../index.js');
describe('basic', () => {
it('type', done => {
expect(lib).to.be.an('object');
done();
});
it('type', done => {
const cxt = lib.init();
expect(cxt).to.be.an('object');
done();
});
it('fail: foo bar', done => {
const cxt = lib.init();
expect(lib.execute(cxt, Buffer.from(' foo bar ???'))).to.eq(1);
expect(lib.getInfo(cxt)).to.deep.eq({
error: 1,
reason: 'Expected declaration command',
command: 0,
type: 0,
size: 0,
time: 0,
start: 0,
stop: 0,
trigger: ''
});
done();
});
it('$comment', done => {
const cxt = lib.init();
expect(lib.execute(cxt, Buffer.from(
' \n $comment some text $end $comment more text $end ???'
))).to.eq(1);
expect(lib.getInfo(cxt)).to.deep.eq({
error: 1,
reason: 'Expected declaration command',
command: 1,
type: 0,
size: 0,
time: 0,
start: 0,
stop: 0,
trigger: ''
});
done();
});
it('$version', done => {
const cxt = lib.init();
expect(lib.execute(cxt, Buffer.from(
`
$version Generated by VerilatedVcd $end
$date Wed Sep 18 22:59:07 2019
$end
$timescale 1ns $end
$scope module top $end
$var wire 1 "}G clock $end
$scope module leaf $end
$var wire 64 {u counter [63:0] $end
$upscope $end
$upscope $end
$enddefinitions $end
`
))).to.eq(0); expect(lib.execute(cxt, Buffer.from(
`
#1
0"}G
#2
1"}G
#300
0"}G
b1111000000000000 {u
#301
b0000111100000000 {u
#302
b0000000011110000 {u
#303
b0000000000001111 {u
`
))).to.eq(0);
expect(lib.getInfo(cxt)).to.deep.eq({
error: 0,
reason: 'NO REASON',
command: 19,
type: 17,
size: 64,
time: 303,
start: 300,
stop: 303,
trigger: ''
});
done();
});
});
/* eslint-env mocha */