Skip to content

tests: rb: Add type conversion test for ruby loader#822

Open
AshutoshSharma-pixel wants to merge 4 commits into
metacall:developfrom
AshutoshSharma-pixel:ruby-conversion-matrix
Open

tests: rb: Add type conversion test for ruby loader#822
AshutoshSharma-pixel wants to merge 4 commits into
metacall:developfrom
AshutoshSharma-pixel:ruby-conversion-matrix

Conversation

@AshutoshSharma-pixel

Copy link
Copy Markdown

Adds metacall_ruby_conversion_test, modeled after metacall_node_conversion_test.

The test loads an identity function from memory using the rb loader and runs it
against all METACALL_* types, printing the conversion matrix.

Local test output on macOS with Ruby 3.2.2:

Boolean => Boolean
Fixnum => Fixnum
Bignum => Bignum
Float => Float
String => String
Array => Array
NilClass => NilClass

Notable difference from the Node loader: Ruby preserves numeric type granularity
(Fixnum, Bignum, Float remain distinct) whereas Node collapses all numeric types
to METACALL_DOUBLE.

Tested locally with:
cmake -DOPTION_BUILD_LOADERS=ON -DOPTION_BUILD_LOADERS_RB=ON -DOPTION_BUILD_TESTS=ON
cmake --build . --target metacall-ruby-conversion-test
ctest -R metacall-ruby-conversion-test --verbose

[ PASSED ] 1 test

Signed-off-by: Ashutosh Sharma <itsashutosh769@gmail.com>
@viferga

viferga commented Jun 14, 2026

Copy link
Copy Markdown
Member

Running CI

…e conversion matrix

Signed-off-by: Ashutosh Sharma <itsashutosh769@gmail.com>
@viferga

viferga commented Jun 14, 2026

Copy link
Copy Markdown
Member

Add tests please.

…nd buffer round-trips

Signed-off-by: Ashutosh Sharma <itsashutosh769@gmail.com>
@AshutoshSharma-pixel

Copy link
Copy Markdown
Author

added assertions for Bool, Int, Long, Double, String, Array, Map and Buffer round-trips. also implemented Buffer (IO::Buffer), Array and Map serialization/deserialization in rb_loader. all pass locally. [ PASSED ] 1 test

Signed-off-by: Ashutosh Sharma <itsashutosh769@gmail.com>
@AshutoshSharma-pixel

Copy link
Copy Markdown
Author

fixed the ubuntu:jammy build failure ruby/io/buffer.h is only available in Ruby >= 3.0, so I've gated the IO::Buffer include and usage behind RUBY_API_VERSION_MAJOR >= 3. on older Ruby versions the buffer falls back to a plain binary string. also added ruby/version.h to the loader include header to ensure the macro is defined. still passes locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants