()
| 897 | |
| 898 | #[tokio::test] |
| 899 | async fn test_subarray_partial() { |
| 900 | test_async_with(|ctx| { |
| 901 | Box::pin(async move { |
| 902 | init(&ctx).unwrap(); |
| 903 | ModuleEvaluator::eval_rust::<BufferModule>(ctx.clone(), "buffer") |
| 904 | .await |
| 905 | .unwrap(); |
| 906 | |
| 907 | let data = "hello world".to_string().into_bytes(); |
| 908 | let module = ModuleEvaluator::eval_js( |
| 909 | ctx.clone(), |
| 910 | "test", |
| 911 | r#" |
| 912 | import { Buffer } from 'buffer'; |
| 913 | |
| 914 | export async function test(data) { |
| 915 | let buffer = Buffer.from(data); |
| 916 | let sub = buffer.subarray(0, 5); // "hello" part |
| 917 | return sub.toString(); |
| 918 | } |
| 919 | "#, |
| 920 | ) |
| 921 | .await |
| 922 | .unwrap(); |
| 923 | let result = call_test::<String, _>(&ctx, &module, (data,)).await; |
| 924 | assert_eq!(result, "hello"); |
| 925 | }) |
| 926 | }) |
| 927 | .await; |
| 928 | } |
| 929 | |
| 930 | #[tokio::test] |
| 931 | async fn test_subarray_out_of_bounds() { |
nothing calls this directly
no test coverage detected