diff --git a/packages/bson-transpilers/test/run-yaml.test.js b/packages/bson-transpilers/test/run-yaml.test.js index 0ca2dbf4be1..8a66e3c54fa 100644 --- a/packages/bson-transpilers/test/run-yaml.test.js +++ b/packages/bson-transpilers/test/run-yaml.test.js @@ -98,8 +98,8 @@ fs.readdirSync(testpath).map((file) => { continue; } if (test.output && output === 'object') { // Can't import libraries from YAML, so un-stringify it first - const expected = executeJavascript(test.output.object); it(`${input}: ${test.input[input]} => runnable object`, () => { + const expected = executeJavascript(test.output.object); const actual = transpiler[input].object.compile(test.input[input]); if (expected && typeof expected === 'object' && '_bsontype' in expected) { expect(actual._bsontype).to.equal(expected._bsontype); diff --git a/packages/bson-transpilers/test/yaml/bson-methods.yaml b/packages/bson-transpilers/test/yaml/bson-methods.yaml index bc01a955100..575cfc1ab9d 100644 --- a/packages/bson-transpilers/test/yaml/bson-methods.yaml +++ b/packages/bson-transpilers/test/yaml/bson-methods.yaml @@ -382,7 +382,7 @@ tests: object: new Long(419430400, 0) Decimal128-methods: - input: - javascript: new Decimal128(Buffer.from('5')).toString() + javascript: new Decimal128(Buffer.from('5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0')).toString() output: python: str(Decimal128('5.3E-6175')) java: Decimal128.parse("5.3E-6175").toString() diff --git a/packages/bson-transpilers/test/yaml/bson.yaml b/packages/bson-transpilers/test/yaml/bson.yaml index f3b79d1ea64..93691b9b3f6 100644 --- a/packages/bson-transpilers/test/yaml/bson.yaml +++ b/packages/bson-transpilers/test/yaml/bson.yaml @@ -363,7 +363,7 @@ tests: Decimal128: - description: 'buffer arg' input: - javascript: Decimal128(Buffer.from('5')) + javascript: Decimal128(Buffer.from('5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0')) output: shell: new NumberDecimal(5.3E-6175) python: Decimal128('5.3E-6175') @@ -383,14 +383,14 @@ tests: object: Decimal128.fromString('5') - description: 'NEW' input: - javascript: new Decimal128(Buffer.from('5')) + javascript: new Decimal128(Buffer.from('5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0')) shell: new NumberDecimal('5.3E-6175') output: shell: new NumberDecimal(5.3E-6175) python: Decimal128('5.3E-6175') java: Decimal128.parse("5.3E-6175") csharp: Decimal128.Parse("5.3E-6175") - object: new Decimal128(Buffer.from('5')) + object: new Decimal128(Buffer.from('5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0')) - description: 'number arg' input: shell: NumberDecimal(5) diff --git a/packages/bson-transpilers/test/yaml/error-misc.yaml b/packages/bson-transpilers/test/yaml/error-misc.yaml index d2515a3fce7..6e1c4fcb9be 100644 --- a/packages/bson-transpilers/test/yaml/error-misc.yaml +++ b/packages/bson-transpilers/test/yaml/error-misc.yaml @@ -218,7 +218,7 @@ tests: errorCode: E_BSONTRANSPILERS_ATTRIBUTE - description: Decimal128 with invalidMethod input: - javascript: new Decimal128(Buffer.from('5')).invalidMethod() + javascript: new Decimal128(Buffer.from('5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0')).invalidMethod() python: Decimal128('1').invalidMethod() errorCode: E_BSONTRANSPILERS_ATTRIBUTE - description: Timestamp with invalidMethod diff --git a/packages/bson-transpilers/test/yaml/imports.yaml b/packages/bson-transpilers/test/yaml/imports.yaml index 1474e2d41ac..2c2d1e6521b 100644 --- a/packages/bson-transpilers/test/yaml/imports.yaml +++ b/packages/bson-transpilers/test/yaml/imports.yaml @@ -296,7 +296,7 @@ tests: - description: Single import NumberDecimal input: shell: "{x: NumberDecimal(1)}" - javascript: "{x: Decimal128(1)}" + javascript: "{x: Decimal128.fromString('1')}" python: "{'x': Decimal128('1')}" output: java: |- @@ -368,7 +368,7 @@ tests: 12: undefined, 100: Code('1', {x: 1}), '100a': Code('!'), 101: ObjectId(), 103: DBRef('c', ObjectId()), 104: Double(1), 105: Int32(1), 106: Long(1, 100), 107: MinKey(), 108: MaxKey(), 110: Timestamp(1, 100), 111: BSONSymbol('1'), 112: - Decimal128([1]), '201a': new Date()}" + Decimal128('1'), '201a': new Date()}" output: java: |- import java.util.regex.Pattern; diff --git a/packages/bson-transpilers/test/yaml/partial.yaml b/packages/bson-transpilers/test/yaml/partial.yaml index dc5a8c949ec..2f26414969f 100644 --- a/packages/bson-transpilers/test/yaml/partial.yaml +++ b/packages/bson-transpilers/test/yaml/partial.yaml @@ -401,7 +401,7 @@ tests: csharp: 429496729601L >> shell: new NumberLong(429496729601) >> - input: - javascript: new Decimal128(Buffer.from('5')).toString + javascript: new Decimal128(Buffer.from('5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0')).toString output: javascript: '' python: str