Add a debug assert and more tests

This commit is contained in:
Alex Crichton
2019-05-13 08:12:32 -07:00
parent 0c681ee2ba
commit 15defcfd3a
6 changed files with 61 additions and 1 deletions

View File

@ -1499,12 +1499,19 @@ impl<'a> Context<'a> {
arg = arg.slice(offset);
ptr = wasm.__wbindgen_realloc(ptr, size, size = offset + arg.length * 3);
const view = getUint8Memory().subarray(ptr + offset, ptr + size);
const ret = cachedTextEncoder.encodeInto(arg, view);
{}
offset += cachedTextEncoder.encodeInto(arg, view).written;
}}
WASM_VECTOR_LEN = offset;
return ptr;
",
start_encoding_as_ascii
start_encoding_as_ascii,
if self.config.debug {
"if (ret.read != arg.length) throw new Error('failed to pass whole string');"
} else {
""
},
);
// Looks like `encodeInto` doesn't currently work when the memory passed