Merge pull request #77 from santigimeno/value_mask_fixes

src: ignore invalid mask values
This commit is contained in:
Andrey Sidorov 2015-01-09 08:53:22 +11:00
commit ef2c30793a
2 changed files with 21 additions and 6 deletions

View file

@ -213,13 +213,16 @@ function packValueMask(reqname, values)
if (!reqValueMask)
throw new Error(reqname + ': no value mask description');
for (var v in values)
for (var value in values)
{
var valueBit = reqValueMask[v].mask;
if (!valueBit)
throw new Error(reqname + ': incorrect value param ' + v);
masksList.push(valueBit);
bitmask |= valueBit;
var v = reqValueMask[value];
if (v) {
var valueBit = v.mask;
if (!valueBit)
throw new Error(reqname + ': incorrect value param ' + value);
masksList.push(valueBit);
bitmask |= valueBit;
}
}
/* numeric sort */

View file

@ -82,7 +82,19 @@ describe('ConfigureWindow', function() {
this.X.LowerWindow(this.wid);
});
it('should ignore invalid mask values', function(done) {
this.X.once('event', function(ev) {
ev.x.should.equal(0);
done();
});
this.X.ConfigureWindow(this.wid, { foo : 3, x : 0 }, function(err) {
console.log(err);
});
});
after(function(done) {
this.X.removeAllListeners('event');
this.X.DestroyWindow(this.wid);
this.X.DestroyWindow(this.wid_helper);
this.X.on('end', done);