Sha256: eec9de22f0bc8432540654557abbc217f431b1ba186dd81c7e92485d507ab095

Contents?: true

Size: 855 Bytes

Versions: 19

Compression:

Stored size: 855 Bytes

Contents

use magnus::RArray;

#[test]
fn can_get_slice_from_r_attay() {
    let ruby = unsafe { magnus::embed::init() };

    let ary: RArray = ruby.eval(r#"[1, nil, "foo"]"#).unwrap();
    let slice = unsafe { ary.as_slice() };

    assert_eq!(3, slice.len());
    assert_eq!("1", format!("{:?}", slice[0]));
    assert_eq!("nil", format!("{:?}", slice[1]));
    assert_eq!(r#""foo""#, format!("{:?}", slice[2]));

    let ary: RArray = ruby
        .eval(r#"["bar", "baz", 42, [1, 2, 3], :test]"#)
        .unwrap();
    let slice = unsafe { ary.as_slice() };

    assert_eq!(5, slice.len());
    assert_eq!(r#""bar""#, format!("{:?}", slice[0]));
    assert_eq!(r#""baz""#, format!("{:?}", slice[1]));
    assert_eq!("42", format!("{:?}", slice[2]));
    assert_eq!("[1, 2, 3]", format!("{:?}", slice[3]));
    assert_eq!(":test", format!("{:?}", slice[4]));
}

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/magnus-0.7.1/tests/array_slice.rs
wasmtime-28.0.0 ./ext/cargo-vendor/magnus-0.7.1/tests/array_slice.rs
wasmtime-27.0.0 ./ext/cargo-vendor/magnus-0.7.1/tests/array_slice.rs
wasmtime-26.0.0 ./ext/cargo-vendor/magnus-0.7.1/tests/array_slice.rs
wasmtime-25.0.2 ./ext/cargo-vendor/magnus-0.6.4/tests/array_slice.rs
wasmtime-25.0.1 ./ext/cargo-vendor/magnus-0.6.4/tests/array_slice.rs
wasmtime-25.0.0 ./ext/cargo-vendor/magnus-0.6.4/tests/array_slice.rs
wasmtime-24.0.0 ./ext/cargo-vendor/magnus-0.6.4/tests/array_slice.rs
wasmtime-23.0.2 ./ext/cargo-vendor/magnus-0.6.4/tests/array_slice.rs
wasmtime-22.0.0 ./ext/cargo-vendor/magnus-0.6.4/tests/array_slice.rs
wasmtime-21.0.1 ./ext/cargo-vendor/magnus-0.6.4/tests/array_slice.rs
wasmtime-20.0.2 ./ext/cargo-vendor/magnus-0.6.4/tests/array_slice.rs
wasmtime-20.0.0 ./ext/cargo-vendor/magnus-0.6.4/tests/array_slice.rs
wasmtime-18.0.3 ./ext/cargo-vendor/magnus-0.6.2/tests/array_slice.rs
wasmtime-17.0.1 ./ext/cargo-vendor/magnus-0.6.2/tests/array_slice.rs
wasmtime-17.0.0 ./ext/cargo-vendor/magnus-0.6.2/tests/array_slice.rs
wasmtime-16.0.0 ./ext/cargo-vendor/magnus-0.6.2/tests/array_slice.rs
wasmtime-15.0.1 ./ext/cargo-vendor/magnus-0.6.2/tests/array_slice.rs
wasmtime-15.0.0 ./ext/cargo-vendor/magnus-0.6.2/tests/array_slice.rs