Sha256: 7c5a38ed28bf9678108defca7b88ecc4bcdf3d39d08f553f147ef945e396a335

Contents?: true

Size: 826 Bytes

Versions: 19

Compression:

Stored size: 826 Bytes

Contents

use magnus::prelude::*;

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

    assert!(ruby.str_new("example").enc_get() == ruby.utf8_encindex());

    assert!(ruby.sym_new("example").enc_get() == ruby.usascii_encindex());
    assert!(ruby.to_symbol("example").enc_get() == ruby.usascii_encindex());

    // symbol upgrades to utf8 when required
    assert!(ruby.sym_new("🦀").enc_get() == ruby.utf8_encindex());
    assert!(ruby.to_symbol("🦀").enc_get() == ruby.utf8_encindex());

    let regexp = ruby.reg_new("example", Default::default()).unwrap();
    assert!(regexp.enc_get() == ruby.usascii_encindex());

    // regexp also upgrades to utf8 when needed
    let regexp = ruby.reg_new("🦀", Default::default()).unwrap();
    assert!(regexp.enc_get() == ruby.utf8_encindex());
}

Version data entries

19 entries across 19 versions & 1 rubygems

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