Aliaksei Chapyzhenka fd06dc4104 better API
2019-11-06 15:32:02 -08:00

87 lines
1.5 KiB
JavaScript

'use strict';
const expect = require('chai').expect;
const vcd = require('../index.js');
describe('basic', () => {
it('typeof vcd', done => {
expect(vcd).to.be.an('function');
done();
});
it('typeof vcd instance', done => {
expect(vcd()).to.be.an('object');
done();
});
it('fail: foo bar', done => {
const inst = vcd();
expect(inst.execute(Buffer.from(' foo bar ???'))).to.eq(1);
expect(inst.info).to.deep.eq({
path: [],
status: 'declaration'
});
done();
});
it('$comment', done => {
const inst = vcd();
expect(inst.execute(Buffer.from(
' \n $comment some text $end $comment more text $end ???'
))).to.eq(1);
expect(inst.info).to.deep.eq({
path: [],
status: 'declaration'
});
done();
});
it('$version', done => {
const inst = vcd();
expect(inst.execute(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(inst.execute(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(inst.info).to.deep.eq({
path: [],
status: 'simulation'
});
done();
});
});
/* eslint-env mocha */