Skip to content

fix(bson-transpilers): account for bson Decimal128 validation changes #2679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/bson-transpilers/test/run-yaml.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/bson-transpilers/test/yaml/bson-methods.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions packages/bson-transpilers/test/yaml/bson.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/bson-transpilers/test/yaml/error-misc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/bson-transpilers/test/yaml/imports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |-
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/bson-transpilers/test/yaml/partial.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down