mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-12 22:41:27 +00:00
Add string comparison operator overloads (#64)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,7 @@ import "allocator/arena";
|
||||
// preliminary
|
||||
|
||||
var str: string = "hi, I'm a string";
|
||||
var nullStr: String;
|
||||
|
||||
// exactly once in static memory
|
||||
assert(changetype<usize>(str) == changetype<usize>("hi, I'm a string"));
|
||||
@ -36,3 +37,26 @@ assert(parseFloat(".1foobar") == 0.1);
|
||||
|
||||
var c = "a" + "b";
|
||||
assert(c == "ab");
|
||||
assert(c != "a");
|
||||
assert("" == "");
|
||||
assert("" != nullStr);
|
||||
|
||||
assert("b" > "a");
|
||||
assert("ba" > "a");
|
||||
assert("ba" >= "aa");
|
||||
assert("ba" > "ab");
|
||||
assert(!("ba" < "ab"));
|
||||
|
||||
assert(!("b" < nullStr));
|
||||
assert(!(nullStr < "b"));
|
||||
|
||||
assert("abc" > "");
|
||||
assert("" < "abc");
|
||||
assert("abc" >= "");
|
||||
assert("" <= "abc");
|
||||
assert(!("abc" < ""));
|
||||
assert(!("" > "abc"));
|
||||
assert(!("" < ""));
|
||||
assert(!("" > ""));
|
||||
assert("" >= "");
|
||||
assert("" <= "");
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user