Sha256: bafc9e58c38dc2bf0c539408f82374b23bcbfe4ca83884fc03b1f581bd93aefd

Contents?: true

Size: 905 Bytes

Versions: 19

Compression:

Stored size: 905 Bytes

Contents

use magnus::{
    encoding::{self, EncodingCapable},
    eval, RRegexp, RString, StaticSymbol, Symbol,
};

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

    assert!(RString::new("example").enc_get() == encoding::Index::utf8());

    assert!(StaticSymbol::new("example").enc_get() == encoding::Index::usascii());
    assert!(Symbol::new("example").enc_get() == encoding::Index::usascii());

    // symbol upgrades to utf8 when required
    assert!(StaticSymbol::new("🦀").enc_get() == encoding::Index::utf8());
    assert!(Symbol::new("🦀").enc_get() == encoding::Index::utf8());

    let regexp: RRegexp = eval!("/example/").unwrap();
    assert!(regexp.enc_get() == encoding::Index::usascii());

    // regexp also upgrades to utf8 when needed
    let regexp: RRegexp = eval!("/🦀/").unwrap();
    assert!(regexp.enc_get() == encoding::Index::utf8());
}

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
wasmtime-14.0.4 ./ext/cargo-vendor/magnus-0.5.5/tests/encoding_capable.rs
wasmtime-14.0.3 ./ext/cargo-vendor/magnus-0.5.5/tests/encoding_capable.rs
wasmtime-14.0.1 ./ext/cargo-vendor/magnus-0.5.5/tests/encoding_capable.rs
wasmtime-14.0.0 ./ext/cargo-vendor/magnus-0.5.5/tests/encoding_capable.rs
wasmtime-13.0.0 ./ext/cargo-vendor/magnus-0.5.5/tests/encoding_capable.rs
wasmtime-12.0.1 ./ext/cargo-vendor/magnus-0.5.5/tests/encoding_capable.rs
wasmtime-12.0.0 ./ext/cargo-vendor/magnus-0.5.5/tests/encoding_capable.rs
wasmtime-11.0.0 ./ext/cargo-vendor/magnus-0.5.5/tests/encoding_capable.rs
wasmtime-10.0.1 ./ext/cargo-vendor/magnus-0.5.5/tests/encoding_capable.rs
wasmtime-10.0.0 ./ext/cargo-vendor/magnus-0.5.5/tests/encoding_capable.rs
wasmtime-9.0.4 ./ext/cargo-vendor/magnus-0.5.5/tests/encoding_capable.rs
wasmtime-9.0.1 ./ext/cargo-vendor/magnus-0.5.3/tests/encoding_capable.rs
wasmtime-8.0.0 ./ext/cargo-vendor/magnus-0.5.3/tests/encoding_capable.rs
wasmtime-7.0.0 ./ext/cargo-vendor/magnus-0.5.2/tests/encoding_capable.rs
wasmtime-6.0.1 ./ext/cargo-vendor/magnus-0.5.1/tests/encoding_capable.rs
wasmtime-6.0.0 ./ext/cargo-vendor/magnus-0.5.1/tests/encoding_capable.rs
wasmtime-5.0.0 ./ext/cargo-vendor/magnus-0.4.4/tests/encoding_capable.rs
wasmtime-0.4.1 ./ext/cargo-vendor/magnus-0.4.4/tests/encoding_capable.rs
wasmtime-0.4.0 ./ext/cargo-vendor/magnus-0.4.3/tests/encoding_capable.rs