-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support Number object in Int32 and Double constructors
Numbers objects deserve the same love and support as their primitive counterparts. So handle them appropriately without introducing regressions into behaviors of other types that may be passed in as values Fixes NODE-2384
- Loading branch information
Showing
4 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
const BSON = require('../../lib/bson'); | ||
const Double = BSON.Double; | ||
const expect = require('chai').expect; | ||
|
||
describe('Double', function() { | ||
describe('Constructor', function() { | ||
var value = 42.3456; | ||
|
||
it('Primitive number', function(done) { | ||
expect(new Double(value).valueOf()).to.equal(value); | ||
done(); | ||
}); | ||
|
||
it('Number object', function(done) { | ||
expect(new Double(new Number(value)).valueOf()).to.equal(value); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
const BSON = require('../../lib/bson'); | ||
const Int32 = BSON.Int32; | ||
const expect = require('chai').expect; | ||
|
||
describe('Int32', function() { | ||
describe('Constructor', function() { | ||
var value = 42; | ||
|
||
it('Primitive number', function(done) { | ||
expect(new Int32(value).valueOf()).to.equal(value); | ||
done(); | ||
}); | ||
|
||
it('Number object', function(done) { | ||
expect(new Int32(new Number(value)).valueOf()).to.equal(value); | ||
done(); | ||
}); | ||
}); | ||
}); |