Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions test/core/test_em_asm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ int main() {

unsigned long p = 8;
EM_ASM({
console.log("int types:");
out("int types:");
out(" char : " + $0);
out(" signed char : " + $1);
out("unsigned char : " + $2);
Expand Down Expand Up @@ -71,35 +71,35 @@ int main() {

// Test mixing ints and doubles
EM_ASM({
console.log("idii");
out("idii");
out("a " + $0);
out("b " + $1);
out("c " + $2);
out("d " + $3);
}, 1, 3.14159, 3, 4);
EM_ASM({
console.log("diii");
out("diii");
out("a " + $0);
out("b " + $1);
out("c " + $2);
out("d " + $3);
}, 3.14159, 2, 3, 4);
EM_ASM({
console.log("iidi");
out("iidi");
out("a " + $0);
out("b " + $1);
out("c " + $2);
out("d " + $3);
}, 1, 2, 3.14159, 4);
EM_ASM({
console.log("ddii");
out("ddii");
out("a " + $0);
out("b " + $1);
out("c " + $2);
out("d " + $3);
}, 3.14159, 2.1828, 3, 4);
EM_ASM({
console.log("iddi");
out("iddi");
out("a " + $0);
out("b " + $1);
out("c " + $2);
Expand Down
184 changes: 92 additions & 92 deletions test/core/test_em_asm_2.cpp

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions test/core/test_em_asm_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int main(int argc, char **argv) {
// Promotions of arrays, function/member pointers and objects implicitly
// convertible to numbers are excluded because they will not be translated
// to corresponding JS objects.
#define TEST_TYPE(type, value) EM_ASM({console.log(#type, Number($0));}, (type)(value));
#define TEST_TYPE(type, value) EM_ASM({out(#type, Number($0));}, (type)(value));
TEST_TYPE(int*, 0);
TEST_TYPE(float, 1.5f);
TEST_TYPE(double, 2.5);
Expand All @@ -39,14 +39,14 @@ int main(int argc, char **argv) {

struct WithBitField w;
w.x = 3;
EM_ASM({ console.log('bit field', $0); }, w.x);
EM_ASM({ out('bit field', $0); }, w.x);

#ifdef __cplusplus
TEST_TYPE(bool, true);
TEST_TYPE(wchar_t, 50);
#else
EM_ASM({console.log('bool 1')});
EM_ASM({console.log('wchar_t 50')});
EM_ASM({out('bool 1')});
EM_ASM({out('wchar_t 50')});
#endif

TEST_TYPE(enum SomeEnum, SIXTY);
Expand Down
8 changes: 4 additions & 4 deletions test/core/test_em_js_i64.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#include <emscripten.h>

EM_JS(void, foo, (uint64_t a, int64_t b), {
console.log(typeof a);
console.log(typeof b);
out(typeof a);
out(typeof b);

console.log('a:' + a);
console.log('b:' + b);
out('a:' + a);
out('b:' + b);
})

int main() {
Expand Down
7 changes: 4 additions & 3 deletions test/core/test_get_exported_function.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <emscripten.h>
#include <emscripten/emscripten.h>
#include <emscripten/console.h>
#include <emscripten/exports.h>

extern "C" EMSCRIPTEN_KEEPALIVE int foo()
Expand All @@ -17,10 +18,10 @@ int main()
{
intfunc f = (intfunc)emscripten_get_exported_function("_foo");
intfunc b = (intfunc)emscripten_get_exported_function("_bar");
EM_ASM(console.log($0 + ' ' + $1), f(), b());
emscripten_outf("%d %d", f(), b());

// Obtaining the same function pointer twice should return the
// same address.
intfunc b2 = (intfunc)emscripten_get_exported_function("_bar");
EM_ASM(console.log($0), b == b2);
emscripten_outf("%d", b == b2);
}
4 changes: 2 additions & 2 deletions test/embind/embind_jspi_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ EM_ASYNC_JS(void, test, (), {
setTimeout(Module.unsuspend);
await Module.suspend();

console.log('done');
out('done');
} catch (e) {
console.log('Failed: ' + e.stack);
out('Failed: ' + e.stack);
}
});

Expand Down
14 changes: 7 additions & 7 deletions test/embind/test_float_constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ EMSCRIPTEN_BINDINGS(constants) {
}

int main() {
EM_ASM(
console.log("PI (as double) = " + Module['PI']);
console.log("EULER = " + Module['EULER']);
console.log("pi (as float) = " + Module['pi']);
console.log("euler = " + Module['euler']);
);
}
EM_ASM(
out("PI (as double) = " + Module['PI']);
out("EULER = " + Module['EULER']);
out("pi (as float) = " + Module['pi']);
out("euler = " + Module['euler']);
);
}
12 changes: 6 additions & 6 deletions test/embind/test_negative_constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ EMSCRIPTEN_BINDINGS(constants) {

int main() {
EM_ASM(
console.log("NEGATIVE_FLOAT_NUM = " + Module['NEGATIVE_FLOAT_NUM']);
console.log("NEGATIVE_INT_NUM = " + Module['NEGATIVE_INT_NUM']);
console.log("negative_float_num = " + Module['negative_float_num']);
console.log("negative_double_num = " + Module['negative_double_num']);
console.log("negative_int_num = " + Module['negative_int_num']);
out("NEGATIVE_FLOAT_NUM = " + Module['NEGATIVE_FLOAT_NUM']);
out("NEGATIVE_INT_NUM = " + Module['NEGATIVE_INT_NUM']);
out("negative_float_num = " + Module['negative_float_num']);
out("negative_double_num = " + Module['negative_double_num']);
out("negative_int_num = " + Module['negative_int_num']);
);
}
}
2 changes: 1 addition & 1 deletion test/fetch/sync_xhr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ int main()
// If an exception is thrown from the user callback, it bubbles up to self.onerror but is otherwise completely
// swallowed by xhr.send.
EM_ASM({self.onerror = function() {
console.log('Got error');
out('Got error');
HEAP32[$0 >> 2] = 2;
};}, &result);
emscripten_fetch_attr_t attr;
Expand Down
4 changes: 2 additions & 2 deletions test/pthread/hello_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

#include <pthread.h>
#include <emscripten.h>
#include <emscripten/html5.h>
#include <emscripten/console.h>

void *thread_main(void *arg)
{
EM_ASM(out('hello from thread!'));
emscripten_out("hello from thread!");
emscripten_force_exit(0);
__builtin_trap();
}
Expand Down
17 changes: 9 additions & 8 deletions test/pthread/test_pthread_64bit_atomics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <pthread.h>
#include <emscripten.h>
#include <emscripten/threading.h>
#include <emscripten/console.h>
#include <assert.h>

#define NUM_THREADS 8
Expand Down Expand Up @@ -39,7 +40,7 @@ void *ThreadMain(void *arg)
assert(globalDouble == 5.0);
assert(globalU64 == 5);
struct Test *t = (struct Test*)arg;
EM_ASM(out('Thread ' + $0 + ' for test ' + $1 + ': starting computation.'), t->threadId, t->op);
emscripten_outf("Thread %d for test %d: starting computation", t->threadId, t->op);

for(int i = 0; i < 99999; ++i)
for(int j = 0; j < N; ++j)
Expand Down Expand Up @@ -80,7 +81,7 @@ void *ThreadMain(void *arg)
break;
}
}
EM_ASM(out('Thread ' + $0 + ' for test ' + $1 + ': finished, exit()ing.'), t->threadId, t->op);
emscripten_outf("Thread %d for test %d: finished, exit()ing", t->threadId, t->op);
pthread_exit(0);
}

Expand All @@ -93,7 +94,7 @@ void RunTest(int test)
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, 4*1024);

printf("Main thread has thread ID %ld\n", pthread_self());
emscripten_outf("Main thread has thread ID %ld\n", pthread_self());
assert(pthread_self() != 0);

switch(test)
Expand All @@ -103,7 +104,7 @@ void RunTest(int test)
default: memset(sharedData, 0, sizeof(sharedData)); break;
}

EM_ASM(out('Main: Starting test ' + $0), test);
emscripten_outf("Main: Starting test %d", test);

for(int i = 0; i < NUM_THREADS; ++i)
{
Expand All @@ -124,7 +125,7 @@ void RunTest(int test)
}

int val = sharedData[0];
EM_ASM(out('Main: Test ' + $0 + ' finished. Result: ' + $1), test, val);
emscripten_outf("Main: Test %d finished. Result: %d", test, val);
if (test != 6)
{
for(int i = 1; i < N; ++i)
Expand Down Expand Up @@ -152,10 +153,10 @@ int main()
for(int i = 0; i < N; ++i)
totalRead += sharedData[i];
if (totalRead == totalWritten)
printf("totalRead: %llu, totalWritten: %llu\n", totalRead, totalWritten);
emscripten_outf("totalRead: %llu, totalWritten: %llu\n", totalRead, totalWritten);
else
printf("64-bit CAS test failed! totalRead != totalWritten (%llu != %llu)\n", totalRead, totalWritten);
emscripten_outf("64-bit CAS test failed! totalRead != totalWritten (%llu != %llu)\n", totalRead, totalWritten);
assert(totalRead == totalWritten);
EM_ASM(out('Main: Test successfully finished.'));
emscripten_outf("Main: Test successfully finished");
return 0;
}
12 changes: 6 additions & 6 deletions test/pthread/test_pthread_atomics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int rand_32()
void *ThreadMain(void *arg)
{
// Do some stdio to test proxying to the main thread.
printf("pthread %p starting\n", arg);
emscripten_outf("pthread %p starting\n", arg);

assert(pthread_self() != 0);
assert(globalUchar == 5);
Expand All @@ -52,7 +52,7 @@ void *ThreadMain(void *arg)
assert(globalFloat == 5.0f);
assert(globalDouble == 5.0);
struct Test *t = (struct Test*)arg;
EM_ASM(out('Thread ' + $0 + ' for test ' + $1 + ': starting computation.'), t->threadId, t->op);
emscripten_outf("Thread %d for test %d: starting computation", t->threadId, t->op);

for(int i = 0; i < 99999; ++i)
for(int j = 0; j < N; ++j)
Expand Down Expand Up @@ -92,7 +92,7 @@ void *ThreadMain(void *arg)
break;
}
}
EM_ASM(out('Thread ' + $0 + ' for test ' + $1 + ': finished, exit()ing.'), t->threadId, t->op);
emscripten_outf("Thread %d for test %d: finished, exit()ing", t->threadId, t->op);
pthread_exit(0);
}

