Skip to content

POC for DRIVERS-2651: Add decimal128 clamped zeros tests with very large exponents #1433

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

Closed
wants to merge 1 commit into from
Closed
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
24 changes: 12 additions & 12 deletions tests/bson-corpus/decimal128-5-valid-027.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Decimal128: [decq414] clamped zeros... (Clamped)
Decimal128: clamped zeros with a large negative exponent
--DESCRIPTION--
Generated by scripts/convert-bson-corpus-tests.php

Expand All @@ -9,9 +9,9 @@ DO NOT EDIT THIS FILE

require_once __DIR__ . '/../utils/basic.inc';

$canonicalBson = hex2bin('180000001364000000000000000000000000000000FE5F00');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "0E+6111"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "0E+6112"}}';
$canonicalBson = hex2bin('180000001364000000000000000000000000000000000000');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "0E-6176"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "0E-999999999999"}}';

// Canonical BSON -> Native -> Canonical BSON
echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n";
Expand Down Expand Up @@ -41,12 +41,12 @@ echo bin2hex((string) MongoDB\BSON\Document::fromJSON($degenerateExtJson)), "\n"
===DONE===
<?php exit(0); ?>
--EXPECT--
180000001364000000000000000000000000000000fe5f00
180000001364000000000000000000000000000000fe5f00
{"d":{"$numberDecimal":"0E+6111"}}
{"d":{"$numberDecimal":"0E+6111"}}
180000001364000000000000000000000000000000fe5f00
180000001364000000000000000000000000000000fe5f00
180000001364000000000000000000000000000000fe5f00
180000001364000000000000000000000000000000fe5f00
180000001364000000000000000000000000000000000000
180000001364000000000000000000000000000000000000
{"d":{"$numberDecimal":"0E-6176"}}
{"d":{"$numberDecimal":"0E-6176"}}
180000001364000000000000000000000000000000000000
180000001364000000000000000000000000000000000000
180000001364000000000000000000000000000000000000
180000001364000000000000000000000000000000000000
===DONE===
4 changes: 2 additions & 2 deletions tests/bson-corpus/decimal128-5-valid-028.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Decimal128: [decq416] clamped zeros... (Clamped)
Decimal128: [decq414] clamped zeros... (Clamped)
--DESCRIPTION--
Generated by scripts/convert-bson-corpus-tests.php

Expand All @@ -11,7 +11,7 @@ require_once __DIR__ . '/../utils/basic.inc';

$canonicalBson = hex2bin('180000001364000000000000000000000000000000FE5F00');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "0E+6111"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "0E+6144"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "0E+6112"}}';

// Canonical BSON -> Native -> Canonical BSON
echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n";
Expand Down
4 changes: 2 additions & 2 deletions tests/bson-corpus/decimal128-5-valid-029.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Decimal128: [decq418] clamped zeros... (Clamped)
Decimal128: [decq416] clamped zeros... (Clamped)
--DESCRIPTION--
Generated by scripts/convert-bson-corpus-tests.php

Expand All @@ -11,7 +11,7 @@ require_once __DIR__ . '/../utils/basic.inc';

$canonicalBson = hex2bin('180000001364000000000000000000000000000000FE5F00');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "0E+6111"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "0E+8000"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "0E+6144"}}';

// Canonical BSON -> Native -> Canonical BSON
echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n";
Expand Down
24 changes: 12 additions & 12 deletions tests/bson-corpus/decimal128-5-valid-030.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Decimal128: [decq420] negative zeros (Clamped)
Decimal128: [decq418] clamped zeros... (Clamped)
--DESCRIPTION--
Generated by scripts/convert-bson-corpus-tests.php

Expand All @@ -9,9 +9,9 @@ DO NOT EDIT THIS FILE

require_once __DIR__ . '/../utils/basic.inc';

$canonicalBson = hex2bin('180000001364000000000000000000000000000000008000');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "-0E-6176"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "-0E-8000"}}';
$canonicalBson = hex2bin('180000001364000000000000000000000000000000FE5F00');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "0E+6111"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "0E+8000"}}';

// Canonical BSON -> Native -> Canonical BSON
echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n";
Expand Down Expand Up @@ -41,12 +41,12 @@ echo bin2hex((string) MongoDB\BSON\Document::fromJSON($degenerateExtJson)), "\n"
===DONE===
<?php exit(0); ?>
--EXPECT--
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
{"d":{"$numberDecimal":"-0E-6176"}}
{"d":{"$numberDecimal":"-0E-6176"}}
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000fe5f00
180000001364000000000000000000000000000000fe5f00
{"d":{"$numberDecimal":"0E+6111"}}
{"d":{"$numberDecimal":"0E+6111"}}
180000001364000000000000000000000000000000fe5f00
180000001364000000000000000000000000000000fe5f00
180000001364000000000000000000000000000000fe5f00
180000001364000000000000000000000000000000fe5f00
===DONE===
24 changes: 12 additions & 12 deletions tests/bson-corpus/decimal128-5-valid-031.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Decimal128: [decq421] negative zeros (Clamped)
Decimal128: clamped zeros with a large positive exponent
--DESCRIPTION--
Generated by scripts/convert-bson-corpus-tests.php

