Skip to content

Commit 0cc8deb

Browse files
authored
fix(bson-transpilers): account for bson Decimal128 validation changes (#2679)
Refs: mongodb/js-bson#476 Refs: https://jira.mongodb.org/browse/NODE-3815
1 parent 739b9e6 commit 0cc8deb

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

packages/bson-transpilers/test/run-yaml.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ fs.readdirSync(testpath).map((file) => {
9898
continue;
9999
}
100100
if (test.output && output === 'object') { // Can't import libraries from YAML, so un-stringify it first
101-
const expected = executeJavascript(test.output.object);
102101
it(`${input}: ${test.input[input]} => runnable object`, () => {
102+
const expected = executeJavascript(test.output.object);
103103
const actual = transpiler[input].object.compile(test.input[input]);
104104
if (expected && typeof expected === 'object' && '_bsontype' in expected) {
105105
expect(actual._bsontype).to.equal(expected._bsontype);

packages/bson-transpilers/test/yaml/bson-methods.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ tests:
382382
object: new Long(419430400, 0)
383383
Decimal128-methods:
384384
- input:
385-
javascript: new Decimal128(Buffer.from('5')).toString()
385+
javascript: new Decimal128(Buffer.from('5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0')).toString()
386386
output:
387387
python: str(Decimal128('5.3E-6175'))
388388
java: Decimal128.parse("5.3E-6175").toString()

packages/bson-transpilers/test/yaml/bson.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ tests:
363363
Decimal128:
364364
- description: 'buffer arg'
365365
input:
366-
javascript: Decimal128(Buffer.from('5'))
366+
javascript: Decimal128(Buffer.from('5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'))
367367
output:
368368
shell: new NumberDecimal(5.3E-6175)
369369
python: Decimal128('5.3E-6175')
@@ -383,14 +383,14 @@ tests:
383383
object: Decimal128.fromString('5')
384384
- description: 'NEW'
385385
input:
386-
javascript: new Decimal128(Buffer.from('5'))
386+
javascript: new Decimal128(Buffer.from('5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'))
387387
shell: new NumberDecimal('5.3E-6175')
388388
output:
389389
shell: new NumberDecimal(5.3E-6175)
390390
python: Decimal128('5.3E-6175')
391391
java: Decimal128.parse("5.3E-6175")
392392
csharp: Decimal128.Parse("5.3E-6175")
393-
object: new Decimal128(Buffer.from('5'))
393+
object: new Decimal128(Buffer.from('5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'))
394394
- description: 'number arg'
395395
input:
396396
shell: NumberDecimal(5)

packages/bson-transpilers/test/yaml/error-misc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ tests:
218218
errorCode: E_BSONTRANSPILERS_ATTRIBUTE
219219
- description: Decimal128 with invalidMethod
220220
input:
221-
javascript: new Decimal128(Buffer.from('5')).invalidMethod()
221+
javascript: new Decimal128(Buffer.from('5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0')).invalidMethod()
222222
python: Decimal128('1').invalidMethod()
223223
errorCode: E_BSONTRANSPILERS_ATTRIBUTE
224224
- description: Timestamp with invalidMethod

packages/bson-transpilers/test/yaml/imports.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ tests:
296296
- description: Single import NumberDecimal
297297
input:
298298
shell: "{x: NumberDecimal(1)}"
299-
javascript: "{x: Decimal128(1)}"
299+
javascript: "{x: Decimal128.fromString('1')}"
300300
python: "{'x': Decimal128('1')}"
301301
output:
302302
java: |-
@@ -368,7 +368,7 @@ tests:
368368
12: undefined, 100: Code('1', {x: 1}), '100a': Code('!'), 101: ObjectId(),
369369
103: DBRef('c', ObjectId()), 104: Double(1), 105: Int32(1), 106: Long(1, 100),
370370
107: MinKey(), 108: MaxKey(), 110: Timestamp(1, 100), 111: BSONSymbol('1'), 112:
371-
Decimal128([1]), '201a': new Date()}"
371+
Decimal128('1'), '201a': new Date()}"
372372
output:
373373
java: |-
374374
import java.util.regex.Pattern;

packages/bson-transpilers/test/yaml/partial.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ tests:
401401
csharp: 429496729601L >>
402402
shell: new NumberLong(429496729601) >>
403403
- input:
404-
javascript: new Decimal128(Buffer.from('5')).toString
404+
javascript: new Decimal128(Buffer.from('5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0')).toString
405405
output:
406406
javascript: ''
407407
python: str

0 commit comments

Comments
 (0)