1 /*
   2  * This is a test whether multi-line strings work correctly.
   3  */
   4 
   5 #target WASI // Will make the JavaScript tester shorter.
   6 
   7 Function strlen(CharacterPointer str) Which Returns Integer32 Is Declared;
   8 
   9 // Let's insert the assembly code produced by EMSCRIPTEN as multiline string.
  10 asm(R"abc(
  11   (func $strlen (param i32) (result i32)
  12     (local i32 i32)
  13     i32.const 0
  14     local.set 1
  15     loop
  16       local.get 1
  17       local.tee 2
  18       i32.const 1
  19       i32.add
  20       local.set 1
  21       local.get 0
  22       local.get 2
  23       i32.add
  24       i32.load8_u
  25       br_if 0
  26     end
  27     local.get 2)
  28 )abc");
  29 
  30 CharacterPointer first := R"(
  31 \"Hello world!"\
  32 )",
  33                  second := R"ab(
  34 \"Hello world!"\
  35 )ab",
  36                  third := R"a(
  37 \"Hello world!"\
  38 )a";
  39 
  40 //Should return 1
  41 Function multiLineStringTest() Which Returns Integer32 Does
  42   Return strlen(first) = strlen(second) and strlen(second) = strlen(third) 
  43          and strlen(third) = strlen("\\\"Hello world!\"\\") + 2;
  44 EndFunction