MCPcopy Create free account
hub / github.com/awslabs/llrt / test_to_object

Function test_to_object

modules/llrt_stream_web/src/readable/iterator.rs:663–696  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

661
662 #[tokio::test]
663 async fn test_to_object() {
664 test_sync_with(|ctx| {
665 BasePrimordials::init(&ctx)?;
666 let good_values: [Value; 7] = [
667 Value::new_bool(ctx.clone(), false),
668 Value::new_int(ctx.clone(), 123),
669 Value::new_float(ctx.clone(), 1.5),
670 rquickjs::String::from_str(ctx.clone(), "abc")?.into_value(),
671 Symbol::new_global(ctx.clone(), "def")?.into_value(),
672 BigInt::from_i64(ctx.clone(), 123456)?.into_value(),
673 Object::new(ctx.clone())?.into_value(),
674 ];
675
676 for value in good_values {
677 to_object(&ctx, value)?;
678 }
679
680 let bad_values: [Value; 3] = [
681 Value::new_uninitialized(ctx.clone()),
682 Value::new_undefined(ctx.clone()),
683 Value::new_null(ctx.clone()),
684 ];
685
686 for value in bad_values {
687 let ty = value.type_of();
688 if to_object(&ctx, value).is_ok() {
689 panic!("Values of type {ty} should not be convertible to object")
690 }
691 }
692
693 Ok(())
694 })
695 .await;
696 }
697}

Callers

nothing calls this directly

Calls 5

test_sync_withFunction · 0.85
to_objectFunction · 0.85
initFunction · 0.50
cloneMethod · 0.45
into_valueMethod · 0.45

Tested by

no test coverage detected