mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-22 11:11:43 +00:00
Preliminary strings
While not well-wrought, it's at least possible now to log some stuff when debugging
This commit is contained in:
18
tests/compiler/std/string.ts
Normal file
18
tests/compiler/std/string.ts
Normal file
@ -0,0 +1,18 @@
|
||||
// preliminary
|
||||
|
||||
var str: string = "hi, I'm a string";
|
||||
|
||||
// exactly once in static memory
|
||||
assert(changetype<usize>(str) === changetype<usize>("hi, I'm a string"));
|
||||
|
||||
assert(str.length == 16);
|
||||
assert(str.charCodeAt(0) == 0x68);
|
||||
assert(str.startsWith("hi"));
|
||||
assert(str.endsWith("string"));
|
||||
assert(str.includes("I'm"));
|
||||
assert(str.indexOf(",") == 2);
|
||||
assert(str.indexOf("x") == -1);
|
||||
|
||||
export function getString(): string {
|
||||
return str;
|
||||
}
|
Reference in New Issue
Block a user