mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-13 23:11:41 +00:00
Add String#lastIndexOf and improve tests (#163)
This commit is contained in:
@ -132,7 +132,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 12)
|
||||
(i32.const 231)
|
||||
(i32.const 255)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -154,31 +154,31 @@
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(tee_local $3
|
||||
(tee_local $2
|
||||
(select
|
||||
(tee_local $3
|
||||
(tee_local $2
|
||||
(select
|
||||
(get_local $2)
|
||||
(i32.const 0)
|
||||
(i32.gt_s
|
||||
(tee_local $3
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(i32.const 0)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(tee_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.lt_s
|
||||
(get_local $3)
|
||||
(i32.const 0)
|
||||
(i32.gt_s
|
||||
(get_local $2)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
(return
|
||||
(i32.const 0)
|
||||
@ -192,7 +192,7 @@
|
||||
(i32.const 4)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
|
@ -201,6 +201,7 @@
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(local $8 i32)
|
||||
(local $9 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.ne
|
||||
@ -212,7 +213,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 12)
|
||||
(i32.const 231)
|
||||
(i32.const 255)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -235,32 +236,37 @@
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $7
|
||||
(select
|
||||
(tee_local $5
|
||||
(select
|
||||
(tee_local $5
|
||||
(get_local $3)
|
||||
)
|
||||
(tee_local $6
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $5)
|
||||
(get_local $6)
|
||||
(set_local $8
|
||||
(block $~lib/internal/string/clamp<isize>|inlined.0 (result i32)
|
||||
(set_local $5
|
||||
(i32.const 0)
|
||||
)
|
||||
(select
|
||||
(tee_local $6
|
||||
(select
|
||||
(tee_local $6
|
||||
(get_local $3)
|
||||
)
|
||||
(tee_local $7
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.lt_s
|
||||
(get_local $6)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(tee_local $6
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.lt_s
|
||||
(get_local $5)
|
||||
(get_local $6)
|
||||
(tee_local $7
|
||||
(get_local $5)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $6)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $8
|
||||
(set_local $9
|
||||
(i32.load
|
||||
(get_local $1)
|
||||
)
|
||||
@ -268,8 +274,8 @@
|
||||
(if
|
||||
(i32.gt_s
|
||||
(i32.add
|
||||
(get_local $9)
|
||||
(get_local $8)
|
||||
(get_local $7)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
@ -285,7 +291,7 @@
|
||||
(i32.const 4)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $7)
|
||||
(get_local $8)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
@ -294,7 +300,7 @@
|
||||
(i32.const 4)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $8)
|
||||
(get_local $9)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
|
@ -5823,7 +5823,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 728)
|
||||
(i32.const 20)
|
||||
(i32.const 25)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
@ -5855,7 +5855,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 696)
|
||||
(i32.const 18)
|
||||
(i32.const 19)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -5903,7 +5903,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 696)
|
||||
(i32.const 74)
|
||||
(i32.const 75)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
|
@ -8611,7 +8611,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 728)
|
||||
(i32.const 20)
|
||||
(i32.const 25)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
@ -8647,7 +8647,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 696)
|
||||
(i32.const 18)
|
||||
(i32.const 19)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -8699,7 +8699,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 696)
|
||||
(i32.const 74)
|
||||
(i32.const 75)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -13,8 +13,24 @@ assert(str.charCodeAt(0) == 0x68);
|
||||
assert(str.startsWith("hi"));
|
||||
assert(str.endsWith("string"));
|
||||
assert(str.includes("I'm"));
|
||||
|
||||
assert("".indexOf("") == 0);
|
||||
assert("".indexOf("hi") == -1);
|
||||
assert(str.indexOf("") == 0);
|
||||
assert(str.indexOf(",") == 2);
|
||||
assert(str.indexOf("x") == -1);
|
||||
assert(str.indexOf(",", 2) == 2);
|
||||
assert(str.indexOf(",", 3) == -1);
|
||||
assert(str.indexOf(", I", -1) == 2);
|
||||
|
||||
assert("".lastIndexOf("") == 0);
|
||||
assert("".lastIndexOf("hi") == -1);
|
||||
assert(str.lastIndexOf("") == str.length);
|
||||
assert(str.lastIndexOf(",") == 2);
|
||||
assert(str.lastIndexOf("x") == -1);
|
||||
assert(str.lastIndexOf(",", 2) == 2);
|
||||
assert(str.lastIndexOf(",", 3) == 2);
|
||||
assert(str.lastIndexOf(", I", -1) == 2);
|
||||
|
||||
export function getString(): string {
|
||||
return str;
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user