aboutsummaryrefslogtreecommitdiff
path: root/tests/core/test_inlinejs3.in
blob: 12e31007ff8c1b991061c49a8f1fd24dd183cc27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
#include <emscripten.h>

int main(int argc, char **argv) {
  EM_ASM(Module.print('hello dere1'));
  EM_ASM("Module.print('hello dere2');");
  for (int i = 0; i < 3; i++) {
    EM_ASM(Module.print('hello dere3'); Module.print('hello dere' + 4););
  }
  EM_ASM_({ Module.print('hello input ' + $0) }, 123);
  int sum = 0;
  for (int i = 0; i < argc * 3; i++) {
    sum += EM_ASM_INT({
                        Module.print('i: ' + [ $0, ($1).toFixed(2) ]);
                        return $0 * 2;
                      },
                      i, double(i) / 12);
  }
  EM_ASM_INT({ globalVar = $0 }, sum); // no outputs, just input
  sum = 0;
  sum = EM_ASM_INT_V({ return globalVar }); // no inputs, just output
  printf("sum: %d\n", sum);
  return 0;
}