()
| 938 | assert_eq!(result, "world"); |
| 939 | }) |
| 940 | }) |
| 941 | .await; |
| 942 | } |
| 943 | |
| 944 | #[tokio::test] |
| 945 | async fn test_subarray_partial() { |
| 946 | test_async_with(|ctx| { |
| 947 | Box::pin(async move { |
| 948 | crate::init(&ctx).unwrap(); |
| 949 | ModuleEvaluator::eval_rust::<BufferModule>(ctx.clone(), "buffer") |
| 950 | .await |
| 951 | .unwrap(); |
| 952 | |
| 953 | let data = "hello world".to_string().into_bytes(); |
| 954 | let module = ModuleEvaluator::eval_js( |
| 955 | ctx.clone(), |
| 956 | "test", |
| 957 | r#" |
| 958 | import { Buffer } from 'buffer'; |
| 959 | |
| 960 | export async function test(data) { |
| 961 | let buffer = Buffer.from(data); |
| 962 | let sub = buffer.subarray(0, 5); // "hello" part |
| 963 | return sub.toString(); |
| 964 | } |
| 965 | "#, |
| 966 | ) |
| 967 | .await |
| 968 | .unwrap(); |
| 969 | let result = call_test::<String, _>(&ctx, &module, (data,)).await; |
| 970 | assert_eq!(result, "hello"); |
| 971 | }) |
| 972 | }) |
nothing calls this directly
no test coverage detected