()
| 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 | } |
nothing calls this directly
no test coverage detected