diff options
author | Alon Zakai <azakai@google.com> | 2024-04-23 16:42:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-23 16:42:01 -0700 |
commit | 42db73abe388c7c8ee990ef839a36fd74a0eaadd (patch) | |
tree | 7a4050dc1710c14bca24aa15e8f06c6f9a8b566d /test | |
parent | 94ddae02e591adeb994ae2f798878e814f976bc1 (diff) | |
download | binaryen-42db73abe388c7c8ee990ef839a36fd74a0eaadd.tar.gz binaryen-42db73abe388c7c8ee990ef839a36fd74a0eaadd.tar.bz2 binaryen-42db73abe388c7c8ee990ef839a36fd74a0eaadd.zip |
[Strings] Fuzz and interpret all relevant StringNew methods (#6526)
This adds fuzzing for string.new_wtf16_array and string.from_code_point. The
latter was also missing interpreter support, which this adds.
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/exec/strings.wast | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/test/lit/exec/strings.wast b/test/lit/exec/strings.wast index c67436c98..0f3183ac6 100644 --- a/test/lit/exec/strings.wast +++ b/test/lit/exec/strings.wast @@ -414,6 +414,64 @@ ;; Concatenating these surrogates creates '𐍈'. (string.concat (string.const "\ED\A0\80") (string.const "\ED\BD\88")) ) + + ;; CHECK: [fuzz-exec] calling string.from_code_point + ;; CHECK-NEXT: [fuzz-exec] note result: string.from_code_point => string("A") + (func $string.from_code_point (export "string.from_code_point") (result stringref) + (string.from_code_point + (i32.const 65) + ) + ) + + ;; CHECK: [fuzz-exec] calling unsigned_code_point + ;; CHECK-NEXT: [fuzz-exec] note result: unsigned_code_point => string("\u0093") + (func $unsigned_code_point (export "unsigned_code_point") (result stringref) + (string.from_code_point + ;; This must be interpreted as unsigned, that is, in the escaped output + ;; the top byte is 0. + (i32.const 147) + ) + ) + + ;; CHECK: [fuzz-exec] calling weird_code_point + ;; CHECK-NEXT: [fuzz-exec] note result: weird_code_point => string("\u03e8") + (func $weird_code_point (export "weird_code_point") (result stringref) + (string.from_code_point + (i32.const 0x3e8) + ) + ) + + ;; CHECK: [fuzz-exec] calling isolated_high_code_point + ;; CHECK-NEXT: [fuzz-exec] note result: isolated_high_code_point => string("\ud800") + (func $isolated_high_code_point (export "isolated_high_code_point") (result stringref) + (string.from_code_point + (i32.const 0xD800) + ) + ) + + ;; CHECK: [fuzz-exec] calling isolated_low_code_point + ;; CHECK-NEXT: [fuzz-exec] note result: isolated_low_code_point => string("\udc00") + (func $isolated_low_code_point (export "isolated_low_code_point") (result stringref) + (string.from_code_point + (i32.const 0xDC00) + ) + ) + + ;; CHECK: [fuzz-exec] calling surrogate_pair_code_point + ;; CHECK-NEXT: [fuzz-exec] note result: surrogate_pair_code_point => string("\u286c") + (func $surrogate_pair_code_point (export "surrogate_pair_code_point") (result stringref) + (string.from_code_point + (i32.const 0x286c) ;; 𐍈 + ) + ) + + ;; CHECK: [fuzz-exec] calling invalid_code_point + ;; CHECK-NEXT: [trap invalid code point] + (func $invalid_code_point (export "invalid_code_point") (result stringref) + (string.from_code_point + (i32.const -83) + ) + ) ) ;; CHECK: [fuzz-exec] calling new_wtf16_array ;; CHECK-NEXT: [fuzz-exec] note result: new_wtf16_array => string("ello") @@ -518,6 +576,27 @@ ;; CHECK: [fuzz-exec] calling concat-surrogates ;; CHECK-NEXT: [fuzz-exec] note result: concat-surrogates => string("\ud800\udf48") + +;; CHECK: [fuzz-exec] calling string.from_code_point +;; CHECK-NEXT: [fuzz-exec] note result: string.from_code_point => string("A") + +;; CHECK: [fuzz-exec] calling unsigned_code_point +;; CHECK-NEXT: [fuzz-exec] note result: unsigned_code_point => string("\u0093") + +;; CHECK: [fuzz-exec] calling weird_code_point +;; CHECK-NEXT: [fuzz-exec] note result: weird_code_point => string("\u03e8") + +;; CHECK: [fuzz-exec] calling isolated_high_code_point +;; CHECK-NEXT: [fuzz-exec] note result: isolated_high_code_point => string("\ud800") + +;; CHECK: [fuzz-exec] calling isolated_low_code_point +;; CHECK-NEXT: [fuzz-exec] note result: isolated_low_code_point => string("\udc00") + +;; CHECK: [fuzz-exec] calling surrogate_pair_code_point +;; CHECK-NEXT: [fuzz-exec] note result: surrogate_pair_code_point => string("\u286c") + +;; CHECK: [fuzz-exec] calling invalid_code_point +;; CHECK-NEXT: [trap invalid code point] ;; CHECK-NEXT: [fuzz-exec] comparing compare.1 ;; CHECK-NEXT: [fuzz-exec] comparing compare.10 ;; CHECK-NEXT: [fuzz-exec] comparing compare.2 @@ -540,6 +619,9 @@ ;; CHECK-NEXT: [fuzz-exec] comparing eq.5 ;; CHECK-NEXT: [fuzz-exec] comparing get_codeunit ;; CHECK-NEXT: [fuzz-exec] comparing get_length +;; CHECK-NEXT: [fuzz-exec] comparing invalid_code_point +;; CHECK-NEXT: [fuzz-exec] comparing isolated_high_code_point +;; CHECK-NEXT: [fuzz-exec] comparing isolated_low_code_point ;; CHECK-NEXT: [fuzz-exec] comparing new_2 ;; CHECK-NEXT: [fuzz-exec] comparing new_4 ;; CHECK-NEXT: [fuzz-exec] comparing new_empty @@ -551,3 +633,7 @@ ;; CHECK-NEXT: [fuzz-exec] comparing slice ;; CHECK-NEXT: [fuzz-exec] comparing slice-big ;; CHECK-NEXT: [fuzz-exec] comparing slice-unicode +;; CHECK-NEXT: [fuzz-exec] comparing string.from_code_point +;; CHECK-NEXT: [fuzz-exec] comparing surrogate_pair_code_point +;; CHECK-NEXT: [fuzz-exec] comparing unsigned_code_point +;; CHECK-NEXT: [fuzz-exec] comparing weird_code_point |