Javascript fix issues, unit tests, adding CI#29
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix JavaScript library bugs and add test suite
Summary
This PR fixes two reported bugs in the JavaScript BEVE library and adds a comprehensive test suite with CI integration.
nullandundefinedvalues are now properly handledChanges
Bug Fixes
Issue #9: String parsing fails for strings >= 64 characters
Root cause: Three bugs were identified:
String length encoded as character count instead of byte count (
beve.js)string.length(character count) instead of UTF-8 byte countnew TextEncoder().encode(value).lengthread_compressed()read extra bytes for multi-byte formats (beve.js)Big-endian byte order in
read_compressed()(beve_file.js)Issue #7: TypeError for null/undefined values
Root cause: The
write_valuefunction had no handling fornullorundefined.Fix: Added handling that matches
JSON.stringifybehavior:null→ encodes as BEVE null (type 0, is_bool=0)undefinedat top level → encodes as nullundefinedin arrays → encodes as nullundefinedin object values → property is omitted{}→ now supported (previously threw)Also fixed typed array detection to check all elements are numbers, not just the first.
Test Suite
Added Jest test framework with 80 tests covering:
.beveexample filesCI Integration
Added GitHub Actions workflow (
.github/workflows/test.yml) that:mainand on pull requestsFiles Changed
javascript/beve.jsjavascript/beve_file.jsjavascript/beve.test.jsjavascript/package.jsonjavascript/package-lock.json.github/workflows/test.yml.gitignoreTesting
All 80 tests pass.
Compatibility
.bevefiles continue to work (verified by compatibility tests)