Expand All @@ -105,7 +105,7 @@ void RunTest(int test)
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, 4*1024);

printf("Main thread has thread ID %d\n", (int)pthread_self());
emscripten_outf("Main thread has thread ID %d\n", (int)pthread_self());
assert(pthread_self() != 0);

switch(test)
Expand All @@ -115,7 +115,7 @@ void RunTest(int test)
default: memset(sharedData, 0, sizeof(sharedData)); break;
}

EM_ASM(out('Main: Starting test ' + $0), test);
emscripten_outf("Main: Starting test %d", test);

for(int i = 0; i < NUM_THREADS; ++i)
{
Expand All @@ -136,7 +136,7 @@ void RunTest(int test)
}

int val = sharedData[0];
EM_ASM(out('Main: Test ' + $0 + ' finished. Result: ' + $1), test, val);
emscripten_outf("Main: Test %d finished. Result: %d", test, val);
if (test != 6)
{
for(int i = 1; i < N; ++i)
Expand Down
10 changes: 5 additions & 5 deletions test/pthread/test_pthread_cancel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
#include <assert.h>
#include <unistd.h>
#include <errno.h>
#include <emscripten/em_asm.h>
#include <emscripten/console.h>

_Atomic long res = 43;
static void cleanup_handler(void *arg)
{
EM_ASM(out('Called clean-up handler with arg ' + $0), arg);
emscripten_outf("Called clean-up handler with arg %p", arg);
long a = (long)arg;
res -= a;
}

static void *thread_start(void *arg)
{
pthread_cleanup_push(cleanup_handler, (void*)42);
EM_ASM(out('Thread started!'));
emscripten_out("Thread started!");
for(;;)
{
pthread_testcancel();
Expand All @@ -38,7 +38,7 @@ int main()
{
int s = pthread_create(&thr, NULL, thread_start, (void*)0);
assert(s == 0);
EM_ASM(out('Canceling thread..'););
emscripten_out("Canceling thread..");
s = pthread_cancel(thr);
assert(s == 0);

Expand All @@ -47,7 +47,7 @@ int main()
int result = res;
if (result == 1)
{
EM_ASM_INT( { out('After canceling, shared variable = ' + $0 + '.'); }, result);
emscripten_outf("After canceling, shared variable = %d", result);
return 0;
}
}
Expand Down
Loading