Sha256: 3e93a680aad7861ed7d1da7b73232f00fe87cb3fa5a9c326066754feaaa265cd

Contents?: true

Size: 750 Bytes

Versions: 19

Compression:

Stored size: 750 Bytes

Contents

use magnus::Value;

macro_rules! rb_assert {
    ($s:literal) => {
        assert!(magnus::eval::<bool>($s).unwrap())
    };
    ($s:literal, $($rest:tt)*) => {
        let result: bool = magnus::eval!($s, $($rest)*).unwrap();
        assert!(result)
    };
}

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

    let val: Value = magnus::eval!(
        "
    class Test
      def each
         yield 1
         yield 2
         yield 3
      end
    end
    Test.new
    "
    )
    .unwrap();

    let enumerator = val.enumeratorize("each", ());

    rb_assert!("enumerator.next == 1", enumerator);
    rb_assert!("enumerator.next == 2", enumerator);
    rb_assert!("enumerator.next == 3", enumerator);
}

Version data entries

19 entries across 19 versions & 1 rubygems

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