mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-13 00:51:20 +00:00
fix emscripten dependencies by making separate test crate
This commit is contained in:
35
lib/emscripten-tests/emtests/stackAlloc.cpp
Normal file
35
lib/emscripten-tests/emtests/stackAlloc.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright 2018 The Emscripten Authors. All rights reserved.
|
||||
// Emscripten is available under two separate licenses, the MIT license and the
|
||||
// University of Illinois/NCSA Open Source License. Both these licenses can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <emscripten.h>
|
||||
|
||||
int main() {
|
||||
EM_ASM({
|
||||
var size = 128;
|
||||
var before;
|
||||
before = stackSave();
|
||||
var x = stackAlloc(size);
|
||||
var y = stackAlloc(size);
|
||||
var direction = y > x ? 1 : -1;
|
||||
assert(x % 16 == 0, "allocation must have 16-byte alignment");
|
||||
assert(x == Math.min(before, before + direction*size), "allocation must return the start of the range allocated");
|
||||
var z = stackAlloc(size);
|
||||
assert(x != y && y != z && x != z, "allocations must be unique");
|
||||
assert((y - x)*(z - y) > 0, "allocations must be in the same direction");
|
||||
// no overlaps
|
||||
function notInRange(value, begin, end) {
|
||||
function errormsg() { return value + " must not be in the range (" + begin + ", " + end + "]"; }
|
||||
if (begin < end) assert(!(value >= begin && value < end), errormsg());
|
||||
else assert(!(value <= begin && value > end), errormsg());
|
||||
}
|
||||
notInRange(x, y, y + direction*size);
|
||||
notInRange(x, z, z + direction*size);
|
||||
notInRange(y, x, x + direction*size);
|
||||
notInRange(y, z, z + direction*size);
|
||||
notInRange(z, x, x + direction*size);
|
||||
notInRange(z, y, y + direction*size);
|
||||
out('ok.');
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user