Expand All @@ -9,9 +9,9 @@ DO NOT EDIT THIS FILE

require_once __DIR__ . '/../utils/basic.inc';

$canonicalBson = hex2bin('180000001364000000000000000000000000000000008000');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "-0E-6176"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "-0E-6177"}}';
$canonicalBson = hex2bin('180000001364000000000000000000000000000000FE5F00');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "0E+6111"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "0E+999999999999"}}';

// Canonical BSON -> Native -> Canonical BSON
echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n";
Expand Down Expand Up @@ -41,12 +41,12 @@ echo bin2hex((string) MongoDB\BSON\Document::fromJSON($degenerateExtJson)), "\n"
===DONE===
<?php exit(0); ?>
--EXPECT--
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
{"d":{"$numberDecimal":"-0E-6176"}}
{"d":{"$numberDecimal":"-0E-6176"}}
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000fe5f00
180000001364000000000000000000000000000000fe5f00
{"d":{"$numberDecimal":"0E+6111"}}
{"d":{"$numberDecimal":"0E+6111"}}
180000001364000000000000000000000000000000fe5f00
180000001364000000000000000000000000000000fe5f00
180000001364000000000000000000000000000000fe5f00
180000001364000000000000000000000000000000fe5f00
===DONE===
24 changes: 12 additions & 12 deletions tests/bson-corpus/decimal128-5-valid-032.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Decimal128: [decq434] clamped zeros... (Clamped)
Decimal128: [decq420] negative zeros (Clamped)
--DESCRIPTION--
Generated by scripts/convert-bson-corpus-tests.php

Expand All @@ -9,9 +9,9 @@ DO NOT EDIT THIS FILE

require_once __DIR__ . '/../utils/basic.inc';

$canonicalBson = hex2bin('180000001364000000000000000000000000000000FEDF00');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "-0E+6111"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "-0E+6112"}}';
$canonicalBson = hex2bin('180000001364000000000000000000000000000000008000');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "-0E-6176"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "-0E-8000"}}';

// Canonical BSON -> Native -> Canonical BSON
echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n";
Expand Down Expand Up @@ -41,12 +41,12 @@ echo bin2hex((string) MongoDB\BSON\Document::fromJSON($degenerateExtJson)), "\n"
===DONE===
<?php exit(0); ?>
--EXPECT--
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
{"d":{"$numberDecimal":"-0E+6111"}}
{"d":{"$numberDecimal":"-0E+6111"}}
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
{"d":{"$numberDecimal":"-0E-6176"}}
{"d":{"$numberDecimal":"-0E-6176"}}
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
===DONE===
24 changes: 12 additions & 12 deletions tests/bson-corpus/decimal128-5-valid-033.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Decimal128: [decq436] clamped zeros... (Clamped)
Decimal128: [decq421] negative zeros (Clamped)
--DESCRIPTION--
Generated by scripts/convert-bson-corpus-tests.php

Expand All @@ -9,9 +9,9 @@ DO NOT EDIT THIS FILE

require_once __DIR__ . '/../utils/basic.inc';

$canonicalBson = hex2bin('180000001364000000000000000000000000000000FEDF00');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "-0E+6111"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "-0E+6144"}}';
$canonicalBson = hex2bin('180000001364000000000000000000000000000000008000');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "-0E-6176"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "-0E-6177"}}';

// Canonical BSON -> Native -> Canonical BSON
echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n";
Expand Down Expand Up @@ -41,12 +41,12 @@ echo bin2hex((string) MongoDB\BSON\Document::fromJSON($degenerateExtJson)), "\n"
===DONE===
<?php exit(0); ?>
--EXPECT--
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
{"d":{"$numberDecimal":"-0E+6111"}}
{"d":{"$numberDecimal":"-0E+6111"}}
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
{"d":{"$numberDecimal":"-0E-6176"}}
{"d":{"$numberDecimal":"-0E-6176"}}
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
===DONE===
24 changes: 12 additions & 12 deletions tests/bson-corpus/decimal128-5-valid-034.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Decimal128: [decq438] clamped zeros... (Clamped)
Decimal128: clamped negative zeros with a large negative exponent
--DESCRIPTION--
Generated by scripts/convert-bson-corpus-tests.php

Expand All @@ -9,9 +9,9 @@ DO NOT EDIT THIS FILE

