2018-03-23 12:45:29 +01:00
|
|
|
import "allocator/arena";
|
|
|
|
|
2018-01-27 05:35:14 +01:00
|
|
|
// preliminary
|
|
|
|
|
|
|
|
var str: string = "hi, I'm a string";
|
|
|
|
|
|
|
|
// exactly once in static memory
|
2018-01-29 07:42:40 +01:00
|
|
|
assert(changetype<usize>(str) == changetype<usize>("hi, I'm a string"));
|
2018-01-27 05:35:14 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2018-01-28 23:42:55 +01:00
|
|
|
|
|
|
|
assert(parseInt("0") == 0);
|
|
|
|
assert(parseInt("1") == 1);
|
|
|
|
assert(parseInt("0b101") == 0b101);
|
|
|
|
assert(parseInt("0o707") == 0o707);
|
|
|
|
assert(parseInt("0xf0f") == 0xf0f);
|
|
|
|
assert(parseInt("0xF0F") == 0xf0f);
|
|
|
|
assert(parseInt("011") == 11); // not octal
|
|
|
|
assert(parseInt("0x1g") == 1); // not valid
|
2018-01-29 07:42:40 +01:00
|
|
|
|
|
|
|
assert(parseFloat("0") == 0);
|
|
|
|
assert(parseFloat("1") == 1);
|
|
|
|
assert(parseFloat("0.1") == 0.1);
|
|
|
|
assert(parseFloat(".25") == 0.25);
|
|
|
|
assert(parseFloat(".1foobar") == 0.1);
|
2018-03-23 12:45:29 +01:00
|
|
|
|
|
|
|
var c = "a" + "b";
|
|
|
|
assert(c == "ab");
|