()
| 865 | |
| 866 | #[tokio::test] |
| 867 | async fn test_subarray() { |
| 868 | test_async_with(|ctx| { |
| 869 | Box::pin(async move { |
| 870 | init(&ctx).unwrap(); |
| 871 | ModuleEvaluator::eval_rust::<BufferModule>(ctx.clone(), "buffer") |
| 872 | .await |
| 873 | .unwrap(); |
| 874 | |
| 875 | let data = "hello world".to_string().into_bytes(); |
| 876 | let module = ModuleEvaluator::eval_js( |
| 877 | ctx.clone(), |
| 878 | "test", |
| 879 | r#" |
| 880 | import { Buffer } from 'buffer'; |
| 881 | |
| 882 | export async function test(data) { |
| 883 | let buffer = Buffer.from(data); |
| 884 | let sub = buffer.subarray(6, 11); // "world" part |
| 885 | return sub.toString(); |
| 886 | } |
| 887 | "#, |
| 888 | ) |
| 889 | .await |
| 890 | .unwrap(); |
| 891 | let result = call_test::<String, _>(&ctx, &module, (data,)).await; |
| 892 | assert_eq!(result, "world"); |
| 893 | }) |
| 894 | }) |
| 895 | .await; |
| 896 | } |
| 897 | |
| 898 | #[tokio::test] |
| 899 | async fn test_subarray_partial() { |
nothing calls this directly
no test coverage detected