Commit 7c743408 authored by mtrofin's avatar mtrofin Committed by Commit bot

[wasm] JS-APIs: more WebAssembly.compile tests

enabled TODO-ed compile tests

BUG=v8:5833

Review-Url: https://codereview.chromium.org/2628053004
Cr-Commit-Position: refs/heads/master@{#42293}
parent 8194ff05
......@@ -56,9 +56,6 @@ RawBuffer GetRawBufferSource(
start = reinterpret_cast<const byte*>(contents.Data());
end = start + contents.ByteLength();
if (start == nullptr || end == start) {
thrower->CompileError("ArrayBuffer argument is empty");
}
} else if (source->IsTypedArray()) {
// A TypedArray was passed.
Local<TypedArray> array = Local<TypedArray>::Cast(source);
......@@ -70,13 +67,12 @@ RawBuffer GetRawBufferSource(
reinterpret_cast<const byte*>(contents.Data()) + array->ByteOffset();
end = start + array->ByteLength();
if (start == nullptr || end == start) {
thrower->CompileError("ArrayBuffer argument is empty");
}
} else {
thrower->TypeError("Argument 0 must be an ArrayBuffer or Uint8Array");
}
if (start == nullptr || end == start) {
thrower->CompileError("BufferSource argument is empty");
}
return {start, end};
}
......
......@@ -546,11 +546,14 @@ function assertCompileError(args, err, msg) {
//TODO assertEq(Boolean(error.message.match(msg)), true);
}
assertCompileError([], TypeError, /requires more than 0 arguments/);
//TODO assertCompileError([undefined], TypeError, /first argument must be an ArrayBuffer or typed array object/);
//TODO assertCompileError([1], TypeError, /first argument must be an ArrayBuffer or typed array object/);
//TODO assertCompileError([{}], TypeError, /first argument must be an ArrayBuffer or typed array object/);
//TODO assertCompileError([new Uint8Array()], CompileError, /failed to match magic number/);
//TODO assertCompileError([new ArrayBuffer()], CompileError, /failed to match magic number/);
assertCompileError([undefined], TypeError, /first argument must be an ArrayBuffer or typed array object/);
assertCompileError([1], TypeError, /first argument must be an ArrayBuffer or typed array object/);
assertCompileError([{}], TypeError, /first argument must be an ArrayBuffer or typed array object/);
assertCompileError([new Uint8Array()], CompileError, /BufferSource argument is empty/);
assertCompileError([new ArrayBuffer()], CompileError, /BufferSource argument is empty/);
assertCompileError([new Uint8Array("hi!")], CompileError, /failed to match magic number/);
assertCompileError([new ArrayBuffer("hi!")], CompileError, /failed to match magic number/);
function assertCompileSuccess(bytes) {
var module = null;
compile(bytes).then(m => module = m);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment