mirror of
https://github.com/fluencelabs/marine-rs-sdk-test
synced 2024-12-04 15:20:18 +00:00
add tests
This commit is contained in:
parent
12685c59fc
commit
d1d52e8b69
@ -76,7 +76,7 @@ use std::path::PathBuf;
|
||||
/// let tmp_dir = tmp_dir.to_string_lossy().to_string();
|
||||
/// std::fs::create_dir(&tmp_dir).expect("can't create a directory for service in tmp");
|
||||
///
|
||||
/// let mut __fce__generated_fce_config = fluence_test::internal::TomlAppServiceConfig::load("/path/to/greeting/Config.toml".to_string())
|
||||
/// let mut __fce_generated_fce_config = fluence_test::internal::TomlAppServiceConfig::load("/path/to/greeting/Config.toml".to_string())
|
||||
/// .unwrap_or_else(|e| {
|
||||
/// panic!(
|
||||
/// "app service located at `{}` config can't be loaded: {}",
|
||||
@ -84,10 +84,10 @@ use std::path::PathBuf;
|
||||
/// )
|
||||
/// });
|
||||
///
|
||||
/// __fce__generated_fce_config.service_base_dir = Some("/path/to/tmp".to_string());
|
||||
/// __fce_generated_fce_config.service_base_dir = Some("/path/to/tmp".to_string());
|
||||
///
|
||||
/// let fce = fluence_test::internal::AppService::new_with_empty_facade(
|
||||
/// __fce__generated_fce_config,
|
||||
/// __fce_generated_fce_config,
|
||||
/// "3640e972-92e3-47cb-b95f-4e3c5bcf0f14",
|
||||
/// std::collections::HashMap::new(),
|
||||
/// ).unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
||||
|
@ -130,7 +130,10 @@ fn generate_type_lifting_prolog(
|
||||
},
|
||||
ParsedType::Vector(ty, _) => {
|
||||
let generated_deserializer_name =
|
||||
format!("__fce_generated_vec_deserializer_{}", supplied_arg_start_id);
|
||||
format!("__fce_generated_vec_deserializer_{}", supplied_arg_start_id)
|
||||
.replace("&", "_")
|
||||
.replace("<", "_")
|
||||
.replace(">", "_");
|
||||
let generated_deserializer_ident = new_ident!(generated_deserializer_name);
|
||||
let vector_deserializer = super::vector_utils::generate_vector_deserializer(
|
||||
ty,
|
||||
|
@ -64,10 +64,8 @@ impl ForeignModPrologGlueCodeGenerator for Vec<AstFuncArgument> {
|
||||
use crate::parsed_type::foreign_mod_arg::ForeignModArgGlueCodeGenerator;
|
||||
use quote::ToTokens;
|
||||
|
||||
let arg_types: Vec<proc_macro2::TokenStream> = self
|
||||
.iter()
|
||||
.map(|arg| arg.ty.to_token_stream())
|
||||
.collect();
|
||||
let arg_types: Vec<proc_macro2::TokenStream> =
|
||||
self.iter().map(|arg| arg.ty.to_token_stream()).collect();
|
||||
|
||||
let (arg_names, arg_transforms, arg_drops) = self
|
||||
.iter()
|
||||
@ -84,7 +82,7 @@ impl ForeignModPrologGlueCodeGenerator for Vec<AstFuncArgument> {
|
||||
arg_drops.extend(quote::quote! { std::mem::ManuallyDrop::drop(&mut #arg_ident); });
|
||||
},
|
||||
ParsedType::Vector(ty, _) => {
|
||||
let generated_serializer_name = format!("__fce_generated_vec_serializer_{}", arg_name);
|
||||
let generated_serializer_name = format!("__fce_generated_vec_serializer_{}", arg_name).replace("&<>", "_");
|
||||
|
||||
let generated_serializer_ident = new_ident!(generated_serializer_name);
|
||||
let vector_serializer = super::vector_utils::generate_vector_serializer(ty, &generated_serializer_name);
|
||||
|
@ -91,7 +91,10 @@ fn generate_vector_serializer_impl(
|
||||
}
|
||||
}
|
||||
ParsedType::Vector(ty, _) => {
|
||||
let serializer_name = format!("{}_{}", arg_name, ty);
|
||||
let serializer_name = format!("{}_{}", arg_name, ty)
|
||||
.replace("<", "_")
|
||||
.replace(">", "_")
|
||||
.replace("&", "_");
|
||||
let inner_vector_serializer = generate_vector_serializer(&*ty, &serializer_name);
|
||||
let serializer_ident = crate::new_ident!(serializer_name);
|
||||
|
||||
@ -182,7 +185,10 @@ pub(crate) fn generate_vector_deserializer(
|
||||
}
|
||||
}
|
||||
ParsedType::Vector(ty, _) => {
|
||||
let deserializer_name = format!("{}_{}", arg_name, ty);
|
||||
let deserializer_name = format!("{}_{}", arg_name, ty)
|
||||
.replace("&", "_")
|
||||
.replace("<", "_")
|
||||
.replace(">", "_");
|
||||
let inner_vector_deserializer = generate_vector_deserializer(&*ty, &deserializer_name);
|
||||
let deserializer_ident = crate::new_ident!(deserializer_name);
|
||||
|
||||
|
@ -105,7 +105,10 @@ impl RecordDeserializerGlueCodeGenerator for fce_ast_types::AstRecordItem {
|
||||
}
|
||||
ParsedType::Vector(ty, _) => {
|
||||
let generated_deserializer_name =
|
||||
format!("__fce_generated_vec_deserializer_{}", value_id);
|
||||
format!("__fce_generated_vec_deserializer_{}", value_id)
|
||||
.replace("&", "_")
|
||||
.replace("<", "_")
|
||||
.replace(">", "_");
|
||||
let generated_deserializer_ident = new_ident!(generated_deserializer_name);
|
||||
let vector_deserializer = crate::parsed_type::generate_vector_deserializer(
|
||||
ty,
|
||||
|
@ -5,7 +5,7 @@ use fluence::fce;
|
||||
pub fn main() {}
|
||||
|
||||
#[fce]
|
||||
pub fn byte_type( __arg: Vec<u8>) -> Vec<u8> {
|
||||
pub fn byte_type(_arg: Vec<u8>) -> Vec<u8> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,11 @@ pub fn string_type(_arg: String) -> String {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn str_type(_arg: &str) -> &str {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn bytearray_type(_arg: Vec<u8>) -> Vec<u8> {
|
||||
unimplemented!()
|
||||
|
77
fluence/tests/export_functions/ref_arrays.rs
Normal file
77
fluence/tests/export_functions/ref_arrays.rs
Normal file
@ -0,0 +1,77 @@
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
use fluence::fce;
|
||||
|
||||
pub fn main() {}
|
||||
|
||||
#[fce]
|
||||
pub fn byte_type(_arg: &Vec<u8>) -> &Vec<u8> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn inner_arrays_1(_arg: &Vec<Vec<Vec<Vec<u8>>>>) -> &Vec<Vec<Vec<Vec<u8>>>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn inner_arrays_2(_arg: &Vec<Vec<Vec<Vec<u8>>>>) -> &Vec<Vec<&Vec<Vec<u8>>>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn inner_arrays_3(_arg: &Vec<Vec<Vec<Vec<u8>>>>) -> &Vec<&Vec<&Vec<&Vec<&u8>>>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[derive(Default)]
|
||||
pub struct TestRecord {
|
||||
pub field_0: i32,
|
||||
pub field_1: Vec<Vec<u8>>,
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn inner_arrays_4(_arg: &Vec<Vec<Vec<Vec<TestRecord>>>>) -> &Vec<Vec<Vec<Vec<TestRecord>>>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn string_type(_arg: &Vec<String>) -> &Vec<String> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn f32_type(_arg: &Vec<f32>) -> &Vec<f32> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn f64_type(_arg: &Vec<f64>) -> &Vec<f64> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn u32_type(_arg: &Vec<u32>) -> &Vec<u32> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn u64_type(_arg: &Vec<u64>) -> &Vec<u64> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn i32_type(_arg: &Vec<i32>) -> &Vec<i32> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn i64_type(_arg: &Vec<i64>) -> &Vec<i64> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn empty_type() -> &'static Vec<String> {
|
||||
unimplemented!()
|
||||
}
|
73
fluence/tests/export_functions/ref_basic_types.rs
Normal file
73
fluence/tests/export_functions/ref_basic_types.rs
Normal file
@ -0,0 +1,73 @@
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
use fluence::fce;
|
||||
|
||||
pub fn main() {}
|
||||
|
||||
#[fce]
|
||||
pub fn all_types<'v>(
|
||||
_arg_0: &i8,
|
||||
_arg_1: &i16,
|
||||
_arg_2: &i32,
|
||||
_arg_3: &i64,
|
||||
_arg_4: &u8,
|
||||
_arg_5: &u16,
|
||||
_arg_6: &u32,
|
||||
_arg_7: &u64,
|
||||
_arg_8: &f32,
|
||||
_arg_9: &f64,
|
||||
_arg_10: &String,
|
||||
_arg_11: &'v Vec<u8>,
|
||||
) -> &'v Vec<u8> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn string_type(_arg: &String) -> &String {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn bytearray_type(_arg: &Vec<u8>) -> &Vec<u8> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn bool_type(_arg: &bool) -> &bool {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn f32_type(_arg: &f32) -> &f32 {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn f64_type(_arg: &f64) -> &f64 {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn u32_type(_arg: &u32) -> &u32 {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn u64_type(_arg: &u64) -> &u64 {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn i32_type(_arg: &i32) -> &i32 {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn i64_type(_arg: &i64) -> &i64 {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn empty_type() -> &'static String {
|
||||
unimplemented!()
|
||||
}
|
58
fluence/tests/import_functions/ref_arrays.rs
Normal file
58
fluence/tests/import_functions/ref_arrays.rs
Normal file
@ -0,0 +1,58 @@
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
use fluence::fce;
|
||||
|
||||
pub fn main() {}
|
||||
|
||||
#[fce]
|
||||
#[derive(Default)]
|
||||
pub struct TestRecord {
|
||||
pub field_0: i32,
|
||||
pub field_1: Vec<Vec<u8>>,
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[link(wasm_import_module = "arrays_passing_effector")]
|
||||
extern "C" {
|
||||
pub fn inner_arrays_1(arg: &Vec<Vec<Vec<Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>>;
|
||||
pub fn inner_arrays_2(arg: &Vec<&Vec<Vec<Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>>;
|
||||
pub fn inner_arrays_3(arg: &Vec<&Vec<&Vec<Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>>;
|
||||
pub fn inner_arrays_4(arg: &Vec<&Vec<&Vec<&Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>>;
|
||||
pub fn inner_arrays_5(arg: &Vec<&Vec<&Vec<&Vec<&u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>>;
|
||||
|
||||
pub fn inner_arrays_6(
|
||||
arg: &Vec<Vec<Vec<Vec<TestRecord>>>>,
|
||||
) -> Vec<Vec<Vec<Vec<TestRecord>>>>;
|
||||
|
||||
pub fn inner_arrays_7(
|
||||
arg: &Vec<&Vec<Vec<Vec<TestRecord>>>>,
|
||||
) -> Vec<Vec<Vec<Vec<TestRecord>>>>;
|
||||
|
||||
pub fn inner_arrays_8(
|
||||
arg: &Vec<&Vec<&Vec<Vec<TestRecord>>>>,
|
||||
) -> Vec<Vec<Vec<Vec<TestRecord>>>>;
|
||||
|
||||
pub fn inner_arrays_9(
|
||||
arg: &Vec<&Vec<&Vec<&Vec<TestRecord>>>>,
|
||||
) -> Vec<Vec<Vec<Vec<TestRecord>>>>;
|
||||
|
||||
pub fn inner_arrays_10(
|
||||
arg: &Vec<&Vec<&Vec<&Vec<&TestRecord>>>>,
|
||||
) -> Vec<Vec<Vec<Vec<TestRecord>>>>;
|
||||
|
||||
pub fn string_type(arg: &Vec<String>) -> Vec<String>;
|
||||
|
||||
pub fn byte_type(arg: &Vec<u8>) -> Vec<u8>;
|
||||
|
||||
pub fn f32_type(arg: &Vec<f32>) -> Vec<f32>;
|
||||
|
||||
pub fn f64_type(arg: &Vec<f64>) -> Vec<f64>;
|
||||
|
||||
pub fn u32_type(arg: &Vec<u32>) -> Vec<u32>;
|
||||
|
||||
pub fn u64_type(arg: &Vec<u64>) -> Vec<u64>;
|
||||
|
||||
pub fn i32_type(arg: &Vec<i32>) -> Vec<i32>;
|
||||
|
||||
pub fn i64_type(arg: &Vec<i64>) -> Vec<i64>;
|
||||
}
|
38
fluence/tests/import_functions/ref_basic_types.rs
Normal file
38
fluence/tests/import_functions/ref_basic_types.rs
Normal file
@ -0,0 +1,38 @@
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
use fluence::fce;
|
||||
|
||||
fn main() {}
|
||||
|
||||
#[fce]
|
||||
#[link(wasm_import_module = "arguments_passing_effector")]
|
||||
extern "C" {
|
||||
pub fn all_types(
|
||||
arg_0: &i8,
|
||||
arg_1: &i16,
|
||||
arg_2: &i32,
|
||||
arg_3: &i64,
|
||||
arg_4: &u8,
|
||||
arg_5: &u16,
|
||||
arg_6: &u32,
|
||||
arg_7: &u64,
|
||||
arg_8: &f32,
|
||||
arg_9: &f64,
|
||||
arg_10: &String,
|
||||
arg_11: &Vec<u8>,
|
||||
) -> Vec<u8>;
|
||||
|
||||
pub fn string_type(arg: &String) -> String;
|
||||
pub fn bytearray_type(arg: &Vec<u8>) -> Vec<u8>;
|
||||
|
||||
pub fn bool_type(arg: &bool) -> bool;
|
||||
|
||||
pub fn f32_type(arg: &f32) -> f32;
|
||||
pub fn f64_type(arg: &f64) -> f64;
|
||||
|
||||
pub fn u32_type(arg: &u32) -> u32;
|
||||
pub fn u64_type(arg: &u64) -> u64;
|
||||
|
||||
pub fn i32_type(arg: &i32) -> i32;
|
||||
pub fn i64_type(arg: &i64) -> i64;
|
||||
}
|
@ -2,11 +2,15 @@
|
||||
fn test() {
|
||||
let tests = trybuild::TestCases::new();
|
||||
tests.pass("tests/export_functions/arrays.rs");
|
||||
tests.pass("tests/export_functions/ref_arrays.rs");
|
||||
tests.pass("tests/export_functions/basic_types.rs");
|
||||
tests.pass("tests/export_functions/ref_basic_types.rs");
|
||||
tests.compile_fail("tests/export_functions/improper_types.rs");
|
||||
|
||||
tests.pass("tests/import_functions/arrays.rs");
|
||||
tests.pass("tests/import_functions/ref_arrays.rs");
|
||||
tests.pass("tests/import_functions/basic_types.rs");
|
||||
tests.pass("tests/import_functions/ref_basic_types.rs");
|
||||
tests.compile_fail("tests/import_functions/improper_types.rs");
|
||||
|
||||
tests.pass("tests/records/basic_structs.rs");
|
||||
|
Loading…
Reference in New Issue
Block a user