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