Variable length quantity#995
Conversation
|
This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested. If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos. For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping |
mk-mxp
left a comment
There was a problem hiding this comment.
Wow! A lot of decimal to hex conversion to do here. Fixing the numbers should make all tests pass now.
Well, OK, you have to remove the 32 bit limit from the example.php. That was before we could expect people to have 64 bit machines...
| #[TestDox('Encode a series of integers, producing a series of bytes. -> asymmetric triple byte')] | ||
| public function testEncodeSeriesOfIntegersProducingSeriesOfBytesAsymmetricTripleByte(): void | ||
| { | ||
| $this->assertEquals([0x87, 0xAB, 0x1C], vlq_encode([0x1D6DC])); |
There was a problem hiding this comment.
| $this->assertEquals([0x87, 0xAB, 0x1C], vlq_encode([0x1D6DC])); | |
| $this->assertEquals([0x87, 0xAB, 0x1C], vlq_encode([0x1D59C])); |
| $this->assertEquals([0x00], vlq_decode([0x00])); | ||
| $this->assertEquals([0x40], vlq_decode([0x40])); | ||
| $this->assertEquals([0x7f], vlq_decode([0x7f])); | ||
| $this->assertEquals([0x81, 0xD5, 0xEE, 0x04], vlq_encode([0x357F34])); |
There was a problem hiding this comment.
| $this->assertEquals([0x81, 0xD5, 0xEE, 0x04], vlq_encode([0x357F34])); | |
| $this->assertEquals([0x81, 0xD5, 0xEE, 0x04], vlq_encode([0x357704])); |
| #[TestDox('Encode a series of integers, producing a series of bytes. -> asymmetric quintuple byte')] | ||
| public function testEncodeSeriesOfIntegersProducingSeriesOfBytesAsymmetricQuintupleByte(): void | ||
| { | ||
| $this->assertEquals([0x88, 0xB3, 0x95, 0xC2, 0x05], vlq_encode([0x8665C205])); |
There was a problem hiding this comment.
| $this->assertEquals([0x88, 0xB3, 0x95, 0xC2, 0x05], vlq_encode([0x8665C205])); | |
| $this->assertEquals([0x88, 0xB3, 0x95, 0xC2, 0x05], vlq_encode([0x86656105])); |
| #[TestDox('Decode a series of bytes, producing a series of integers. -> two bytes')] | ||
| public function testDecodeSeriesOfBytesProducingSeriesOfIntegersTwoBytes(): void | ||
| { | ||
| $this->assertEquals([8192], vlq_decode([0xC0, 0x00])); |
There was a problem hiding this comment.
| $this->assertEquals([8192], vlq_decode([0xC0, 0x00])); | |
| $this->assertEquals([0x2000], vlq_decode([0xC0, 0x00])); |
| public function testDecodeSeriesOfBytesProducingSeriesOfIntegersThreeBytes(): void | ||
| { | ||
| $this->expectException(OverflowException::class); | ||
| $this->assertEquals([2097151], vlq_decode([0xFF, 0xFF, 0x7F])); |
There was a problem hiding this comment.
| $this->assertEquals([2097151], vlq_decode([0xFF, 0xFF, 0x7F])); | |
| $this->assertEquals([0x1FFFFF], vlq_decode([0xFF, 0xFF, 0x7F])); |
| #[TestDox('Decode a series of bytes, producing a series of integers. -> four bytes')] | ||
| public function testDecodeSeriesOfBytesProducingSeriesOfIntegersFourBytes(): void | ||
| { | ||
| $this->assertEquals([2097152], vlq_decode([0x81, 0x80, 0x80, 0x00])); |
There was a problem hiding this comment.
| $this->assertEquals([2097152], vlq_decode([0x81, 0x80, 0x80, 0x00])); | |
| $this->assertEquals([0x200000], vlq_decode([0x81, 0x80, 0x80, 0x00])); |
| 0xff, 0xff, 0xff, 0x7f, 0x00, | ||
| 0xff, 0x7f, 0x81, 0x80, 0x00, | ||
| ]; | ||
| $this->assertEquals([4294967295], vlq_decode([0x8F, 0xFF, 0xFF, 0xFF, 0x7F])); |
There was a problem hiding this comment.
| $this->assertEquals([4294967295], vlq_decode([0x8F, 0xFF, 0xFF, 0xFF, 0x7F])); | |
| $this->assertEquals([0xFFFFFFFF], vlq_decode([0x8F, 0xFF, 0xFF, 0xFF, 0x7F])); |
| public function testDecodeSeriesOfBytesProducingSeriesOfIntegersMultipleValues(): void | ||
| { | ||
| $this->assertEquals( | ||
| [8192, 1193046, 268435455, 0, 16383, 16384], |
There was a problem hiding this comment.
| [8192, 1193046, 268435455, 0, 16383, 16384], | |
| [0x2000, 0x123456, 0xFFFFFFF, 0, 0x3FFF, 0x4000], |
This PR updates the PHP track implementation of variable-length-quantity to bring it fully in line with the current canonical data from problem-specifications.
✅ Summary of Changes
Updated exercise metadata using:
configlet sync -u -e variable-length-quantity --yes --docs --filepaths --metadata --tests include
Ensured Markdown instructions and .meta files reflect the latest canonical content.
Resolved the previously unsynced instructions.md.
Removed unnecessary // strict_types comments from:
Test file
Example solution
Preserved the directive itself (declare(strict_types=1);) as required for PHP track consistency.
Left the comment intact in the student stub file, per track conventions.
Added missing UUIDs to test DocBlocks.
Updated all #[TestDox] annotations to match canonical descriptions exactly.
Ensured every test case corresponds 1:1 with the canonical JSON.
Renamed all test methods to reflect the full canonical description for clarity and consistency.
Ensured naming is deterministic and generator‑friendly.
Inserted variable-length-quantity alphabetically to keep the file properly ordered.
Ensures future syncs will include this exercise automatically.
Verified all test cases match canonical order.
Removed outdated patterns and ensured full alignment with current problem-specifications.
Confirmed no missing or duplicated tests.
Added my GitHub handle to .meta/config.json as a contributor to this exercise.