mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-29 06:32:17 +00:00
wasm_names fix
This commit is contained in:
@ -101,7 +101,7 @@ run_test!("loop", wasm_loop);
|
|||||||
run_test!("memory_redundancy", wasm_memory_redundancy);
|
run_test!("memory_redundancy", wasm_memory_redundancy);
|
||||||
run_test!("memory_trap", wasm_memory_trap);
|
run_test!("memory_trap", wasm_memory_trap);
|
||||||
run_test!("memory", wasm_memory);
|
run_test!("memory", wasm_memory);
|
||||||
// TODO: fix comparison??? run_test!("names", wasm_names);
|
run_test!("names", wasm_names);
|
||||||
run_test!("nop", wasm_nop);
|
run_test!("nop", wasm_nop);
|
||||||
run_test!("of_string-overflow-hex-u32.fail", wasm_of_string_overflow_hex_u32_fail, fail);
|
run_test!("of_string-overflow-hex-u32.fail", wasm_of_string_overflow_hex_u32_fail, fail);
|
||||||
run_test!("of_string-overflow-hex-u64.fail", wasm_of_string_overflow_hex_u64_fail, fail);
|
run_test!("of_string-overflow-hex-u64.fail", wasm_of_string_overflow_hex_u64_fail, fail);
|
||||||
|
@ -97,12 +97,13 @@ fn run_action(program: &ProgramInstance, action: &test::Action)
|
|||||||
let module = module.clone().unwrap_or("wasm_test".into());
|
let module = module.clone().unwrap_or("wasm_test".into());
|
||||||
let module = module.trim_left_matches('$');
|
let module = module.trim_left_matches('$');
|
||||||
let module = program.module(&module).expect(&format!("Expected program to have loaded module {}", module));
|
let module = program.module(&module).expect(&format!("Expected program to have loaded module {}", module));
|
||||||
module.execute_export(field, runtime_values(args).into())
|
module.execute_export(&jstring_to_rstring(field), runtime_values(args).into())
|
||||||
},
|
},
|
||||||
test::Action::Get { ref module, ref field, .. } => {
|
test::Action::Get { ref module, ref field, .. } => {
|
||||||
let module = module.clone().unwrap_or("wasm_test".into());
|
let module = module.clone().unwrap_or("wasm_test".into());
|
||||||
let module = module.trim_left_matches('$');
|
let module = module.trim_left_matches('$');
|
||||||
let module = program.module(&module).expect(&format!("Expected program to have loaded module {}", module));
|
let module = program.module(&module).expect(&format!("Expected program to have loaded module {}", module));
|
||||||
|
let field = jstring_to_rstring(&field);
|
||||||
|
|
||||||
module.export_entry(field.as_ref(), &ExportEntryType::Any)
|
module.export_entry(field.as_ref(), &ExportEntryType::Any)
|
||||||
.and_then(|i| match i {
|
.and_then(|i| match i {
|
||||||
@ -280,3 +281,13 @@ pub fn spec(name: &str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert json string to correct rust UTF8 string.
|
||||||
|
// The reason is that, for example, rust character "\u{FEEF}" (3-byte UTF8 BOM) is represented as "\u00ef\u00bb\u00bf" in json.
|
||||||
|
// It is incorrect. Correct "\uFEFF" => we need to do a double utf8 parse here.
|
||||||
|
// This conversion is incorrect in general case (casting char to u8)!!!
|
||||||
|
fn jstring_to_rstring(jstring: &str) -> String {
|
||||||
|
let jstring_chars: Vec<u8> = jstring.chars().map(|c| c as u8).collect();
|
||||||
|
let rstring = String::from_utf8(jstring_chars).unwrap();
|
||||||
|
rstring
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user