require_once __DIR__ . '/../utils/basic.inc';

$canonicalBson = hex2bin('180000001364000000000000000000000000000000FEDF00');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "-0E+6111"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "-0E+8000"}}';
$canonicalBson = hex2bin('180000001364000000000000000000000000000000008000');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "-0E-6176"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "-0E-999999999999"}}';

// Canonical BSON -> Native -> Canonical BSON
echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n";
Expand Down Expand Up @@ -41,12 +41,12 @@ echo bin2hex((string) MongoDB\BSON\Document::fromJSON($degenerateExtJson)), "\n"
===DONE===
<?php exit(0); ?>
--EXPECT--
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
{"d":{"$numberDecimal":"-0E+6111"}}
{"d":{"$numberDecimal":"-0E+6111"}}
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
{"d":{"$numberDecimal":"-0E-6176"}}
{"d":{"$numberDecimal":"-0E-6176"}}
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
180000001364000000000000000000000000000000008000
===DONE===
24 changes: 12 additions & 12 deletions tests/bson-corpus/decimal128-5-valid-035.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Decimal128: [decq601] fold-down full sequence (Clamped)
Decimal128: [decq434] clamped zeros... (Clamped)
--DESCRIPTION--
Generated by scripts/convert-bson-corpus-tests.php

Expand All @@ -9,9 +9,9 @@ DO NOT EDIT THIS FILE

require_once __DIR__ . '/../utils/basic.inc';

$canonicalBson = hex2bin('18000000136400000000000A5BC138938D44C64D31FE5F00');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "1.000000000000000000000000000000000E+6144"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "1E+6144"}}';
$canonicalBson = hex2bin('180000001364000000000000000000000000000000FEDF00');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "-0E+6111"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "-0E+6112"}}';

// Canonical BSON -> Native -> Canonical BSON
echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n";
Expand Down Expand Up @@ -41,12 +41,12 @@ echo bin2hex((string) MongoDB\BSON\Document::fromJSON($degenerateExtJson)), "\n"
===DONE===
<?php exit(0); ?>
--EXPECT--
18000000136400000000000a5bc138938d44c64d31fe5f00
18000000136400000000000a5bc138938d44c64d31fe5f00
{"d":{"$numberDecimal":"1.000000000000000000000000000000000E+6144"}}
{"d":{"$numberDecimal":"1.000000000000000000000000000000000E+6144"}}
18000000136400000000000a5bc138938d44c64d31fe5f00
18000000136400000000000a5bc138938d44c64d31fe5f00
18000000136400000000000a5bc138938d44c64d31fe5f00
18000000136400000000000a5bc138938d44c64d31fe5f00
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
{"d":{"$numberDecimal":"-0E+6111"}}
{"d":{"$numberDecimal":"-0E+6111"}}
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
===DONE===
24 changes: 12 additions & 12 deletions tests/bson-corpus/decimal128-5-valid-036.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Decimal128: [decq603] fold-down full sequence (Clamped)
Decimal128: [decq436] clamped zeros... (Clamped)
--DESCRIPTION--
Generated by scripts/convert-bson-corpus-tests.php

Expand All @@ -9,9 +9,9 @@ DO NOT EDIT THIS FILE

require_once __DIR__ . '/../utils/basic.inc';

$canonicalBson = hex2bin('180000001364000000000081EFAC855B416D2DEE04FE5F00');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "1.00000000000000000000000000000000E+6143"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "1E+6143"}}';
$canonicalBson = hex2bin('180000001364000000000000000000000000000000FEDF00');
$canonicalExtJson = '{"d" : {"$numberDecimal" : "-0E+6111"}}';
$degenerateExtJson = '{"d" : {"$numberDecimal" : "-0E+6144"}}';

// Canonical BSON -> Native -> Canonical BSON
echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n";
Expand Down Expand Up @@ -41,12 +41,12 @@ echo bin2hex((string) MongoDB\BSON\Document::fromJSON($degenerateExtJson)), "\n"
===DONE===
<?php exit(0); ?>
--EXPECT--
180000001364000000000081efac855b416d2dee04fe5f00
180000001364000000000081efac855b416d2dee04fe5f00
{"d":{"$numberDecimal":"1.00000000000000000000000000000000E+6143"}}
{"d":{"$numberDecimal":"1.00000000000000000000000000000000E+6143"}}
180000001364000000000081efac855b416d2dee04fe5f00
180000001364000000000081efac855b416d2dee04fe5f00
180000001364000000000081efac855b416d2dee04fe5f00
180000001364000000000081efac855b416d2dee04fe5f00
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
{"d":{"$numberDecimal":"-0E+6111"}}
{"d":{"$numberDecimal":"-0E+6111"}}
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
180000001364000000000000000000000000000000fedf00
===DONE===
Loading