summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lit/exec/strings.wast15
-rw-r--r--test/lit/passes/precompute-strings.wast29
2 files changed, 44 insertions, 0 deletions
diff --git a/test/lit/exec/strings.wast b/test/lit/exec/strings.wast
index 706602b1c..5ff8ce47a 100644
--- a/test/lit/exec/strings.wast
+++ b/test/lit/exec/strings.wast
@@ -244,6 +244,17 @@
)
)
)
+
+ ;; CHECK: [fuzz-exec] calling slice
+ ;; CHECK-NEXT: [fuzz-exec] note result: slice => string("def")
+ (func $slice (export "slice") (result (ref string))
+ ;; Slicing [3:6] here should definitely output "def".
+ (stringview_wtf16.slice
+ (string.const "abcdefgh")
+ (i32.const 3)
+ (i32.const 6)
+ )
+ )
)
;; CHECK: [fuzz-exec] calling new_wtf16_array
;; CHECK-NEXT: [fuzz-exec] note result: new_wtf16_array => string("ello")
@@ -309,6 +320,9 @@
;; CHECK-NEXT: [LoggingExternalInterface logging 98]
;; CHECK-NEXT: [LoggingExternalInterface logging 99]
;; CHECK-NEXT: [LoggingExternalInterface logging 0]
+
+;; CHECK: [fuzz-exec] calling slice
+;; CHECK-NEXT: [fuzz-exec] note result: slice => string("def")
;; CHECK-NEXT: [fuzz-exec] comparing compare.1
;; CHECK-NEXT: [fuzz-exec] comparing compare.10
;; CHECK-NEXT: [fuzz-exec] comparing compare.2
@@ -329,3 +343,4 @@
;; CHECK-NEXT: [fuzz-exec] comparing get_codeunit
;; CHECK-NEXT: [fuzz-exec] comparing get_length
;; CHECK-NEXT: [fuzz-exec] comparing new_wtf16_array
+;; CHECK-NEXT: [fuzz-exec] comparing slice
diff --git a/test/lit/passes/precompute-strings.wast b/test/lit/passes/precompute-strings.wast
index aa138b289..f70430648 100644
--- a/test/lit/passes/precompute-strings.wast
+++ b/test/lit/passes/precompute-strings.wast
@@ -129,4 +129,33 @@
(i32.const 0)
)
)
+
+ ;; CHECK: (func $slice (type $1) (result (ref string))
+ ;; CHECK-NEXT: (string.const "def")
+ ;; CHECK-NEXT: )
+ (func $slice (export "slice") (result (ref string))
+ ;; Slicing [3:6] here should definitely output "def".
+ (stringview_wtf16.slice
+ (string.const "abcdefgh")
+ (i32.const 3)
+ (i32.const 6)
+ )
+ )
+
+ ;; CHECK: (func $slice-bad (type $1) (result (ref string))
+ ;; CHECK-NEXT: (stringview_wtf16.slice
+ ;; CHECK-NEXT: (string.const "abcd\c2\a3fgh")
+ ;; CHECK-NEXT: (i32.const 3)
+ ;; CHECK-NEXT: (i32.const 6)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $slice-bad (export "slice-bad") (result (ref string))
+ ;; This slice contains non-ascii, so we do not optimize.
+ (stringview_wtf16.slice
+ ;; abcd£fgh
+ (string.const "abcd\C2\A3fgh")
+ (i32.const 3)
+ (i32.const 6)
+ )
+ )
)