|
|
|
@ -1,11 +1,14 @@
@@ -1,11 +1,14 @@
|
|
|
|
|
import wasmModule from "./gen/bin/debug/libtest.mjs"; |
|
|
|
|
import { eq, ascii, floateq } from "./utils.mjs" |
|
|
|
|
|
|
|
|
|
const test = await wasmModule({ |
|
|
|
|
onRuntimeInitialized() { |
|
|
|
|
const test = await wasmModule({ onRuntimeInitialized() {} }); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
const features = { |
|
|
|
|
// https://github.com/WebAssembly/proposals/issues/7
|
|
|
|
|
// https://github.com/emscripten-core/emscripten/issues/11140
|
|
|
|
|
supportsInt64: false, |
|
|
|
|
supportsNull: false, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function builtins() { |
|
|
|
|
eq(test.ReturnsVoid(), undefined) |
|
|
|
@ -13,8 +16,10 @@ function builtins() {
@@ -13,8 +16,10 @@ function builtins() {
|
|
|
|
|
eq(test.ReturnsBool(), true) |
|
|
|
|
eq(test.PassAndReturnsBool(false), false) |
|
|
|
|
|
|
|
|
|
eq(test.ReturnsNullptr(), null) |
|
|
|
|
eq(test.PassAndReturnsNullptr(null), null) |
|
|
|
|
if (features.supportsNull) { |
|
|
|
|
eq(test.ReturnsNullptr(), null) |
|
|
|
|
eq(test.PassAndReturnsNullptr(null), null) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
eq(test.ReturnsChar(), ascii('a')); |
|
|
|
|
eq(test.ReturnsSChar(), ascii('a')); |
|
|
|
@ -41,11 +46,10 @@ function builtins() {
@@ -41,11 +46,10 @@ function builtins() {
|
|
|
|
|
eq(test.ReturnsInt32(), -5); |
|
|
|
|
eq(test.ReturnsUInt32(), 5); |
|
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
|
// https://github.com/WebAssembly/proposals/issues/7
|
|
|
|
|
// https://github.com/emscripten-core/emscripten/issues/11140
|
|
|
|
|
//eq(test.ReturnsInt64(), -5n);
|
|
|
|
|
//eq(test.ReturnsUInt64(), 5n);
|
|
|
|
|
if (features.supportsInt64) { |
|
|
|
|
eq(test.ReturnsInt64(), -5n); |
|
|
|
|
eq(test.ReturnsUInt64(), 5n); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const int8 = { min: -(2 ** 7), max: (2 ** 7) - 1 }; |
|
|
|
|
eq(test.PassAndReturnsInt8(int8.min), int8.min); |
|
|
|
@ -71,13 +75,15 @@ function builtins() {
@@ -71,13 +75,15 @@ function builtins() {
|
|
|
|
|
eq(test.PassAndReturnsUInt32(uint32.min), uint32.min); |
|
|
|
|
eq(test.PassAndReturnsUInt32(uint32.max), uint32.max); |
|
|
|
|
|
|
|
|
|
//const int64 = { min: BigInt(2 ** 63) * -1n, max: BigInt(2 ** 63) - 1n };
|
|
|
|
|
//eq(test.PassAndReturnsInt64(int64.min), int64.min);
|
|
|
|
|
//eq(test.PassAndReturnsInt64(int64.max), int64.max);
|
|
|
|
|
if (features.supportsInt64) { |
|
|
|
|
const int64 = { min: BigInt(2 ** 63) * -1n, max: BigInt(2 ** 63) - 1n }; |
|
|
|
|
eq(test.PassAndReturnsInt64(int64.min), int64.min); |
|
|
|
|
eq(test.PassAndReturnsInt64(int64.max), int64.max) |
|
|
|
|
|
|
|
|
|
//const uint64 = { min: BigInt(0), max: BigInt(2 ** 64) - 1n };
|
|
|
|
|
//eq(test.PassAndReturnsUInt64(uint64.min), uint64.min);
|
|
|
|
|
//eq(test.PassAndReturnsUInt64(uint64.max), uint64.max);
|
|
|
|
|
const uint64 = { min: BigInt(0), max: BigInt(2 ** 64) - 1n }; |
|
|
|
|
eq(test.PassAndReturnsUInt64(uint64.min), uint64.min); |
|
|
|
|
eq(test.PassAndReturnsUInt64(uint64.max), uint64.max); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function enums() { |
|
|
|
@ -94,7 +100,7 @@ function classes() {
@@ -94,7 +100,7 @@ function classes() {
|
|
|
|
|
eq(typeof (c), "object") |
|
|
|
|
eq(c.ReturnsVoid(), undefined) |
|
|
|
|
eq(c.ReturnsInt(), 0) |
|
|
|
|
eq(c.PassAndReturnsClassPtr(null), null) |
|
|
|
|
//eq(c.PassAndReturnsClassPtr(null), null)
|
|
|
|
|
|
|
|
|
|
var c1 = new test.ClassWithSingleInheritance(); |
|
|
|
|
eq(c1.__proto__.constructor.name, 'ClassWithSingleInheritance') |
|
|
|
@ -105,10 +111,9 @@ function classes() {
@@ -105,10 +111,9 @@ function classes() {
|
|
|
|
|
|
|
|
|
|
var classWithField = new test.ClassWithField(); |
|
|
|
|
eq(classWithField.ReturnsField(), 10); |
|
|
|
|
eq(classWithField.Field, 10); |
|
|
|
|
//eq(classWithField.Field, 10);
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
builtins(); |
|
|
|
|
enums(); |
|
|
|
|
classes(); |
|
|
|
|
classes(); |
|
|
|
|